Programblings

Rambling about programming and life as a programmer

Do not learn Ruby

Posted by webmat on February 20, 2008

Update: This article has has a new home on programblings.com. Go to the article.
Comments are closed here but still open there :-)

Ruby will get under your skin. You will miss its features and quirks when you’re not using it. You might even find other languages insufferable, once you get comfortable with Ruby.

After you’ve started using Ruby, there’s a significant chance you’ll start loathing whatever code base you currently have to work on. Especially if it’s a statically compiled language. A code base you used to think was ok, except for its few quirks.

After a while of perusing the different Ruby-related blogs, you’ll have heard other Rubyists speak of their work with words like beauty, productivity, expressiveness, conciseness, fun and you’ll realize just how far your current language is taking you from all of these words.

You’ll see

Dictionary<string, string> someDic = new Dictionary<string, string>();

And dream of

some_dic = {}

You’ll see multiple declarations for the same method, trying to emulate optional parameters and think of Ruby’s symbols and options hashes, where such a simple method as:

def method_with_options(options = {})
encoding = options[:encoding] || 'utf-8'
puts('Other option detected') if options[:other_option]
#...
end

Enables all of the following uses

method_with_options :encoding => 'utf-16', :other_option => true
method_with_options :encoding => 'utf-16'
method_with_options :other_option => true
method_with_options

You’ll hear about metaprogramming and the complex syntax or frameworks that can bend Java, C# or C++ to allow a programmer to achieve what he seeks.

In the back of your head, you’ll think of the insane flexibility allowed by

– simple Ruby syntax for method chaining or redefinition;

– dynamic class definition, that lets you add methods to any existing class, even Ruby’s core classes;

– duck typing, where objects of any type can be passed to a method, as long as it responds to the expected method calls in a reasonable fashion;

and oh so many other Ruby niceties.

You’ll encounter twisted method definitions such as

bool SomeMethod(int param1, ref SomeClass someClass, out SomeEnum resultType, out string result)

and think of Ruby’s multiple returns that allows you to clearly define what’s a return value and what’s a parameter:

success, resultType, result = some_method(param1, someClass)

You’ll delve into huge, puzzling class hierarchies that struggle just to use the right abstraction level for class names… You’ll eventually realize that the whole hierarchy was simply there to share a few methods among loosely similar classes.

Then you’ll really get irritated at all the accidental complexity that could have been avoided by simply using mixins, where you define a common method and then include it in any appropriate class. And all of this without ever puzzling over strange abstract names for classes that happen to sit between 2 clear-cut levels of abstraction.

You’ll want to explore a new part of the .Net API by playing with it. You’ll create a dummy project in some random directory, find a name for it, include the proper parts of the API in the generic main class created by default and finally start playing with the construct of interest.

All this time you’ll be thinking of IRB, the Ruby interactive console. It not only allows you to play with an existing API with absolutely no fuss, but thanks to Ruby’s flexibility, you can even define classes in the console and then play with them!

But then you’ll think “Oh yeah, IRB is in fact so flexible that I can use if from a frickin’ web page (with a tutorial)!” And you’ll go play there for a couple minutes (when no one’s looking), just to keep you sane for a couple more hours. Until the C++ / C# / Java drudgery is over for the day.

You’ve been warned. If you learn Ruby, you’ll start thinking it’s impossible for you to keep using the technology you’re currently using at work. If you’re patient you’ll try to introduce it there gently (and most likely get frustrated at the time it takes). If you’re not so patient, you’ll just end up changing job.

Next monday I’m joining the great team at Karabunga to work on Defensio. I’ll be doing Ruby and a bit of Rails. Liberation is coming :-)

54 Responses to “Do not learn Ruby”

  1. Congratulations on your new gig!

  2. webmat said

    Thanks for your thought :-)

  3. que0x said

    got your point !, could you please explain advantage of learning ruby over python?
    python already have a huge library from web to Academia , while Ruby looks focusing on web stuff if i may tell ! what do you think ?

  4. @que0x I say you should learn both. period. no reason to learn just 1.

  5. Que0x: I think it’s more a question of personal taste. I personally find the Ruby syntax much more elegant and easier than Python. Feature-wise, I’d say they’re roughly equivalent, though.

  6. Stijn said

    QueOx, I suggest you play it fair: spend a day (or evening) exploring Python and do the same with Ruby.
    But on the other hand (SPOILER AHEAD!), instead of wasting your time, you can just forget Python and learn Ruby, because that ‘s what you ‘ll end up with anyway ;-)

  7. Chris said

    I’m going to assume your comment isn’t just trolling and answer my perspective honestly (and to be clear, I’m just a developer and not the author of this original post).

    Ruby isn’t “focused on web stuff” by any means – I think you’re confusing Ruby the language with Rails the wildly popular framework built in Ruby. In fact most pre-Rails Ruby developers would probably get a chuckle from thinking that Ruby is a “web language” ala PHP. Since learning Ruby I’ve amassed a moderate collection of command-line Ruby scripts I use on a day-to-day basis that have absolutely nothing to do with the web.

    I’ve now used Ruby far more than I’ve used Python simply because I enjoy Ruby’s syntax more, Rails is built in it and I genuinely like the community around it (which is not to imply that Python’s community isn’t just as likable, I just don’t know). In my mind there’s no concrete “advantage” to learning Ruby over Python, any “advantage” will largely be subjective and personal. Rather think of it as “its great to learn a dynamic language that exposes you to concepts not commonly found in statically-typed or pure-OOP languages”, pick one, dive in and learn it. Lots of intelligent, productive people are writing wildly cool code in Python as well, I’m sure.

    Don’t get caught up in the language, get caught up in the learning.

    Cheers
    Chris

  8. bewhite said

    You are right. Once I have tried Ruby I just can’t feel comfortable while using languages like PHP or Java. I have changed my job and now I’m happy :)

  9. Reedo said

    Oh, please tell me I won’t end up like the bitter old Lisp users, continually saying “But this new problem is easily solved by this technology over here! Really! Am I the only one who sees that every other technology is slowly approaching this one?! I feel like I’m taking crazy pills!”…

  10. ATSkyWalker said

    I think you’ve managed to explain the a few pros of Ruby in contrast to languages like java but didn’t get much into what you lose!

    Granted, Ruby is much more concise and java is much more verbose, but although

    Dictionary someDic = new Dictionary();
    is kind of ugle compared to

    some_dic = {}

    Java’s syntax (although can benefit from some simplification) still expresses much more about the intent of the programer. You immediately know what kind of objects are being stored in this Dictionary and can make some safe decisions as to how to manipulate it. You can also choose to use its agnostic manifestation :

    Dictionary x = new Dictionary() which will behave more or less the same as its Ruby counterpart, etc….

    On the other hand, you can never tell anything about what kind stuff this dictionary would hold at runtime in the Ruby world, and don’t get me started on “Duck Typing” because while its nifty for little scripts, it does not scale when 10+ people are working with the same code base!

    Also, optional parameters are possible in Java either through a similar contraption to Ruby’s hashtables (minus the symbol support), or through varargs!

    Don’t get me wrong, Ruby is great. I use it every day, and I also use Java daily. Each language has its place, purpose, pros, and cons.

    You also have to keep Groovy in mind, because if Java programmers are going to seek beauty and brevity in a dynamic language its gonna be Groovy not Ruby because of ease of entry into it and its support for both typed and untyped syntax!

  11. ATSkyWalker said

    The first java snippet in my first post should read:

    Dictionary someDic = new Dictionary();

  12. Lorenzo E. Danielsson said

    Agree fully that after getting used to Ruby, many other languages seem overly complex. I do have a few other addictions however, such as Haskell. I’m toying around a bit with Scala at the moment, but haven’t made up my mind if I love it or hate it yet.

  13. Andrey Shchekin said

    May be I am just too used to Perl and JS, but what’s so new in {} and dynamic redefinition?
    The problem with everything except ‘{}’ is that dynamic means ‘no Intellisense and no compile-time checks’.
    Well, if we do not need Intellisense and compile-time checks, what’s the hype — _any_ dynamic language will seem better than C#.

    But I would hate to do any refactoring in a big dynamic project — and automatic refactoring will certainly not be possible.
    While unit-tests help, compilation checks are just so faster and more thorough.

    And optional arguments are available in VB/VB.NET for a very long time, but no one wanted them to C# until everyone saw it in Ruby.

    Now what I agree with are the things I always wanted to see in C#: mixins (traits?) and multiple returns.
    Hopefully they will add them at some point.

    Btw, talking of consoles, Immediate Window is your friend (it even has Intellisense).

  14. foobar said

    I didn’t realize that all developer needed to survive was syntatic sugar.

  15. bbaka said

    But i do not get. If you are in rome do as the roman do. If in Ruby, curly brackets are used in declaring a hash whiles in Java or some language one has to type 5 lines to accomplish that just do that and be free. If you are really into programming i do not think language differences should be a problem. Some languages are better in some respect than others and vice versa. Lets stop rambling about the language and code.

  16. Al Brown said

    python or ruby?

    well, i would rather have jewels on a plane instead of snakes

  17. […] Do not learn Ruby « Programblings […]

  18. webmat said

    @que0x (on Python vs Ruby)
    I’d say if you’re using Python right now, learning Ruby will not be as much of a life-changing experience. Python does have a lot of the same features that Ruby has.

    On one hand, I find Ruby still seems to have the edge on expressiveness and the ease of doing metaprogramming. On the other hand, I’ve heard the Python VM is more mature and stable. But that is changing right now with all the work being done on the different Ruby VM implementations (YARV, Rubinius, JRuby, IRonRuby).

    If you’re not using either however, I agree with Carl and Stijn that both are really worth a look. And give them both a try.

    I totally agree with Chris when he points out that Ruby is not strictly a web language. It’s a general-purpose language like C++, C# and Java. The wildly popular Rails web framework has changed that perception since it came out, however.

  19. webmat said

    @Reedo
    I fully recognize that in a sense, Ruby is just yet another step closer to Lisp, feature-wise (see Paul Graham, “What made Lisp different” http://www.paulgraham.com/diff.html). On the other hand I think Ruby is a better bet right now for employability reasons, for the effervescence of the community and so on.

  20. webmat said

    @ATSKyWalker
    Of course there are tradeoffs in using Ruby. In this article I only wanted to provoke thought. My aim was not to weigh the pros and cons.
    I’d like to point out however that in languages that support generics, such as Java (to an extent), C++ and C#, whenever you use a collection without specifying the type, you are foregoing the very advantage you say your language has! Your version of the Dictionary example does not specify any type, so you can put anything in it and you have no guarantee of what you’ll get out farther down the line :-) I’m not saying it’s bad, I’m just pointing out that this is exactly the same as Ruby (in this example).
    How this is mitigated in the Ruby (or Python) world is a whole other topic (debate) in itself, so I won’t get into that here (Andrey Shchekin does at comment 13, though). Might as well make it a full-blown post eventually.
    I’m curious about Groovy. I’m keeping an eye out and I just may try it soon. I’m particularly in the optional typing feature you mention…

  21. webmat said

    @Bbaka
    I don’t mind your stance. With Ruby I’ll just deliver features faster than you ;-)

  22. […] Do Not Learn Ruby (webmat) […]

  23. […] Do not learn Ruby Posted in Ruby. […]

  24. she said

    woot i can join the praise
    ruby is my main language since 4 years.
    i dont regret it, although i am one of the few who says that ruby as a language is quite complex (unifies many paradigms)
    its no longer a problem for me, i pick what i like and dont use the rest (i.e. i never use @@class_vars and I hardly use private declarations)

    however there are still a few legit uses for other languages:

    – A faster language to combine with Ruby. I am still undecided whether I will use C or C#. Right now I tend to C because of all the legacy code in C.
    – Some concepts in other languages are very useful, for Example the Io language has good introspection. Ruby needs this!
    Also, the feature i miss most is keyword arguments. I often write very long methods (many arguments) but I also dont want to be forced to use a hash just to address keys at a later position.

    By the way to the guys praising Groovy – Groovy sucks. It is the java attempt to keep people in java.

    Even python is a lot better than groovy, and if you need the speed anyway you can go lua. I really dont see ANY reason for groovy except to keep java programmers with the sinking boat that is called java (“sinking” not so far because of the money, there is still a lot of money, but because of what language is GOOD and which language is NOT good.)

  25. rubinelli said

    @Andrey:

    NetBeans does a great job if you want an IDE with auto-completion. As the IronRuby project matures, you’ll probably see Intellisense support in Visual Studio too.

    Also, since Ruby code has much less boilerplate code than C# or Java, you rarely need the kind of multi-hundred-line refactoring operations sometimes needed in these languages.

  26. webmat said

    @rubinelli
    Great points! I didn’t even think of mentioning them. For those interested in seeing Ruby in Visual Studio, take a look at the Sapphire Steel screencast, available at
    http://www.sapphiresteel.com/IronRuby-Visual-Designer

    When I first saw the screencast, I actually posted an article about it: Culture shock

  27. […] são muitas as qualidades da linguagem Ruby. Mas isso tudo tem efeitos colaterais. Por conta disso, este texto do blog Programblings explica porque você não deve aprender […]

  28. commenter said

    Ruby’s nice, but I found that when I tried to program in it I just got buried by runtime errors caused whenever I tried to refactor the code.

  29. debiani386 said

    this blog has killed all desire to program in ruby (no offense). Still my favorite language is BASIC and LSL. C/C++ comes in 3rd

  30. Antoine said

    Hey!

    Ruby may be awesome, but don’t lump all static languages in with C++/Java/C#.

    OCaml and Haskell lack much of the noted wordiness in your Dict example (but you still have to compile …)

  31. webmat said

    @Antoine
    Good point. Functional languages are on my shortlist of languages I’m keeping an eye on. I can’t wait till I have time to really immerse myself in one or two of them.
    Type inference is one of the features I’m looking forward to experience.

  32. webmat said

    @debiani386
    That was the point, wasn’t it? Quote: “Do not learn Ruby” ;-)

  33. […] Do not learn Ruby Ruby will get under your skin. You will miss its features and quirks when you’re not using it. You might even […] […]

  34. […] [RUBY] Do not learn Ruby, webmat.wordpress.com, via:ruby.reddit.com […]

  35. […] February 23, 2008 Do not learn Ruby: https://webmat.wordpress.com/2008/02/20/do-not-learn-ruby/ […]

  36. Corey said

    Amen to all of this. I quit my job doing C# to join a company doing Rails. I found that, while at work, I was dreaming about being home and working in Ruby. I have one week left before I get to start working there.

  37. webmat said

    @Corey
    Cool! Same adventure about at the same time. Good luck to you :-)

  38. pete said

    “Also, since Ruby code has much less boilerplate code than C# or Java, you rarely need the kind of multi-hundred-line refactoring operations sometimes needed in these languages.”

    LOL — you really don’t have a clue what refactoring is about, do you?

  39. Inferis said

    w00t, it’s like Perl all over, but then 10 years later. :D

  40. webmat said

    *And* readable! ;-)

  41. Joe said

    .NET rules……enough said.

  42. spacebat said

    @webmat:
    I couldn’t resist porting this post to Perl and Python, please forgive the derivation.

  43. Arne D H said

    I absolutely agree that there is stuff that is superior to Java – maybe both Ruby and Python are. It is a shame that people are so frozen in their VB/C/Java syntax patterns as to only accept linguistic clones.

    Smalltalk has a tiny syntax and is wonderful for object oriented development. Ruby is Java crawling slowly toward Smalltalk by adding syntax (But it does have a module system that makes it possible to deliver an app without dragging along every library in the development environment)

    Somebody mentioned the bitter people with a prehistory of Lisp who can tell you that this was solved in a library they used in 73 – but everyone else gets a “deer in the headlights” look when the syntax deviates from their paradigm. Forth, APL/K/J, Prolog, Haskell are probably way superior for a lot of stuff, but people aren’t willing to learn.

  44. webmat said

    @Spacebat
    Haha! Love your posts :-)
    Now I regret not giving examples of Ruby’s flexibility for metaprogramming (aliasing methods, adding methods to existing classes, overriding method_missing and so on). I actually would have liked to see what it looks like in both these languages :-)

  45. ATSkyWalker said

    @She,
    You said “By the way to the guys praising Groovy – Groovy sucks. It is the java attempt to keep people in java.” Can you qualify?

    I don’t wanna get into my language is better than your language kind of discussion, but I’m interested in knowing the reasons behind such grand statement. Maybe you’ve had some bad experiance for which elaboration will help us all out there!

  46. Stii said

    You’ve been copied :P

    http://ubermonkey.net/blog/2008/02/25

  47. […] it started with the article titled Do Not Learn Ruby, after which came a response titled Do Not Learn Perl, and then came Do Not Learn […]

  48. makrtucks said

    Dude, it’s like my life up there in print! I’m finding it extremely difficult to get through the daily drudgery of using Java for everything – no matter that it’s NOT the best tool for all jobs, it’s just that because that’s all they’ve used, that’s all they’ll ever use.

    No matter that the same work can be done a helluva lot faster in ruby or python or [insert language here] “we use Java”. I’m literally starting to resent Java because it’s so long and drawn out to do most things. Don’t get me wrong, it’s great for some stuff (like out performing rails in a web format – don’t shoot me) but I just want to be one of these people that loves their job and loves the language they are using – I want to create beautiful, readable code – I want to be a ruby / rails freelancer :¬(

    It just gets under your skin – so as the article says, don’t learn it, ignorance is indeed bliss.

  49. webmat said

    @makrtucks
    Dude, just take a look at the job boards around where you live ;-)
    Even at my previous job, though, I still used Ruby locally to automate some small tasks I didn’t have to share with coworkers. It might be a temporary way to get relief… And eventually a coworker will see you do something nice with it and say “Wait a minute… Can I have that too?” and it can start from there, if you really want to stay where you are now.

  50. marktucks said

    @Webmat
    Not too many (I’ve actually never seen any) jobs around the South West of England for Ruby or Rails developers, unfortunately :¬( but I know what you’re saying – use Ruby to create little rays of light in an otherwise dull day :¬D

  51. […] Do not learn Ruby « Programblings (tags: ruby programming humor essay) […]

  52. […] absolutely right. :) I recently read a good article to this effect: "Do not learn Ruby" https://webmat.wordpress.com/2008/02/…ot-learn-ruby/. It’s a fun read. Cheers, […]

  53. […] não aprender ruby (veja mais – link em inglês) Esse link mostra um bom motivo para você não aprender a linguagem de programação ruby. Um dos […]

  54. […] you want some inspiration as you continue your path look here at the facetiously named Do not learn Ruby. I’ll keep you updated as I continue to learn […]

Sorry, the comment form is closed at this time.