Author Topic: Ruby vs Python  (Read 2173 times)

0 Members and 1 Guest are viewing this topic.

Offline detective6

  • /dev/null
  • *
  • Posts: 8
  • Cookies: 13
  • Step back. Evaluate. Recognize.
    • View Profile
Ruby vs Python
« on: December 31, 2013, 09:48:29 pm »
Hey all.


I just joined recently, but one of the first things I noticed about the community here is that pretty much everyone uses Python for a majority of their scripting, which is understandable since that's the general trend in the infosec industry. I'm personally an avid supporter of Ruby, and I was surprised that there was so few Ruby devs on here (maybe they're just lurkers?).


For me, Ruby is simply more idiomatic and looks just as clean as python code. In addition, it borrows its regex directly from Perl, which I believe is a HUGE advantage. Finally, there are multiple ways of doing almost everything, for instance the "for thing in things" and the ".each" method. And it's just fun to write Ruby!


I don't really understand why so few people choose Ruby for security scripting. Some companies like Matasano exclusively use Ruby for their projects. And Metasploit is written in Ruby, so it's a pretty useful language to know. I'm curious to hear from all of you why you personally chose Python, whether you've tried Ruby, and if so, what you liked / didn't like about the language.


And if anyone is curious, here are some of the libraries I use when writing Ruby scripts.


OpenStruct - for creating quick and dirty classes with arbitrary attributes
Set - basically just arrays, but are useful when you don't want duplicate values (why reinvent the wheel for this functionality?)
Digest (module) - provides classes for crypto hashes
JSON - for json serialization and parsing (duh...)
Socket - pretty much the same wrapper as the python wrapper
URI - easy creating, handling, and manipulation of URI's
Sequel - for interacting with databases without actually writing SQL (I really don't like SQL)
I know this looks like science fiction; it's not.

Offline vezzy

  • Royal Highness
  • ****
  • Posts: 771
  • Cookies: 172
    • View Profile
Re: Ruby vs Python
« Reply #1 on: December 31, 2013, 10:31:52 pm »
Quite the contrary, Ruby is quite popular in infosec, as well. smbexec, wpscan and several other large-profile tools are written in Ruby.

Ruby is more esoteric than Python. It quite liberally borrows from Perl's TMTOWTDI philosophy, which can be seen as both an advantage and a crutch. The message passing and OO traits from Smalltalk are quite desirable, compared to Python's more mainstream Nygaard model of OOP.

I think Python being a more conservative and predictable language is what draws people to use it more. Also, reputation. Ruby simply isn't as suited to desktop application development as Python is. For small scripts and tools, it doesn't make much of a difference. But Ruby is primarily known as a language for web application development with frameworks like Rails and Sinatra. There isn't really a reliable way to build desktop GUIs, whereas with Python you have Tkinter, PyGTK and PyQt all very well developed.
Quote from: Dippy hippy
Just brushing though. I will be semi active mainly came to find a HQ botnet, like THOR or just any p2p botnet

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Re: Ruby vs Python
« Reply #2 on: December 31, 2013, 10:51:43 pm »
Also, reputation.
Indeed.

Yes there's a mass quantity of users who turn to Python, and I see almost zero Ruby posted here. Not that I'm bashing Python but it would be nice to see some more variety.
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python

Offline vezzy

  • Royal Highness
  • ****
  • Posts: 771
  • Cookies: 172
    • View Profile
Re: Ruby vs Python
« Reply #3 on: December 31, 2013, 11:03:31 pm »
Indeed.

One thing I've noticed among Python users (especially those who learn it as a first language) is that they use nothing but Python. They suffer from this inertia where they write everything in Python and refuse to try other languages. It's as if to mask their incompetence.
Quote from: Dippy hippy
Just brushing though. I will be semi active mainly came to find a HQ botnet, like THOR or just any p2p botnet

Offline detective6

  • /dev/null
  • *
  • Posts: 8
  • Cookies: 13
  • Step back. Evaluate. Recognize.
    • View Profile
Re: Ruby vs Python
« Reply #4 on: December 31, 2013, 11:49:59 pm »
I think Python being a more conservative and predictable language is what draws people to use it more.
That's a really good point. My school just switched their Intro to CS class from Java to Python because it was more relateable for kids that didn't have any programming background. I was more puzzled as to why more people on this particular site don't use Ruby though.
One thing I've noticed among Python users (especially those who learn it as a first language) is that they use nothing but Python.
And that must be why. I'm guessing a decent portion of this user base learned Python as their first language, which is logical because it's easy to quickly start making useful little scripts.
Also, reputation.
Yeah a lot of times when I tell someone I wrote something cool in Ruby, they automatically assume I made a Rails app because the terms have almost become synonymous in the trendy tech industry. Well anyhow, I'll be posting a bit of ruby stuff from now on, so prepare to see some diversity haha.



I know this looks like science fiction; it's not.

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: Ruby vs Python
« Reply #5 on: December 31, 2013, 11:53:27 pm »
Serious coders understand that Python is powerful but it's not for everything - you won't make soup with it. It has been said many times over that each language has it's own purpose.
I myself use Python a lot, but it's usually for quick macro scripts, sometimes I write a bigger project in it but only because it's so easy to do it, and Python is very big among scientists - there are a lot of great libs for plotting, serious scientific calculations, data analysis and all that jazz.

As much as I love python I choose other languages over it for different types of projects, such as C/++, Java, Delphi....
However I do agree with vezzy that programmers that learn Python and think it's the absolute bomb, then refuse to learn anything else, are nothing but ignorant fools.

Now talking about ruby, it is being used, but the way I see it, Ruby is more for large projects, some to replace PHP. You don't see a lot of simple, macro ruby scripts... or at least I don't?

Kinda drunk, I dunno... :P a programmer must know at least a few languages to get around, that is my point. Python is good, but not for everything.

Offline vezzy

  • Royal Highness
  • ****
  • Posts: 771
  • Cookies: 172
    • View Profile
Re: Ruby vs Python
« Reply #6 on: January 01, 2014, 12:00:20 am »
You don't see a lot of simple, macro ruby scripts... or at least I don't?

Actually, there are. Quite a bit. In fact, a lot of people use it for that instead of writing shell scripts, especially web developers who are very used to Ruby.
« Last Edit: January 01, 2014, 12:00:36 am by vezzy »
Quote from: Dippy hippy
Just brushing though. I will be semi active mainly came to find a HQ botnet, like THOR or just any p2p botnet

Offline Matriplex

  • Knight
  • **
  • Posts: 323
  • Cookies: 66
  • Java
    • View Profile
Re: Ruby vs Python
« Reply #7 on: January 01, 2014, 12:07:03 am »
Python was my 5th language and I have to say I use a lot. Mostly for maintenance things on my *nix system but I recently coded a irc client for proof of concept. However I learned Ruby just after Python and I just find Python to be more familiar for some reason. I use Java as my main language because I develop games most of the time I am coding. Absolutely hate C++/C, not because I'm a java programmer but because there seem to be alot of unnecessary things you have to do in it to even create a function. But it definitely has it's uses ;)

@OP
Ruby is no doubt a great language, and it's definitely used more than you think. But a lot of people go with, as vezzy said, reputation because there are just more resources all over the web.
\x64\x6F\x75\x65\x76\x65\x6E\x00

Offline detective6

  • /dev/null
  • *
  • Posts: 8
  • Cookies: 13
  • Step back. Evaluate. Recognize.
    • View Profile
Re: Ruby vs Python
« Reply #8 on: January 01, 2014, 12:10:08 am »


I agree that every developer needs to have a good arsenal of programming languages under his belt. I think knowing how you "should be" using them is also extremely beneficial (i.e. python for science and data). That's why I separate my programming into 3/4 main categories. For quick macro scripts I use Ruby because it's quick and it just makes sense to me. For web stuff I use PHP because it's so largely supported and documented. And for systems programming and programs where speed is more beneficial, I use C. Once in a while I'll fool around with Scheme when I'm doing discrete math type of stuff.


As far as Ruby being used for larger projects, yes I also use it for that as well. What usually ends up happening is I think of a quick little macro script and write it in Ruby. Then I keep adding features until I realize that it becomes an actual utility.


I just realized that I fucking scope creep myself... smh.
I know this looks like science fiction; it's not.