Wednesday, March 5, 2008

Things I hatedon't like about Ruby

Ruby is quite cool, I like lot of features, but for me as C/C++ developer there are some things, which are quite annoying. Please note, that I'm aware that lot of issues I mention here are actually Ruby features. This post will be dynamic, so more items will be eventualy added. For each issue, I'll try to search for solution or workaround. Also I encourage you to post any ideas you might have about solving these problems.

  • multiple classes per file
    I know that you can have more classes in C++ as well, but I like Java way. I also know that Ruby doesn't force you into writing multiple classes per file, but it also doesn't discourage people that write spaghetti code. If you end up maintaining project like this, it's hell.
    Solution: Use search to navigate project, or refactor to class per file.

  • variables doesn't have to be declared
    This is anoying, if you have to study some old code. In Java/C++ world you have to declare class/object variables. If you look at the code after some time you have all members of the class neatly organised at declaration section. In ruby you're free to use variable wherever you like, without first declaring it.
    Solution: correct way of using members is to use accessors: attr_reader, attr_accessor, and attr_writer.
    Well ... one friend had good note: "Always code, as if the guy which end up maintaining your code is violent psychopat, who knows where you live."

  • arguments lack type information
    This is related to previous item. Coding with strongly type-based languages is quite addictive. Switching to Ruby, you'll start missing those: "cannot cast x to y" errors from compiler.
    Solution: ?

No comments: