I've been programming (when I do program) mainly in Perl for the last 10 years or so. But I've been itching to learn a new language for a while now, and the two near the top of the list are Ruby and Python.
I figure that Ruby would be easy to learn because of its similarity to Perl (I'm told). But I also figure that Python would be easy to learn because of its simplicity. And when it comes to webby stuff, I can use Rails with Ruby and Django with Python.
I'm currently leaning toward Python and began doing so last week. I started with Mark Pilgrim's excellent Dive Into Python and made it thru the first 3 chapters pretty quickly. So far it feels pretty good.
Before I really dive in, though, I'm curious to hear what others think about the choice between these two languages.
(On a related note, you might also read Tim Bray's On Ruby post, since he just started learning Ruby.)
Posted by jzawodn at July 31, 2006 10:29 AM
Python will be more familiar to you since you're a Perl guy. (I have to re-learn Perl every time I pick it up--it's so easy to produce write-only code in it.) Ruby will stretch you more--it embodies all the right lessons from Lisp. Maybe you should consider Haskel for a real stretching. My current fave is R (http://www.r-project.org/) but I'm doing exploratory data analysis, not webby stuff.
I wanted to move to python or ruby for web development, but than again I found Jifty (http://jifty.org). It's perl, so you allready know it, it has CPAN behind it (I don't have half of life to re-write every CPAN module to ruby) and it seems like great upgrade to your existing skills.
Last year I started trying to learn Ruby, and found it fairly easy to grasp... much easier to grasp than Rails actually. This year, I started learning Python, and subsequently Django, and found them to both be a lot easier than Ruby. The only caveat is that I'm not a trained programmer. I'm just a designer that happened to pick up on programming practices through the use of PHP applications, and then through learning proper Javascript writing. As such, your mileage may vary with any language you decide to learn, and any framework for said language as well.
I think you might learn Python, becouse it is a very simple and powerfull language.
I´m currently doing a component framework using python, and i´m very satisfied with this. This framework has a version in Java, so i can percept the big diference in the code. With Python you write less code and a legible code :).
In my job i have a friend the like Ruby and i see him doing something with this frequently... he agree with me that python is more elegant than python, becouse somethings are more easier (sintaticaly and functionally) in python than ruby.
Additionally, python is becoming a popular language very quickly.
Let us know which one you switch to..
I myself tried to learn python (and succeeded in learning how to make a form, check it against some stuff, and spit out new content based on form actions).. but that's about it.
I find PHP just so easy to do anything I want with, and it's already installed everywhere so that's a bonus.
Also, there's just too many frameworks now for all the languages that I'm afraid to learn one for fear of it going obsolete.
Ryan:
This isn't about *switching* as much as adding a new tool to my collection.
I'd go with Ruby. I took a class last semester in Python and I learned Ruby on my own. I'm by no means an expert, but I have had some exposure to both.
What I didn't like about Python was the fact that OOP seems bolted on. For example, to open a file you use "f = open("text.txt")" but to close it you do "f.close()". Ruby is much more elegant in that everything is an object.
For web development I'll go on with php but for data crunching or scientific stuff I chose (I mean last week) python. Very valuable also R, as Rob suggested, a bit memory hungry but a powerful statistical tool.
ciao
Danilo
Disclaimer: I work with Django, at the company that originally developed it.
My general advice on the Python vs. Ruby question boils down to asking "how does your brain work?" Because, really, the two languages are about equivalent for most practical purposes (except Unicode, but Ruby will be fixing that soon enough). The big difference is in the idioms and conventions of the languages; for example, Ruby programmers, IME, tend to be much more willing to do things like adding new functionality to the built-in classes, while Python programmers are generally hesitant to do "monkeypatching" anywhere (and can't do it to the built-ins, because they're not mutable).
Ruby's got quite a bit more syntactic sugar (some of which will be immediately familiar to the part of your brain that's assimilated Perl), but of course that comes with the overhead of having to learn how it works. Python has much less of that, but at the cost of being more verbose in plenty of situations.
Anyway, regardless of your choice you're going to have access to good documentation (Dive into Python is a great book, ditto the pickaxe book on the Ruby side), strong communities and motivated people writing heaps of solid, reusable code; it's a win either way, so I'd say dip your toes in both pools, then follow through with the one you feel most comfortable programming in.
I'm going to vote for ruby because it's one of my favourite languages. My opinion probably isn't worth that much since I've never done anything in python but ruby is a lot of fun to program in.
It also has one of the best guide/tutorial I have ever read:
http://www.poignantguide.net/ruby/
Python, man! Python.
I'm biased, as a Python lover, a contributor to open-source Python projects and somebody who gets paid to program Python professionally every day.
Python just feels right to me. It feels clean, it feels poetic, it feels beautiful.
That's subjective, though, and clearly each programmer is different.
One *objective* thing I can point out, though, is that Ruby has become popular largely due to a single application (Ruby on Rails), whereas Python has been entrenched in many disciplines, from science and mathematics, to journalism, to Web development, to data manipulation/analysis, for a while now. There's a lot of great, free Python code out there.
Have fun with "Dive Into Python" -- a fantastic book -- and I enjoyed meeting you (briefly) at OSCON.
I absolutely love Python -- it really depends on what you want to do though. For the sake of learning a new language, Python (as a language) is just great. I wrote a GUI sudoku assistant in Python, and for me it was a lot of fun.
To put things into context, I'm not a fan of RoR. I much prefer PHP.
I don't think Ruby is more like Perl, other than using punctuation/symbols with variables.
In any case, I find them both very enjoyable.
Oddly enough, in my experience, it seems like ex-Perl guys are more likely to go with Python and ex-Java guys are more likely to go with Ruby. YMMV.
How about something sufficiently different from Perl? Neither Python nor Ruby really qualify. Say, Erlang?
I think it comes down to how much cleverness you like.
Ruby will let you do some incredibly clever, magical things that may or may not be understandable or obvious to another programmer.
Python places much more emphasis on being simple and direct. That means that sometimes you have to be more explicit about what you want the code to do, but it's usually clear and understandable to someone reading it.
What style you prefer is definitely a matter of personal taste.
Me, I enjoy the satisfaction of crafting something clever every now and then, but most of the time I just want code to be stupidly obvious and easy to understand, especially if there's more than one programmer involved.
Ultimately, both are vast improvements over Perl though. After coding Perl for five years and being a big Perl evangelist, it took me about two weeks of working in Python before I decided that I never wanted to touch Perl again if I could help it.
Pick up both and keep us posted on your progress, findings etc. :-) Love to hear your POV
Btw, no point learning X for its similarity to Y since that defeats the purpose learning a new language, no?
I was a Python user for quite a while before switching to Ruby.
The languages themselves are both modern, dynamic languages and I think you will find them both to be compelling upgrades from Perl. Whatever option you choose, the combination of a modern dynamic language with a clean MVC framework and object-relational mapping layer is very powerful.
The standard Python libraries themselves tend to be somewhat better thought out and structured than their Ruby equivalents. (I'm thinking in particular about Net::HTTP in the Ruby world, which has some odd warts and missing functionality.)
On the other hand, the Ruby language has a more consistent design (everything is an object, every class can be extended, etc.) and a more expressive syntax for things like blocks and regular expressions.
The tipping point for me was Rails.
Python web development is fragmented into a number of alternatives (http://www.boddie.org.uk/python/web_frameworks.html). I'm not knocking Django or Zope or any of the other frameworks, but the net effect is that the communities end up being fragmented across the different frameworks, decreasing the development and support bandwidth of any particular framework.
Rails is the predominant Ruby web application framework and has a unified community, resulting in extremely rapid progress in the framework, an abundance of plugins and generators, and great support.
I've had success with Rails both in a personal project (Berry411), and my company has successfully deployed Rails in a larger scale site built by a team of 5 developers (Jobster.com).
I can't pass comment on Ruby as I haven't used it but the main reason I would recommend Python is that it is just so bloody useful.
I've used everything from Z80 Assembler to C/C++, Java, TCL and Perl but Python is the one that I am most productive in.
I'm still only scratching the surface as I start stretching my programming muscles after far too long managing projects but eveything always ends up easier than I expect it to be. Mark's book is great too. And as for his Universal Feed Parser - love it.
You know that I'm a Python person, but I do recommend looking at both. Ruby has some very interesting tricks up its sleeves with respect to things like crafting Domain Specific Languages (something Rails takes great advantage of) and Sam Ruby has been doing some baffling things with continuations recently (see his blog).
That said, having experimented with both Python has retained its spot as my preferred language. It's exceedingly well designed - if you ever catch one of Guido's keynotes it becomes clear just how much thought goes in to the tiniest details. "Pythonic" code is a pleasure to write and a pleasure to read. But it definitely comes down to personal taste.
If you want to learn something /really/ interesting, take a look at OCaml. It's a type-inference functional language with (apparently) excellent library support and incredible performance - half the speed of C in some cases.
While I *love* Why's Poignant Guide, I'm of two minds as to whether or not it's actually helping me learn Ruby. Although I want to go faster all the time, just to see what he does next, so I suppose it is good in that respect. I'm also in two minds about Ruby – compared to Python it makes my brain hurt, but I respect it for being so strictly object-oriented.
I'm finishing up a large python project, and it drives me up the wall. For a while I was sending "Python Sucks #??" email to my friend Nelson every day. My main complaint with it is that it doesn't have the finish and consistency of Perl's mental model -- that is, unlike Perl, for me, there is no point at which I've learned how python does things and now I can reasonably guess what the right way to do something is, without having to look at the docs. That said, I think the wxPython project is great, and there are lots of other parts of Python that are neat or interesting.
Unlike Python and like Perl (again, for me), Ruby has an internal consistency and beauty that have made it a pleasure for me. I still like Groovy better in syntax and in libraries, but Ruby is much more usable as a real application tool.
I'd suggest you do both, as I would really welcome a comparison by someone who didn't start in one camp or the other.
I'm a big Python user, and I have yet to hear a cogent reason why I might want to use Ruby instead.
Disclaimer and disclosure: I'm not really a programer at all, I'm a web designer who dabbles in programming, mostly with Django (these days) and PHP (in the past). I also work for the company that originally developed Django, although I was not here at that time and have no real ties to it, as my job here is as a designer and I don't do much (if any) programming for the day job. I've never written a line of Ruby and don't know much about it.
With that out of the way: if I were going to pick one or the other to learn, it would be Python, and the reason why is simply that it's more widely-used across more different areas and more different industries. I've heard almost exclusively good things about Ruby and Rails -- so I'm sure they're great tools (and there would certainly not be anything wrong with learning both!). But, as Adrian alluded to, Ruby seems (at least from an outsider's perspective) to be pretty confined to the Rails community. One framework, one use (web development). Python, on the other hand, is used for so many different things in so many companies that it just seems like it would be a more valuable addition to your toolkit.
I guess Ruby just seems kind of niche, where Python seems more general-use and widespread. I'm very aware that Ruby is capable of being used for more than just Rails and web development -- but it doesn't seem to have much buy-in from the programming community at large, outside of that niche.
And I'll say again that is purely the *perception* of an outsider, and likely doesn't reflect reality. But, perceptions matter. And my perception is that if I walked into an interview and said "I know Ruby," the interviewer would likely think, "okay, this guy can make Rails-based web apps." On the other hand, if I walked into the same interview and said, "I know Python," he/she might think, "this guy can write all sorts of apps with all sorts of uses, on or offline, and can probably wrangle any of a handful of Python-based web frameworks for the web stuff."
I'd suggest learning both (how's that for unhelpful!) assuming you have the time. I recently was in the same boat and read "Dive into Python" and the Ruby pickaxe book and "Agile Web Development with Rails". Then I ended up doing a project with Ruby after playing around with python. This was all in my non-work "free time" and I found it was a lot easier to get back into Ruby than python. The python ecosystem seems to be a lot more developed at least right now.
I guess I'll suggest something that nobody else has yet to suggest that ISN'T Python or Perl.. How about Smalltalk's Seaside environment (see link below)utilizing either Squeak smalltalk (open-source) or Cincom's Visualworks environment (that's what I use)? It's a 100% change from what you're used to and is 100% OO (object oriented).. I'm in the process of converting a bunch of PHP code that was a pain in the $##$! to keep maintained to this environment and it is SOOO much easier.. I tried learning RoR, but found it rather confusing with all of the files it left everywhere. The ST environment has some things to offer that none of the others do such as real-time debugging/profiling via a web-page -- let's see you do that with Python or Ruby or PHP! Seaside's able to generate XHTML compliant output and you don't even have to write HTML! It's all done programattically with callbacks for form processing (to fill in variables, etc).. It's got Ajax support and someone just recently took a cut at YUI capabilities as well.. Overall, I've been very impressed with it and hope to have my rewritten web-app ready to go in the next month or so as my time permits.
Checkout : www.seaside.st
Depends on what you love about Perl.
I've tried switching to Python from Perl several times, and while I found it easy to learn, and easy to love, working on large projects brought to light just as many weird-ism, and in the end it had a bondage and displine approach to coding that made it no fun (like Java).
So for years I pined, missing Python's IDLE, and objects all the way down, first class functions, etc. And then I found Ruby. And it was all that and more. A pure delight. Makes working in PHP during the day *even harder* then it already was.
That said Python is faster then Ruby, and we are unlikely to see Ruby running on the S60 phones anytime soon. But if you're just wanting a language to stretch your thinking, or if you're wanting a new webstack, go with Ruby. If you're wanting something to use in *new* environments, e.g. embedded, go with Python.
Definitely Python. I started learning Python a while back and have been happy ever since. I can do web stuff, batch processing, windowed apps, etc. and I don't have to change much.
To me, Ruby only received the attention that it did because of Rails. Some people think it has a better syntax and I think that's all personal preference...
Last week, I attended the recent "Ruby Guidebook" tutorial by Dave Thomas at OSCON. I have to say that coming from Python, I was appalled by all the syntactic cruft in Ruby. I was able to quickly write out shorter and clear Python alternatives to the presented Ruby examples.
Then we arrived at part 2 on OOP, blocks and metaprogramming. I liked the "everything's an object" part of Ruby. Blocks were like the full-blown lambda that Python still needs, but without the bad Lisp connotation. And metaprogramming was more accessible -- but I still can't see any cases where I'd use either the Ruby or Python versions in my code.
More or less, Ruby probably has the slight edge with OOP and blocks, but Python wins with me with its powerful list and generator comprehensions (which I use constantly) and with its far cleaner (and, most times, shorter) code.
Pay attention to James Bennett's comment above. I disagree with the idea that it is "taste" that determines which language you like ... it really does come down to "how your brain works". I can't find Ruby's syntax enjoyable or even workable ... I hardly ever have to look at a Python manual for syntax ... it simply flows out of me when I code. My brain is configured for Python.
I see "taste" and "how your brain works" as meaning pretty much the same thing.
I prefer Python to Ruby. It was alot easier to hack my PHP class for sending SMS messages to Python than what it has been trying to get it going in Ruby. I find that from a Perl/PHP perspective, using Python is a lot easier than Ruby. Although I would like to, at some stage master Ruby, I doubt it will be in the near future.
If you are planning to do network related things Python has an excellent networking framework called Twisted (http://twistedmatrix.com/) which I've dabbled a bit with on a product project (I basically fixed various bugs and added functionality which I required which I could hack in).
agree with Grrrr, there is nothing to pick up from ruby or python but some syntax. they both are essentially as capable as perl. if you are a confident perl programmer, i recommend staying a perl programmer or looking at perl6, which will be more capable than perl5, python or ruby. at the very least it might be useful to look at ruby if only to dispell some of the hype.
following Grr's point, looking at erlang (for example) would actually be educational - it is a different tool offering different solutions and new ways to think. erlang in particular has attributes neither ruby nor python have - very strong support for concurrency. the whole point of erlang is concurrency, it is not an afterthought. given herb sutter's nice piece on the serious role concurrency will play in the future, its worth looking into.
i have been spending six months trying to become a haskell coder. once again, a totally different beast from perl/python/ruby. the six months prior to that i spent looking at ruby, but went back to perl once i realized CPAN has no peers.
I've been trying to decide for a few years now, still can't make up my mind that one is worth all of my attention.
While I still do lots of Perl at work, a few years ago I started looking at both Ruby and Python and started working with Python. Didn't do a ton with it but enough to get a feel. Most recently did some playing with the django framework.
I guess I didn't feel satisfied because a few months back I started a new side project and chose Ruby and RoR. I found Ruby and particularly RoR to be a bit more difficult to get my arms around, but a fun challenge.
So perhaps the answer is both, just a matter of what one to start with.
as a followup after seeing more of the other comments - i see grrr and simon willison have both suggested functional languages (as i did) as more interesting alternatives. i also mentioned concurrency. i would like to point out that it is no accident that functional languages are very well suited for concurrent coding, as they have strict semantics for mutability. as a more esoteric project, dan sugalski (formerly of the parrot project) is working on a vm called tornado with high concurrency built in from the ground up.
i also think something like opengl is really worth looking into. the next web is going to be very graphical.
Ruby programmers have more fun. I love Ruby, but I write any code that I intend to maintain for the next decade in Python.
Corey:
I certainly could. But that doesn't help me decide which of them to learn *next*... :-)
Jeremy --- yeah, why don't you take one for the team, and try them both for a while? Your experiences would make for good blog reading.
I haven't used Ruby but Python isn't a bad language to learn. You'll produce the tidiest looking code in Python.
That said, if you want to learn a lot from a new language, I would suggest Ocaml. It is a very high level language that is as fast as C++. The first application that I wrote in Ocaml was about 2K lines of code and it worked without a hitch the first time I successfully compiled it. Ocaml is also very terse and although the learning curve can be a little steep, it is definitely rewarding.
I poked my head into both. Ruby looks very exciting from a language design and theory perspective - it's very clean, everything's a message, all that good stuff.
I was put off by python's space-nazi thing at first, but once I got past that I liked pretty much everything else. Couple of places where Ruby feels cleaner, but Python's quite nice. Certainly much prettier than Perl (I used to be a Perl hack in a previous life).
I ended up at Python - for some reason I was more immediately useful in Python that I was in Ruby. I also was more drawn to Django than RonR, primarily because I have terrible memory and had a hard time remembering the RonR magic.
I still intend to get into Ruby some day. You can do crazy things like this: http://www.artima.com/rubycs/articles/patterns_sexp_dslsP.html
I am learning Python right now from Pilgrim's book. It is easy to learn if you know Perl fairly well; essentially no new concepts. But that is the depressing part. It seems like a fraternal twin: nearly the same age, similar outward features, similar upbringing, similar inconsistencies in different parts of their personalities, and lots of their friends pretending the two are really different.
So, maybe you shouldn't learn Python because it won't be too interesting. Maybe go retro instead and learn Scheme or APL or Cobol.
My extremely biased opinion is that you should learn Python first. I would especially encourage you to play with the more unique features of the language like list comprehensions, generator expressions, and Python decorators. Also, I would recommend playing with duck-typing, applying aspect-oriented concepts and monkeypatching, and if you're really adventurous, metaclasses :)
Ruby is a decent language, and I like Rails a lot, but I find the concise, consistent, one-obvious-way to do most things in Python ends up supporting a lot of clean programming practices.
If you will be doing web development with Python, I would recommend Django.
I'm a big fan of Python, but my salary is paid because of Perl ;) What I've seen along my friends is Perl hackers like Ruby more than Python, because its syntax is more flexible (ala Perl). To me, Python is a very elegant language, very well designed, simple but very powerful. I think you should test both for a while and select the one you feel more confortable.
Jeremy, whatever one you do choose to learn, I hope you'll do some followup posts with some examples and stuff..
I'm sure you could come up with some interesting blog posts about learning a language as you discover a bunch of odd quirks along the way.
I say go with python. If google's emulating yahoo's portal style, the least you can do is learn their language.. right?
I recommend you learn HINDI. It is and will be waaay more useful than either Ruby and Python added together.
In Tim Bray's entry... how about this line:
"But in practice, when I look at Python code I find my eyes distracted by a barrage of underscores and double-quote marks. Typography is an important component of human communication, and Ruby’s, on balance, is cleaner."
Well, as a Python guy (and C# and Clarion and...) I find Ruby's symbols distracting along the same lines. @ and @@ and then semi-colons... not as beginning of loops but as :: separators to a method or : as a beginning of a symbolic name or some such. I don't see how Ruby is any prettier than Python.
And another thing struck me when Tim was doing his Atom presentation at OSCON. He was talking about how there were some holes in the XSL processing library in Ruby (or something along those lines... I can't remember exactly) and you could bet your life savings that not only would Python have a solid library to use... it would probably have several different to choose from (if the standard one wasn't setup to your liking). Certainly in terms of existing code and existing libraries and ports... Python has an edge. But with Ruby's rapid gain in popularity... things could change over time depending on whether it's a solid movement or just a fad.
Fish a coin out of your pocket. Label 'heads' Ruby, and 'tails' Python. Flip the coin. Whichever side you *hope* will land face up is the next one to learn.
Several years ago, when I outgrew AWK as my primary (toolbox) scripting language, and I learned Python. Back then Ruby didn't have the momentum that it does today, but I still had looked at it.
I was never a big Perl fan; I didn't care for the (symbols/special character) syntax and had seen too many people write code that they couldn't maintain when they picked it up six months latter.
There is one basic philosophy difference between Ruby and Python. Ruby follows the Perl philosophy that there should be many ways to do the same thing. Matz, like Larry Wall feels that is a benefit to creativity of the programmer. Python on the other hand, goes out of its way to try to have only one way to do something.
So since Ruby looked too much like Perl for me, and this basic difference in philosophy, convinced me to go with Python. I haven't regretted it.
Three big complaints you will hear with Python are 1) the white space indenting. I happen to like it and if you use an editor that understands Python, it won't be an issue. If you don't, just use spaces and not tabs :-) The second complaint is the need to define "self" in every method. And yes, the language could do with this, but for everything else I get, I can live with it. And the last complaint is they just haven't got it together on a web framework. Yes, they have made big strides recently with Turbogears and Django, but for a language that prides itself on having one way to do something, this is still an issue.
So like many have said, I don't think you could go wrong with either language. I don't mean to be a Ruby basher, I think the language has a lot going for it, but I prefer Python.
Since you already know Perl, I'm not sure how much you'd get out of either Ruby or Python.
Ruby will probably remain the king of the hype cycle until Perl 6. Rails worries me a bit for anything more than personal toys: check the Rails sites out there--they all seem really slow and overly chatty with the server compared to stuff using J2EE, PHP, Django, etc.
Python has a whole lot on Ruby as far as breadth and depth of projects out there, but explicit self and the verbosity might drive you nuts.
If you're looking for OO with a web framework, check out Smalltalk and Seaside (http://www.seaside.st/), under the Squeak (http://squeak.org/) environment. If you can get past the ugly Squeak interface, you'll find a whole fascinating world in there made from OO done right.
If you're looking for something that will punish your brain and force you to grok the functional world, check out Haskell (http://haskell.org/haskellwiki/Haskell). Some people prefer Ocaml to Haskell.
There's been some noise regarding Erlang lately, too.
I strongly recommend anyone interested in Python to read Eric Raymond's article "Why Python" (http://www.linuxjournal.com/article/3882). I quote:
"When you're writing working code nearly as fast as you can type and your misstep rate is near zero, it generally means you've achieved mastery of the language. But that didn't make sense, because it was still day one and I was regularly pausing to look up new language and library features!"
Another thing I like about Python is the amount of libraries aavilable. You can do statistical analisys (interface to R), cellphone programming (with the Nokia S60 Python interpreter), Beowulf Clusters (PyMPI), web programming (Django), C callable routines, extend Python with C, use most GUI libraries available in Linux & Windows, program sockets, threads, server daemons, games! (PyGame), web services, simple scripts to parse logs, VoIP servers (twisted)...
And finally, it's both compact and elegant, and reading other people's python code is much easier than other people's C, PHP or Perl.
I’m doing quite a few personal projects and I wanted to learn either Ruby on Rails and Django. I bought the Agile Rails book and I read it in a night and spent about two weeks really liking Ruby on Rails. To be fair, I almost gave up and joined the Rails camp but I tried Django in a night and after a slightly harder setup curve, I was doing more in less time. Django just fit me do to it’s “stupidly fast development” mantra.
Both are miles above anything that I’ve used in previous jobs (Asp, Asp.net, PHP4, etc) and I highly recommend them both! Aside from web, both are perfectly capable languages and I’m amazed at the high level of quality frameworks and code that keeps coming out.
Having dabbled with both (much more ruby than python admittedly) I say ruby.
Why? it's more consistent. Things do what you expect them to - Take for example applying a function to a list.
In ruby, you just go list.map {|x| a = x + 1; return dostuff(a) }
In python, you either have to declare a function elsewhere (because lambdas can only have 1 statement), rewrite it to use 1 statement, or use a list comprehension - none of which spring to mind as 'the obvious thing to do'
I could go on and on, but while both are nice, ruby is much more "usable" in that it's easy to guess both how to do new things and what existing things do, while python (IMHO) is not.
PS: If you put in an invalid email address, it takes you to the 'please fix your comment' page which you can never submit, as it doesn't have the "Type jeremy" textboxt :-)
It depends in part what you are doing. Some things are easy. GUI apps, games, deployed applications, scientific applications...? Then you want Python over Ruby with no question. For sysadminy stuff Python is generally more popular, but if you are planning to use it alongside Perl then that's probably not a niche you are looking to fill. In the web realm... well, you know what that's like. For the casual or occasional web programmer, the hottest frameworks in either languages aren't really well suited.
In terms of what you'll learn...? I'm not sure; the two languages aren't that different. Generally Ruby libraries are more object-oriented, and Python libraries more function-oriented. You'll see more OO tricks in Ruby (things like method missing hackery, clever class construction, etc), and more functional tricks in Python (things like decorators and generators). But this is only a tendency, it's not a specific feature that one has that the other misses. There aren't any core language features one has that the other doesn't.
If you are interested in language design and underlying implementations, there's something in both languages. Ruby will be more accessible; casual DSLs are easier to write, YARV is a smaller project, language design is generally more open. Python is in a different stage of its life; Python 3.0 offers a chance to have input (but less so than in Ruby), PyPy offers some deep coding. There's both JRuby and IronPython/Jython if you want to go that way for some reason.
If you just want to get stuff done... well, they are both capable scripting languages, just like Perl.
Isn't it sufficient to know 1 language in each of the following categories?
1)Procedural
2)Scripting
3)Object oriented
My votes go to C, Perl & Java.
Of course, if you're itching to learn a languague, go Python!
And when it comes to Object Orientation, there aren't too many languages cleaner & more elegant than Java. (Can almost hear the scripting zealots rolling up their sleeves.)
I'm primarily a Ruby programmer, but I've used Python a bit (just enough to know I didn't like it). What really bothered me was the crippled lambda - it felt like Python promised a lisp experience, but when it came down to it, just wasn't lispy enough. Ruby's functional programming just feels right to me, plus there's the very clean, smalltalk-inspired OO as a bonus.
Python or Ruby?
Wel, if you start with Python, chances are you'll just fall in love with it, and you won't feel the need to look elsewhere.
And that would be exactly the case if you start with Ruby instead.
This is because both languages sem to hit the same spot.
Bot are simple, readable, dynamic, fun, etc, etc...
And of course, the first one is always "easier" than the second one, because you already had time and practice to get used to it, and once your brain is molded to a language (or an application), it's hard to change.
It's like asking a java programmer in what language he would be more productive. It doesn't matter if Python or Ruby are easier, if all he knows is Java, he would be more productive in Java...
No going back to the "Python or Ruby" dilemma, I think it comes down to a few idiosyncratic aspects:
Python tends to prefer "only one obvious way" of doing an specific task, thus making it easier to learn and remember. On the other hand, Ruby tends to give you more freedom and multiple ways to get something done. This can be good once you know the language, but it will make it harder to learn (or to read for others).
Also what python programmers love, could be exactly what others hate (for example: indentation).
Like wise for Ruby (braces, "end" for terminating loops, etc).
Luis
Over the last year and a half I've learned both languages. Python came first, which was pretty easily attained. I've done ObjectiveC, PHP, Perl, C and C++ development over the last five years, so Python was pretty easily tackled once I added the syntax to memory. I was working primarily with the PyPbjC bridge for doing OS X development, so in a couple of weeks I was happily coding GUI's. With that said, learning Python did not really give me much in the way of new knowledge or advance the limits of my programming knowledge very far.
Then I switched to doing a new Rails project last July (shameless plug: http://www.near-time.com/) and had to learn Ruby and the Rails API's to get to work. Learning Ruby greatly advanced my limits, by introducing mixins, closures, block, and all that fun stuff from Lisp and friends. Ruby has felt right and I continue to be amazed at how much I can accomplish in so little code. I've since embraced using Ruby as my primary scripting tool in my admin duties and day to day computing. Rake (http://rake.rubyforge.org/) is an invaluable tool and Capistrano (http://manuals.rubyonrails.com/read/book/17) lets me script my servers in a painless manner.
For me, there have been more moments of joy and I've learned much more from the Ruby experience. I think you'll find Python easier to pick up, but if you already have a dynamic language in the toolkit then I'd go for Ruby. Plus you can see what all the fuss is about with Rails. It's quite slick. ;-)
Cheers,
Blake
there is really no substitute for trying both and sticking to the one you prefer.
I too have had significant experience with both, and personally I think Ruby is much more interesting and elegant. Examples include: 1. True OO, e.g. `2.days.ago`, 2. Built-in RegEx, rather than as a library. 3. The use of co-routines is super-cool, eg. no more need to worry about finally blocks for closing files, releasing locks, etc. 4. Beautiful succinctness, eg. optional parentheses, @var for instance variable and @@var for class variable (rather than self.var & self.__class__.var). The list goes on. Python is simple and straightforward, but Ruby has more new ideas, and is generally more powerful and expressive. The only drawback I would consider is that Ruby is about 10x slower than Python (as far as I know), due to the lack of a bytecode format. Bottom line, if you want to learn to think differently about programming, go with Ruby.
Jeremy,
Since you want an extra tool i would recommend Python. Language wise both are beautiful languages each have their own set of supporters and critics. You could go for the flexibility of Ruby or the more 'there should be only one way' approach of Python. I prefer the later, because it allows me to quickly understand libraries written by others. This helps me using lots of different libraries and understanding them fairly easy which keeps me from suffering from the NIH-syndrome.
Python also has a huge set of excellent libraries. Want to script/automate the web, use 'twill'. Want to process LOTS of information use scipy of pytables. Network programming? Twisted or Pyro. Interface with C? use ctypes or pyrex. Create rich interfaces or want to create a game? Use Pygame or PyOpenGL. I know that for many of these solutions there just isn't an alternative with the same high quality in the ruby world.
Performance wise, Python outperforms ruby or perl. Besides that, lots off effort is being put in making it faster (recently the need-for-speed sprint). There are lots of projects that will allow you to write code in plain python and have it run blazing fast. Not just numerical computing (for which you could use scipy), but there is a JIT (psyco) and multiple ways to actually compile your python code (shedskin, pypy, pyrex).
I have been using Python now for about 2 years now and it not only allowed me to finish project much faster then i used to (in C or Java). But also had a big influence on my workflow. I never ever use Matlab anymore but just use 'matplotlib' and scipy. I've recently discovered Pylons, a web framework which i really start to love. And currently i'm working on something which is very CPU intensive. It was too slow for native Python, and even when running it under numpy just wasn't fast enough. But ctypes allowed me to rewrite the inner loop to C, vectorize it with GCC 4.2 and call it from within Python. The result is not only awesome fast but the time cost for creating this all was amazingly low.
Cheers,
Nicholas
Like Blake Watters above, I learned Python first. I used Python for about three years before I started learning Ruby. I've been doing Ruby for about two years now.
For me, I definitely preferred Ruby over Python, however I greatly prefer Python to Perl. :)
Both are great languages. I do feel like Ruby offers some things that Python doesn't, blocks, mixins, symbols, better OO support, etc. As many others have mentioned, it really is personal preference. A lot of it depends on whether you like a method like this:
def hello(self, arg): # self would only be used in the case
print arg # of a class method. But it's used
# all the dang time there.
or like this:
def hello(arg)
puts arg
end
ultimately it boils down to things like having to have a self reference in class methods (python) or having actual data protection through accessors (ruby). The explicit use of self does allow you to do some rather interesting things I've read, in practice though, I found it irritating. Ruby offers real data protection for it's member variables if that's important to you. They also have some really neet syntactic sugar, such as:
attr_reader :hello
statements like the above read almost like a dsl, but are just function calls. Ruby let's you omit the parethenses around your arguments if it's not ambiguous. If you omit the parentheses from a Python function it returns the function as an argument:
test = hello
test(arg) # calls the original hello function with arg
Ultimately it really does boil down to a pure aesthetic choice. I doubt there is anything I could do in Ruby or Python that I couldn't do in the other language with a similar amount of code + or - a bit. It's nothing like the difference between doing it in Python versus Java for instance.
I would like to clear up a few misconceptions that people have posted about Ruby. A lot of people have said that Ruby is sort of a one trick language, as in Rails. This could not be further from the truth. While it's true that Python has more mature libraries, what shocked me about Ruby was that Ruby programmers *live* in Ruby to a degree that was astounding. I never got the same feeling from the Python community. Ruby programmers do absolutely everything in Ruby.
Additionally most good Ruby that I've seen doesn't remind me much of Perl. The Ruby way of writing code is just as un-perlish as the Python way. However in both languages, you can write the code in a way the would make regular users of the language cringe. Ruby will probably open you up to more deep computer science principles imo than python will.
So, my preference having used both of them extensively, is that I prefer Ruby, but would have no hesitation to use Python for a project if it seemed to fit better. A lot of it depends on the project, but for general learning, I feel like both languages are going to become immensely popular in the years to come. So you should learn both. :)
Perhaps this will interest you. Also check the link that's included there to the new Django review.
Considering how similar Ruby and Python are, I'd say it doesn't really matter. Once you know one of them, it should be very easy to acclimate to the other within a few days of immersion. I did so in the order of Python then Ruby, with the help of Dive Into Python -- an excellent text that's never boring; if you're having fun with that then go for it. Besides, Python seems to have more extensive, free, up-to-date English documentation and books (unless I've missed something in the Ruby world altogether). If you feel like using Ruby then that shouldn't be hard either - again, the crossover is pretty seamless. So don't sweat it; there's ample time to learn and try both since the learning curve is low for one after you learn the other.
But this is considering the general languages. If web frameworks is a concern, I'm not too sure. Rails is well reviewed and something of a Ruby standard. I personally like web.py (http://webpy.org) but your results may vary. Take a glance at examples and see which looks the cleanest/easiest/best for you.
You can try to weigh the choice against past Perl knowledge or whatnot, but I highly doubt it matters. Both Ruby and Python have many great merits and annoyances (Ruby's superfluous "end" statements versus Python's colons). To quote Futurama:
Fry: "How can I live my life if I can't tell good from evil?"
Bender: "Ah, they're both fine choices, whatever floats your boat."
From my point of view Python seems more stable and scales well. Have you taken into consideration PHP too? It has a more C-like syntax (just as Perl) and a great community. They're all strong and reliable languages, and choosing one depends on what you aim by learning it.
Cheers!
I started programming with Perl, then moved (kinda) to Python and now I pretty much do most of my coding (outside work) in Ruby. Personally I think Ruby is more flexible in that I can make it do what I want in whatever way I want. Know what I mean? So if you're coming from Perl-land, it is likely you'll enjoy programming in Ruby.
> In ruby, you just go
> list.map {|x| a = x + 1; return dostuff(a) }
Am I missing something (I'm not really familiar with ruby), or is this really just equivalent with the following python code?
[dostuff(x + 1) for x in list]
if it is, I'd say python takes this one.
peace.
Ruby.
Python is just Perl with a different beat. If you are going to the effort of learning a new language, learn one that will make you think differently about programming.
Ruby is what Perl and Python should have been one day, but got distracted.
As for the others. Well, thinking about learning something like PHP to do web development in this day and age is like learning machine code because you want to build a word processor...
Learn both.
You've got a lot of perl knowledge, in a couple of weeks you should be able get to the point where you can write useful 20-40 line apps in either.
Both languages have their strengths, and it's good to have a choice.
But learn Python first, because Dive Into Python is awesome. Once you've used that to unlearn some instinctive perlisms, Ruby will be easy.
Hi! Which one would you recommend for a total newbie to programming?
I am a python person from top to bottom. But even I have dabbled in learning Ruby. So I will cast my vote as saying that you should look at both(but look at Python first! :-)
There was an article that was written that mentioned Python will change the way you think about programming, and I think that statement was very true for me.
Well, I'm a Perl developer right now and the only scripting language I thought about learning was Lua. It's very small and lightweight.
@Simon Willison:
Taste != way your brain works. I like the look of Lisp ... The use of parentheses & prefix notation everywhere is very appealing on the surface. But in practice, it's extremely jarring when I sit down to code -- the flow is not there and will never be. But I can appreciate the language and how certain things are done.
I can appreciate things about Ruby too -- some of the language aesthetics are appealing (like blocks) and I wish they were in Python. But syntactically it looks like a traffic accident.
@Blake and Doug:
I have to correct some misinformation here ... you didn't delve into Python completely ... mixins and closures are part of the language. Blocks are the only things you mentioned that aren't part of Python.
You might find this useful if you are trying out Python:
http://swaroopch.info/text/Byte_of_Python:Main_Page
by Swaroop CH (of Yahoo)
You have plenty of good feedback, and both Ruby and Python are well designed and productive languages. Both communities are good as well. Still I think that in many areas, the Python community has some hard earned momentum that will take the Ruby community years to match.
In scientific computing, for example, numpy, scipy and matplotlib make up a pretty reasonable matlab replacement. There are projects for networks and graphs like networx; proof systems like metamath/ghilbert. Pretty much anything you want to work on there is a good starting point.
I had the same decision a few years ago. I looked at the features of both languages and decided that Ruby looked nicer. Then I tried to write a real program in it, and discovered that Ruby had rather poor library support. (It's surely better now, but looks like it's still behind Python.)
I'm not sure if Ruby has decent Unicode support yet, for example. And on another program, I wanted to use OpenGL; the OpenGL in Python is mature and working, but Ruby OpenGL is just a .tar.gz download of somebody's homepage, version "0.32g". Gtk+ has great Python bindings; Ruby's are several versions old. And so on.
So I'd say: If you want to learn the language to have another language to play with, and/or to hack the language and libraries yourself, learn Ruby. It does seem a bit more elegant, in some ways. If you want to have a language to use for products that need to ship, or interface with specific existing libraries, then learn Python.
They're both pretty good languages. To me, the library support is where they differ.
I don't know Ruby well enough to make a judgment, but I think Python has reached that "critical mass" where it would be useful to learn it either way you go. And the fact that's it's so easy to pick up yet powerful to use doesn't hurt either. ;p
Ruby. Ruby's code blocks allow you to create all sorts of natural looking little languages quite easily (no parsing required). Python's lambda's are seriously crippled by being limited to only one line of code. And then there's that indentation-as-syntax thing Python has (makes it tough to copy&paste code for example). Metaprogramming in Ruby seems to be a bit easier as well.
Going from Perl to Ruby is deceptively easy at first, but as you dig deeper you'll find a different philosophy at work - it's more like Smalltalk - so it's easy to quickly become productive in Ruby if you're coming from Perl (that's what I did), but Ruby is different enough from Perl so that your mindset will change in good ways.
If you're looking for a Ruby-based web programming framework that's not Rails, check out Nitro ( http://nitroproject.org ). Nitro has been around at least as long as Rails and is perhaps a bit closer in philosophy to Django than it is to Rails.
Ruby has reached that "critical mass" where it would be useful to learn it either way you go.
Another vote for Ruby. My local usergroup has some converts from Perl who are really enjoying Ruby. It also has some Python people who have really enjoyed working with it.
I haven't dabbled with Python at all, but Ruby has been fun for me.
If you have an application such as linking to existing C++ class libraries (this came up for me last week) or need to go live next week with 20 million users and need to count every extraneous OS 'access()' call to reduce bottlenecks - Python is the clear winner. If you want to quickly write elegant and highly structured classes and have heart palpitations over people mixing SQL and Javascript with server code, Rails is the winner. While there are always exceptions, I think this highlights the two stylistic camps in a slightly exaggerated way. I probably lean towards the Python camp - but then nobody is paying me to do either; which would change the equation.
So do you have an application for what you hope to achieve in learning this new language, or is it just learning a new language for the sake of learning a new language?
If that's the case, I would highly recommend learning Chinese...
Well I didn't read all the other comments so this may have been stated. The fact is everyone thinks differently and Python will appeal to some and Ruby others. So why not both? There is nothing that says you can only learn one more language. Learn one to a point and then learn the other. After you have a taste for both, pick.
@Brandon Corfman
"I have to correct some misinformation here ... you didn't delve into Python completely ... mixins and closures are part of the language. Blocks are the only things you mentioned that aren't part of Python."
Brandon, you really shouldn't start off with "you didn't delve into Python completely". It simply shows your ignorance to make a statement like that. I programmed professionally with Python for over 3 years, at a development job, not a sysadmin job. My job all day long was to dig into Python. So your statement is entirely inaccurate on that count.
Next, I didn't mention closures as something Ruby has but Python doesn't. However if you really want to get into it, Python's *doesn't* have native support for closures, instead you can emulate it through using default values to an inner function. Some hard core Pythonista's insist that is "true" closure support, but compared to a language that truly has native support for closures like Lisp or Ruby, it's very inelegant.
Finally, Python does not support Mixins. There are ways you can hack around and learn from this technique, but it's not a feature of Python. See this article: http://www.linuxjournal.com/article/4540
"mix-ins are not a distinct technical feature of Python". Now on to the more important point with regard to Mixins, while you can approximate this behavior in Python, it requires language trickery that is the antithesis of what Python is about. Python isn't about doing clever tricks like this to approximate what another language is doing, rather it's about solving problems simply and elegantly within the language you are provided. Python isn't about making it more like another programming language, if you want those type of features, you really should use a language that not only supports them but embraces those ideals as first class citizens and supports them outright instead of trying to force a language to do what it's not designed to do.
Python is a great language, there are a large number of problems and projects that I would use it for over Ruby and vice versa. If you plan to be a craftsman you have to learn what each tool is *designed* to be used for, and use it for that purpose.
I vote Ruby, though I'd recommend that you dabble with both for a while first. Some people claim the Python and Ruby are so similar that one of them is redundant - however those people likely have not tried both of them out for a small project. They both seem to engender a different mindset that's not so easily explained. Personally, I find that Ruby fits my brain better.
I also tend to think that Ruby has more momentum at this point. Recently we started a new project at work and we were fortunate to be able to choose our language. Of the 8 developers only one wanted to go with Python while another 5 were enthusiastic about trying Ruby (of the remaining two, one had a slight bias against Python and the other was interested in using Haskell or Erlang).
I vote for Python, which is a cool language, but, much more importantly, the development process of the language itself is a thing of beauty and a long term source of strength. The evolution of the language is guided by Guido, who is pragmatically brilliant, and is contributed to by a large number of extremely smart and thoughtful people; but somehow the development of Python is much more than the sum of its impressive parts. It is like an acorn on its way to becoming a mighty oak; it will not be destroyed by passing storms, strong though they may be, and it will express itself fully as an organic tree with important branches reaching into the future and supporting whole communities.
There may be a few knots and whorls, but they highlight the dignity of the tree.
I would recommend you to learn both Python and Ruby. You do not need to learn them extensively, but a langage is really a matter of taste, so test it and enjoy the one with the better taste for you.
Chicks prefer Ruby programmers. But Python programmers get all the money. If you use Perl you'll loose your hair but you'll get a lot of facial pilosity. And Java is boring.
Oh my, that was a very interesting debate. Like Loïc said, learn both languages and don't bother asking the partisans which one is the better.
Now if someone wants to debate what is the BEST EVER text editor, that's an interesting question ! And the Amiga was way better than the Atari, this goes without saying.
The "fib" function in § 2.5 (pg 13) of Dive Into Python doesn't calculate fibonacci numbers, for sure. Wonder what else "fib" would stand for.
I'd say definitely python. No offense intended to Ruby but Guido is a world class language designer and his work is *elegant*. Rails itself is elegant but I never feel comfortable with the Ruby syntax. The other thing is its well known that Ruby books sell well but what's less known is Python books sell poorly and always have. Now both languages are rich, deep and complex. And both languages are in wide use so you have to ask why.
People don't spend money easily anymore and programming books aren't cheap at all. So I'd argue that Python programmers, for whatever reason, don't need to buy books. And that argues heavily for:
* Python being easier to learn
* Python "feeling" more natural
One caveat to Python is that the indenting model -- which sounds wonderful -- basically means that its pretty much impossible to easily copy and paste code from the net into an editor and have it work. White space always gets mangled and that means code won't work since white space is part of the semantics.
It really does come down to what will help you professionally and how your brain works. The reason I didn't like Ruby was precisely because it struck me as object-oriented perl, and I never liked perl, but if you know perl, that might be a plus. From a real developer point of view, python and ruby play in the same space, and represent similar approaches to the programming problem. My guess is that ruby has more momentum right now, but that changes day to day. For a more analytic approach to Python (if your brain works that way) I would suggest the OReilly book.
@Doug,
I referenced both you and Blake together in my comment about closures and mixins for the sake of expediency. Didn't mean to attribute my comment about closures to you.
Mixins as a result of multiple inheritance are still mixins. Ruby's ability to do module includes to implement mixins is nice, but not essential to the definition. I've used mixins in wxPython, for instance. Even the article you referenced talks about mixins in C++, which doesn't even have dynamic loading.
Personally, I couldn't get *into* Ruby when I tried a while back, even though I came from a strong Perl background.
Python on the other hand, and Django especially, is just awesome and something I would recommend highly.
I'm still using CakePHP for projects but once I'm more comfortable with Django it will most certainly be something I'd use commercially.
I'd say look at each of these links for five minutes each:
http://www.python.org/doc/current/lib/lib.html
http://www.ruby-doc.org/stdlib/
That's what you'll be using to solve *your* problems, so pick the one that fits. You'll enjoy both languages, so if you have time, learn both of them enough to be dangerous.
Personally, Python led me to think of all things as lists, and Ruby led me to think in blocks and closures, a really foreign idea coming from PHP. Learning Ruby also made me go back and take a hard look at the capabilities of Javascript :)
If you'd like an overview of Python in action, you might like our growing collection of Python screencasts, we have 50 videos right now (mostly for Python, some for Java and others):
http://ShowMeDo.com
We cover starting with Python, GUI programming with wxPython, IDEs (Wing, PyDev, SPE, IPython), Classes, the TurboGears web framework, tools and learning environments. Our videos come from our users and ourselves, and we want to encourage people to share their knowledge.
We'd love to cover Ruby (and, well, everything...given time) but don't yet have any videos - would anyone like to make some?
FWIW we both use and love Python, and we've used TurboGears for ShowMeDo :-)
I've been coding professionally for a little over a decade, and most of that time it has been in perl. A few years back I picked up ruby and python. I stuck with perl.. then tried python again. I've found that Python is, for me the best of the three though not without its faults, just overall the best blend.
I now code professionally in python, for personal satisfaction, and as well as the income, python jobs are worth more than perl coding jobs, that's just what I've learned personally living in a major metropolitan area.
-eric
Someone commented about how the choice between Python and Ruby is probably a matter of how your brain works. I second that heartily. I have a hunch you will take a liking to just one of these (though you will make a pragmatic decision too, which may not be the same). So yeah, try 'em both, and flip a coin to get started!
I use Ruby myself, and haven't coded enough in Python to make a comparison. I will just say that coding in Ruby makes me happy. It is not just the pleasures of a high level language, but also the functional touches, the neat syntax without limiting what I can do, the ease of modiying/extending the language kernel in a readable fashion, and the elegant syntax for using closures.
Good luck!
Let me stir the pot a little here. You should learn Tcl next, so you can start playing with AOLserver. Then, maybe you can get some more Yahoo! folks to use it ... and ... and ... :-)
Tcl may not be "sexy" like Ruby or Python, though.
Ease of learning shouldn't even be an issue, because neither Python nor Ruby is particularly hard to learn. However, I do think Ruby is easier to approach because, in stark contrast to Python, Ruby is very consistent (thanks to the so-called "principle of least surprise").
Personally, I think Ruby is much more fun to _use_, so that's what I'd recommend. Ruby is also much more elegant and, dare I say it, beautiful. You won't know which you'll prefer until you've learnt both, though.
Jeremy, first off - Thanks for "High Performance MySQL" that has been of great use!
The debate here has been surprisingly polite and open minded. Kudos to all commenters for not falling into the mud and muck.
I work with Perl and Ruby every day as well as support some inherited (somebody else wrote it, I get to maintain it) python code. Two of my employees actually handle the python stuff, but I do have to grok it and be able to assist them in their work. In grok'ing it, I've read a lot and written just a little. Both of my employees who work on the python code (both have written Ruby code as well) both seem to like Ruby better, aka they have both asked: "can we just port it all of this to Ruby?"
As many of the other folks have said, Ruby and Python both give you several similar advantages over Perl. I, personally, really like the feel of Ruby code and after having written Perl for 10 years with intersperced encounters with C/C++, Java, and TCL, it seems, as they say, "fun". I feel like I'm working on my problem at hand and not against the language.
It is true that Ruby's extended library, ala CPAN, is not as mature as Python's, but it is growing very quickly. As to the person who complained about REXML, there are many different XML libs that you can use depending on what you wish to accomplish and I do use different ones depending on what I want to do.
This whole thread has made me think that I really should go write some more Python code so that I can understand it at a deeper level, but I'm working on Erlang right now and can't do a detour. Python will be next in the queue.
If you want to write code thats similar to your Perl code, but quicker, with less effort, and more maintainability, I would recommend Ruby. If you want to stretch your brain in a usable way (not Intercal(http://www.muppetlabs.com/~breadbox/intercal/) or Brainfuck(http://www.muppetlabs.com/~breadbox/bf/) ) check out Erland. Language support for concurrent/distributed programming is at its base. I'm thinking that once I grok it well enough, I'm going to start working on a project to bring that brings that to Ruby.
Would love to hear what you come up with after all this commentary.
cheers!
I already knew Python, bu I was highly motivated to learn Ruby. I read all the tutorials, bought all the books and read almost all of them.
But the difference in maturity was a deal breaker for me, so I still use Python exclusively, even though I know a lot of Ruby.
That might change of course, but for a dynamic language made with fast paced developers in mind, it is taking too long. I can't afford to have all my projects fall apart with evey new point release of one of one of ten libraries.
Sorry for a late reply and rehashing the same points.
First off, it's refreshing to see such a civilized discussion on this topic.
I don't know if this helps, as it's my purely subjective experience. I'm originally a front-end "web designer" who decided to expand his skills and become more flexible in implementing custom dynamic/interactive sites and web apps. This was a few years ago and I started with PHP & JavaScript (beyond copy-and-pasting horrbile little scripts off the Net), at the same time getting into general CS concepts and development best practices.
About two years ago, I discovered Ruby and found it to be a whole new world. Doing OOP was a joy and the compact syntax was a welcome break from the C-style verbosity of PHP and JavaScript. I found it very easy to get into and eventually grasp on a more advanced level. Two months ago, I started learning Python, just for the fun of it and because I was impressed by the existing libraries which, amongst other things, promised to enable me doing various helpful non-web related tasks as well. Getting into Python is a piece of cake. For the record, the whitespace issue never was an issue at all for me, maybe I'm stupid but I really don't understand the big drama being made about it. As I progessed, an interesting thing happened: In the back of my mind I always related and compared Python's language features and philosophy to Ruby's equivalents and I realised that there were things that bothered me in Ruby (which I hadn't consciously noticed before) and that made more sense to me in Python. I guess it comes down to the "personal taste / fitting your brain" subject. For me, the One Way To Do It / "expicit over implicit" matter fits better than Ruby's flexibility and magic. Sure, you need to adapt your thinking a bit but in the end, I can't find anything that would place Ruby above Python. You can nitpick single features, idioms and implementation details to death, but in the end you need to produce the results you desire in as little time as possible and have something maintainable on the long run. Python's OOP works differently but it is not "tacked on" and has imposed no limitations for me. The syntax differences are something any programmer with a bit of experience should get around without difficulty.
I still love Ruby and still prefer and recommend it over other languages I've looked into since and before. But Python, although it does have a few well-known issues too, has more going for it. Sorry about this lengthy piece; what I'm trying to say is, perhaps start learning Ruby and *then* Python. For myself, at least, I can say that in retrospect that order was more fruitful than if I'd done it the other way around. If Ruby fits *your* brain better, of course, you'll find that out soon enough.
Python.
- Has more supports
- The inventor is employed by a company that uses the language heavily, in the long run we might see vast improvements (since he's paid to work on the language)
- Wide range of implementation from GUI, Network, WWW and a little bit of CG
Well in short Python is more mature compare to Ruby. Others might say developing time in Ruby is much faster but all I heard everyday is RoR not Ruby specifically. Besides, it doesn't matter much between Rails vs Django if the programmers are good.
Some people dislike Python because it enforces the indentation rule (I disliked it too first time I heard about it). But after I read an article written by Ken Arnold (http://www.artima.com/weblogs/viewpost.jsp?thread=74230), my view changed.
I've been weighing the same decision for a while now, and originally decided on Ruby because it was sexy. I started learning it and had fun, but found that the educational and support resources were not as plentiful. It hit me as having great potential, and wonderful consistency, but not right for what I'm doing.
Started learning Python and have been very happy. Great educational resources: Dive Into Python, Think Like a Computer Scientist, Python411, Guido's tutorial, great help file, friendly community, etc. Put together a program to analyze categorical syllogisms with a minimum of trouble. (Got bit by the indentation thing once or twice.) I'm pressing on with Python.
Keith
My short form (having used both fairly extensively):
Ruby is a better LANGUAGE.
Python has better LIBRARIES.
Both of these are an enormously big deal. If I was writing something from scratch, I would choose Ruby in a heartbeat--but you don't write anything from scratch. So depending on the work you're going to do, that can make a huge difference. For example, right now I'm throwing together a lot of small scientific programming scripts. I looked around for any way I could do this in Ruby. Then I found PyVtk, SciPy, Matplotlib, and friends, and wrote it in Python. I also have a need for a small data-driven web app, and I'm doing that in rails.
But overall, I'd have to agree that the Python libraries out there TEND TO BE better developed, better supported, and better documented. And that can be a huge, huge deal.
So again: Ruby is the better language, but Python has the better libraries. Can't go too far wrong with either.
If I truly could only learn one, I'd go with Python for the libraries and for its popularity, but I'd be missing a lot to have never seen Ruby...
In my opinion, Ruby was much easier to start. I started programming Ruby with no knowlede of programming whatsoever, and it was very simple and easy to use, it was basically just write out the coding in a text document, save it in the ruby format then open it with a command prompt, and it didn't have to be compiled or anything. I learned how to do all of that right away. Then this morning I tried learning Python, it was pretty simple, but I had no idea how to even run the program.
Basically, having that said, Ruby was very simple, and from what my cousin told me, it was very quick and easy starting with Ruby after using Java and C++ his entire life. But then again, Python is also pretty much straight forward and you could start writing full programs within a week. If I were you, I would try each out and stick with the one that just seems easier and more efficient. Good luck and hopefully your decision ends up being a good choice.
This is a tough decision. Either way, YOU will come out on top. It's just that Python seems sooooo versatile, has an amazing user community, and is used in practically every industry on the planet. Take a look at "Python Success Stories" over at Python.org. Remarkable!
I was going to recommend Ruby. Having been an ex-Perl guy that did a bit of Python and then switched to Ruby, I was going to talk about how expressive the language is, about how it has everything you like about Perl but with far fewer of the warts, but that Python is a fine language as well, etc., etc.
After reading the existing comments, however, I'm going to throw my hat in with the folks that say that neither one is different enough to really change your world. You say that your goal is to "add a new tool to your collection". I realized that Ruby has been a replacement for Perl for me, not an additional tool. The only Perl I've done since learning Ruby has been to maintain old code that I've written, or occasionally to use an obscure CPAN module that has no Ruby equivalent. It was the same way when I was hacking Python. All three languages have basically the same domain.
Consider learning something that will change the way that you think about programming. Haskell or O'Caml, perhaps, or even Common Lisp or a modern Scheme. Erlang, maybe. They may seem impractical, but in truth, you'll only be getting an incremental _practical_ value out of learning Ruby or Python in addition to Perl. In the long- or even medium-term, changing the way you think is probably worth more than moving a little syntax around.
If you must have something "practical", then maybe look at Scala or Nice, as they run on the JVM. Neither seem as inherently appealing, though, as the options mentioned above.
(Disclaimer: I know none of these languages.)
Cheers!
-- Orion
PYTHON
PYTHON
PYTHON
That's all I can say.
Do you know what I'm doing now before finding this page, JUST SEARCHING WHICH IS THE BEST LANGUAGE TO LEARN.
I have seen the popularity rankings, it's JAVA, nothing can beat that, of course. But transition is taking place, JAVA, in the near future can fall down on the popularity rankings and that's for sure.
C, C++ are cool, but the scripting languages like PHP, PERL, PYTHON, RUBY are growing.
Best of them, is best of PYTHON, RUBY. Choosing from the two is really difficult.
I GO WITH ONE THING
BETTER LANGUAGE : RUBY is the winner
BETTER LIBRARIES, SUPPORT, RESOURCES : PYTHON is the winner
And what about C#, If you want to develop really coooool applications for WINDOWS , just for WINDOWS, then I recommend learning C#, NOTHING CAN BEAT THAT IN ALL DOTNET LANGUAGES.
Are you a web developer,
LAMP LAMP LAMP LAMP
L : LINUX
A : APACHE
M : MySql
P : PHP
That's all I can say, if you want to make your own website, then follow LAMP.
I have only Started learning Python (coming from a Perl, PHP, Java background). But I was in the same boat.. Python or Ruby. What sold me on Python...
IronPython.
The main reason that IronPython sold me was that I work in an environment that is heavy into .NET. Now Granted, MS does not have all the tools up to date as of this writing.
From my POV the logic was simple:
Learning Python and I can use it for .NET or on *nix with some subtle changes. Basically, 2 Platforms for the price of one.
Anyway I dig Python, and the community that it has... More than likely once I get my feet good and wet with Python I will move on to Ruby. But for getting the most bang for my buck to begin with, I would have to say Python...
Regarding the "slow" library development for Ruby (the libs are called "gems"), I might argue that the ease with which one could roll their own solution in Ruby might make gem development naturally slow. Personally, having spent months working on a public Internet site, I didn't find any glaring deficiencies that I couldn't find a solution for.
Python people look at ruby's symbols (a nice language feature, btw) and get turned off by colons? You do know that once you get used to looking at them as symbols (which is quickly), the colons "disappear", right? And if you use the right editor ::cough:: TextMate ::cough::, it gets syntax-highlit anyway.
I know it's subjective but I didn't dig neither the whole "every other word is 'self'" thing in Python nor the significant whitespace. The fact that Ruby is a completely functional language (as in "everything returns a value") I found very satisfying.
And lastly, there's the whole "Python only lets you do things one way" philosophy. As a final example, an excerpt from a terminal session:
maxwell:~ jacquelinestriano$ python
Python 2.3.5 (#1, Jan 13 2006, 20:13:11)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit
'Use Ctrl-D (i.e. EOF) to exit.'
>>> quit
'Use Ctrl-D (i.e. EOF) to exit.'
>>> wtf asshole
File "", line 1
wtf asshole
^
SyntaxError: invalid syntax
>>>
Indeed.
So basically, it KNEW I wanted to leave the interpreter, because it recognized both "quit" and "exit", but it STILL insisted I use ctrl-D. And with that attitude towards the programmer, I blew Python off. ;)
Peter: nice one! People can wax lyrical about features in their favourite language, but often it's the little things that annoy us!
Don't learn both, or one.. use that precious time you have to expand your mind - learn lisp, scheme, or smalltalk (not ruby).
Lisp for what an industrial behemoth of a language can do with little work;
Scheme for sanitised version of Lisp that provides a cleaner outlook
Smalltalk for horizons it will broaden when you realise that working in an encapsulated environment (i.e. the smalltalk image) has a lot of good aspects.
I don't favour any of the languages, but they each added something (sometimes obvious, sometimes not) to my knowledge. Won't these things make you a better perl, or python or ruby or javascript thinker/programmer?
:-)
Baked.
I've programmed in dozens of languages and had extensive experience with object oriented systems, starting with my work on CLU in the 70's while I was a student at MIT. Play around with Smalltalk, Haskell, Scheme, Prolog, and the R project. Each of these will broaden your understanding and appreciation of programming languages in general. I think Perl is a great example of a scripting language -- you've already got that under your belt. The languages that I've mentioned all have a kind of single mindedness and purety that make them easy to appreciate and each is a fantastic tool for a certain kind of problem.
If Python didn't exist, I'd be a Ruby programmer. Its a great language. Blocks, tighter integration of RE's, symbols, RonR -- Ruby has a lot going for it, but I think Python is just a bit better. Metaprogramming, like operator overloading in C++, has it's place, but too much of it results in hard to maintain programs. So I don't see Ruby's more extensive use of it as a big plus. While on the other hand, a key part of almost any program is iteration. Constructing and understanding why loops in one's programs are correct is absolutely essential to writing software. Ruby's looping constructs are, to me, harder to reason about than Python's. Mentally, constructing the loop invarients and terminating conditions to really understand the loop is harder when every loop is an iterator being fed a block.
Python's emphasis on short, straightforward solutions makes for maintainable systems. List comprehensions, for example, are very efficient, very short, and very easy to understand. Python programs can manipulate data with map and filter like Ruby does, but it's more pythonic to simply use a straightforward list comprehension -- shorter, faster, and easier to read.
I didn't want to rely on whitespace to indicate nesting when I started out in Python, but now I much prefer it to using end, end, end, etc. and trying to figure out which one goes with which iterator. Yaml, widely used in Ruby projects, depends upon whitespace so I think it's a bit disingenuous to complain about using whitespace to indicate nesting. Python has warts, but so does Ruby: strange precedence (a or b and c) means something different than (a || b && c); do...end doesn't always mean the same as { ... }; synonyms for common method names (e.g. map == collect, etc.). Ruby seems to embrace the Perl mantra of "there's more than one way to do it". I prefer the "there's an obvious way to do it" slogan of Python.
I frequently see comments suggesting that Ruby is more Lisp-like or more object-oriented and hence better. I don't really see it that way. Ruby definitely isn't Lisp -- programming in it really feels different than programming in Lisp. That's not bad. Ruby's great on it's own and doesn't need to be Lisp or Smalltalk. Programming in either Python or Ruby is fun. Python has IronPython, Jython, Pypy, the Twisted framework, list comprehensions, generators, and a great and creative community of users. Ruby has it's own, different strengths. You really can't lose in choosing between the two.
Finally, don't become an advocate for one without really understanding the other.
I am in the same situation: I need to decide what to learn next: Ruby or Python. I decided to go with Python for its library support and because the book "Dive Into Python" is freely available. I already read the first 2 chapters and found the book very useful.
I want to thank all the people that contributed to this thread. The information presented here is very relevant for the subject in question and not only that, but everybody was polite and on the subject. It is great that such places do exist on the Internet: many people benefit from this, not only the thread started - "jzawodn".
Regards,
Razvan M.
Hey!
I read all of those comments... Why dont you just take the time to learn both. That way you will have mastered 2 new languages and you can answer your question for yourself.
Hi Jeremy,
Would you mind to analyze those comments and update teh post with the results? I've just read maybe 20% of those an I would say that the score is:
50% Python
30% Ruby
20% Learn both or no opinion
Wow, opinionated bunch — this page is a mile long.
I'll defer my personal opinion, suffice it to say that both languages rock and both sometimes suck, and a mile-long thread of opinions doesn't amount to shite in the face of a good year in the trenches.
I would like to point out that Ruby's efficacy isn't solely hinged to Rails (as some have suggested). Ruby spent years gaining significant popularity in Japan without the help of Rails before anyone bothered to document it in English (thanks pragprogs). Rails just happens to be that immensely popular application that came about shortly after the Ruby craze hit our shores. And what with the Web turning 2.0...
Anyway, from what I've read about Ruby 1.9/2.0 and Python 3000, the languages seem to be merging. They'd never admit it, but each is adopting some of the other's strengths in measured doses.
Which begs the question, which of you brave developers is working on Rupy? Pyrub? How about ErLisPyRubCamKel?
Languages are fun. Learn them all. At the same time. You'll probably never get a thing done, but you'll be able to talk some serious shop.
Jeremy, I see you posted this a year+ ago. Did you learn RoR? Do you have any comments and suggestions? Any regrets? ;)
I also want to thank everybody for the very civil helpful discussion. I am a Java programmer needing to add a core language to my arsenal to replace Java and this discussion has been very wise and helpful.
Very interesting discussion and very civilized.
I do most of my programming in S and R, and know some commond lisp and elisp. I was thinking about learning a scripting language so found this very helpful.
regards
Hey Jeremy!
we want your conclusions !!!
Write what you think about this two years later.
Thank you for this great discussion! It looks like Ruby has a good syntax and Python has well developed libraries. But the question is about the future. What do you recommend for a tomorrow, Python, Ruby, F# or something else? Thanks in advance.
It looks like you guys never mention "deployment."
There are many stable web hosting, even free, for PHP, Java. Not for Ruby until JRuby and its 'war' deploument.
What about Python?
DO i miss anything?
Hello Jeremy,
Good choice with python. I'm also into python, and I like it a look!
Good luck learning!
Having good support/resources is the key in choosing a language and work with it for a long term. I was comparing Ruby and Python and decided to go with Python for better libraries and supports.
Right now, I'm leaning over Python comparing to past experience with Perl. I also doing some GTK+ app with Python using PyGTK along with C & GTK+.
Well, here's how it works. I'm not biased by the way. Here are the facts.
Python:
Simple
Easy
Powerful
Straight-Forward
Great for coding with multiple programmers
Ruby:
Powerful
Versatile
Useful
More possibilities
Here's a metaphor to go with that:
python is like an a racing arrow, straight, powerful, silent and deadly
ruby is like a whip, it's powerful, it's like many weapons in one, it can be tricky to use though
So that is to say, they are equivalent, but different at the same time. They are both very good though.
Ruby and Python are both great languages. I would prefer Ruby over Python for one thing I hate in Python - "Indentation detects programming constructs". A space here and there interpreter starts cribbing. If you are coming from Perl background I definitely suggest Ruby over Python.
Interactive Programming Books make learning new programming language very easy. Readers can execute or edit code snippets straight out of the book. You can try free interactive programming books on both Ruby and Python at http://roorky.com. IPUBReader comes with free bundled programming books on both Ruby and Python.
Thanks
-- PK
I have used Python for 6 years now and I am looking forward to the changes in Python 3--and I'll still use for a lot of things when I don't want to use C++?Obj-C. But I am moving a lot of future work to Ruby. Why? MacRuby. Unlike Python which still uses the poorly implemented and documented Cocoa Bridge for Cocoa programming on my favorite UNIX OS X, MacRuby is compiled straight to Objective-C so voila--no more painful errors, Objective-C hacked Python or Ruby and no more errors and omissions in the Bridge biting my code. As much as I really don't want to learn yet another similar language to Python and the detestable Perl I am doing it.
If you are a System Admin type I would go w/ Python. Not for any real programming reasons, but Python is much more popular in that community. I've seen Ruby fall on it's face a few times for some serious data crunching and I went w/ Perl for a few scripts. But only very last resort.
If you just want to learn a new language or do Web stuff than use Ruby. Python's classes and OO is weak at best. Ruby on Rails is a fun Env for web dev and if you know Ruby you well on your way. It's OO is much better and mixins are great.
Either way, forget about Perl. I was a Perl developer for 10+ years and swore by it. Never use it again unless I have to. I use Ruby and Python now.
I'm a c developer by trade, c++ developer by profession an
do scripts on the side. The way I see it the more you code the more you start appreciating the nuances between languages. I for one, like to collect Ruby snippets because the are so darn KOOL! 2.times do p "Ruby is KOOL" end