October 28, 2003Flaws in RubyI am in general very fond of Ruby. It's a very appealing language allowing all kinds of object-oriented designs not available in Java and other traditional languages. However, there is no such a thing as a perfect language, and there are a few details in Ruby that bother me. For example:
Matz does have a point with the exploding complexity of orthogonal features. I believe this fact is one of the main reasons why C++ became so unbelievably complex, both in syntax and in semantics. For examples, templates were initially introduced using the "<" and ">" characters. It didn't take long before somebody realized that this new notation would conflict with the stream operator ">>", thereby forcing you to close nested templates with "> >" instead of ">>". However, I believe that in the particular case of overloading, Matz is mistaken. This is one of the few features whose combination with other features is pretty well understood and still easy to read. The only problem I can think of is when you try to mix overloaded methods with default arguments. The ambiguity of this particular case led to the rule that default arguments can only be specified at the end of the signature (okay, there is another reason for this constraint that has to do with the way parameters are pushed to the stack, but I won't go there). Matz himself is the first to say that "there is no perfect language". Or rather, his perfect language is not my perfect language. Fair enough. Ruby is still a joy to program. Comments
If you really need the method overloading you can try this package http://mephle.org/StrongTyping/. Ruby is very expressive language where you can emulate a lot of things. Regarding orthogonality you are absolutelly correct, that why it is so pleasure to program in ruby. Posted by: ruby fan at October 28, 2003 07:19 AMCedric, you might like Groovy then (shameless plug)... http://groovy.codehaus.org/ Groovy is a python/ruby style language designed for the JVM. So it compiles down to normal Java bytecode & Java classes, yet has much of the power of Ruby (closures, lists/maps syntax, generators, dynamic typing etc). The nice thing is that both inside the Groovy language and outsite (in the JVM) there is no difference between Groovy or normal Java objects - i.e. groovy objects can use Java objects and vice versa. Incidentally Groovy fixes all of your 3 complaints. * no Perlyness The 'end' syntax was the one thing which looked so ugly and BASIC to me that it kept me off Ruby. Posted by: Sumit at October 30, 2003 09:38 AMI think Ruby can use { } instead of END Posted by: Stephan Schmidt at November 13, 2003 06:14 AM"The 'end' syntax was the one thing which looked so ugly and BASIC to me that it kept me off Ruby." I had the same initial reaction, but I kept hearing good things about it, so I bought the PickAxe book and dug in. I was soon won over, so much so I that I now manage http://www.rubyxml.com and http://www.ruby-doc.org. I tend to use { ... }, and only use begin/end for blocks and exceptions, so the sematic difference is more clear. And I rarely need to use any of the Perlisms. Posted by: James Britt at December 5, 2003 08:32 AM"The Perl heritage" was my mistake. Their use will be removed or at "The meaningful indenting" is plain wrong for a language like Ruby, Finally, I am not against "method overloading", but it very easily leads to optional static typing in the language, which changes the language As a newcomer to ruby, with a perl/c/java background, I am astonoshed that simple 'argument count' overloading does not work. Surely most people would expect this to work: IMHO multiple dispatch is better than method overloading. A method is implemented multiple times like in overloading. At the time of the method call the types of the arguments determine which method is invoked. Something like a big switch generated by the language and containing forward calls to the different methods. But I cannot see how it could be implemented in Java nor in Ruby. They only offer single dispatch on the invocant (the object before the dot of the method call). i also dislike the use of 'end' (just about the only think i *don't* like in ruby). so, since everybody is saying that this is a matter of taste, does that mean that this will work: class Hello Or what about this: def fib(n) in other words, i'm more comfortable with {} coming from C,C++, & C# so what are the precise syntax rules for substituting {} for 'end'? is there anything wrong with how i structured my code above? I keep getting syntax errors & "odd number list for Hash" errors, & i'm pretty sure it has something to do with my syntax, since both of these work in their original form (using 'end'). Thanks! Posted by: carlo at April 28, 2006 11:20 AMI personally love the "end" syntax for blocks. Often I find myself liking the usage of plain words instead of so many symbols while programming in Ruby. I think the {}'s show Java and C's formality while "end" expresses Ruby's easy, comfortable appeal. Posted by: Glenn at December 21, 2006 05:00 AMWhen I moved from C++ to pascal I sooned learned to appreciate 'end' since it was in keeping with pascal's neatness. And wow did that neatness make a big difference in productivity. Well, ruby seems to have that virtue also, and it just seems right. I still avoid curly braces (except for one liners) in my ruby code, but I like the tip above about using 'end' for exceptions; but I'll do it the other way around. Posted by: GregL at February 12, 2007 03:42 PMMy only problem with 'end' is readability. Tabbing is not enough to be clear on where blocks begin and end. Brackets can be lined up for easy readability. But, I love ruby, so I use end. I also would like to see argument count overloading. That's not so ambiguous, is it? Posted by: Andrew Otto at August 28, 2007 11:46 AMPost a comment
|