Tigraine
Daniel Hoelbling talks about programming

My beef with Ruby/Python

June 17th, 2009 . by Daniel Hölbling

I just spent some time poking around Ruby after some poking around Python. And both times I find the typing concept awkward.
Not so much because there is none, but because there is one visible to the trained programmer, implicit but still there.

That being true for primitive types, for classes this makes a whole lot more sense, since we can use the concept of duck typing:

"when I see a bird that walks like a duck and swims like a duck and quacks like a duck, I call that bird a duck."

Some patterns we came to use in static languages are just obsolete in dynamic settings. But the cost to me is that I also have no metadata present about the object I am currently dealing with. It could be anything, and I don’t know before I execute it.  
In C# I can simply hit object. and see all available methods/properties/events, allowing me to look at their documentation and so on. In Ruby, not even the smarter IDEs like RubyMine can do that for you. 

That in itself is no big deal if you are only working with your own classes and methods, where you know how they work or have a general understanding of how they work. Where I really need this metadata is when working with complex frameworks and libraries that expose tons of stuff through protected members from superclasses, that are just invisible to me. That said, to me the whole Ruby/Python experience was more of a running around and hunting method signatures rather than getting something done.

I guess that experience is normal and I am rather sure I’ll get the hang of it rather sooner than later. But coming from years of static typing dynamic languages just feel weird and especially their way of interacting with you as a programmer are different (no Intellisense being my #1 problem with all of them)


  • Chubas

    And not quite true for primitive types (try to guess what type is 2 ** 64. The answer is [Bignum, Integer, Precision, Numeric, Comparable, Object, Kernel])

    Yes, Ruby is quite a different paradigm in some aspects. And you need some experience to get used to it, specially what you say about typing system.

    It also depends on the good programming habits. Most of the good libraries are well documented, and can help IDEs to do its job, but yes, having a perfect Intellisense like in static typed languages is quite a challenge, if not impossible. In Python there is the “”"Inline doc”"” thing, which I find pretty nice. In Ruby, dynamically defined methods (like eval-ing at runtime), singleton methods, method_missing?, etc…, all these things that make Ruby so beautiful are difficult for the current tools to work with, without some help from the programmer. RubyMine does a pretty good job, though.

    But something I like about Ruby in particular is that most programmers apply the SOLID principles when programming, and the language flexibility helps a lot. For example, the Principle of Least Surprise, in which you know that query methods (like Array#contains?) return a pseudo-boolean — I say pseudo because aside from returning true or false, most of the query methods return an object or nil, which act (quack) like boolean for boolean comparison purposes.

    Learning new languages/paradigms is good. You’ll see you won’t miss that feature as much as you think you do.

  • http://www.tigraine.at Daniel Hölbling

    Thanks for the comment.

    Yes I’ve seen those ? and ! conventions and I quite like them. Language flexibility is awesome, but sometimes people tend to use that against their own language in their samples.

    For example one official Python sample looks like this:
    >>> while b < 10:
    … print(b)
    … a, b = b, a+b
    (http://docs.python.org/3.0/tutorial/introduction.html#first-steps-towards-programming)
    It made my head blow up. Sure, the b, a+b would take alone 3 lines in a static language. But does this warrant to write double assignments that also (for me) get executed rather interestingly (both at the same time).

    Solid is obviously a very important topic to me, and I expect people to follow it be it in C# or Ruby or whatever.

    As for the IntelliSense. I guess I’ll get used to it. Most people who offered their opinion on IDEs said they usually went back to more lightweight stuff like vim or emacs. It’s just not the perfect way to learn a new language, coming from a world where syntax was the only important thing, classnames and methodnames could be discovered through the IDE.

    greetings Daniel

    Ps: I need to get Disqus working again, the default input field for comments in this theme is just a joke.

  • http://www.semanticmetadata.net Mathias

    Ruby & Rails are both for advanced web designers and possibly people who like writing scripts. It’s quite ok for prototyping, but can never offer the performance and options from a “real” programming language and an extensive framework.

    Besides it’s incredible slowness it’s not really easy to code as there is no handy IDE :)

  • http://www.tigraine.at Daniel Hölbling

    I suspect there will be some pretty successful sites out there that prove you wrong.
    RoR and Ruby is not very performing, but so can be badly written C# code.
    I consider Ruby a “real” language, it’s just different. And as with V8 and Tracemonkey in Javascript (also a dynamic language) we’ll see interpreters that will close the gap between C derivates and Ruby/Python.
    Don’t get fooled by Javascripts poor performance once manipulating the DOM. Tracemonkey (FF JS Engine) performs almost as well as native C, only DOM operations in the browser are incredibly slow.