Many programmers love Ruby, they just can’t get enough of it. Its probably one of the most aggressively evangelized languages since Java first came on the scene. They generally cite features that include a flexible and extensible syntax, closures, and how concise and expressive the code can be.
Comments
noblemaster replied ago:
>>> In Java you must painstakingly tell it the type of each variable you use, and this is one of the main reasons Ruby is more concise and easier to read than the equivalent Java.
Static typing has some distinct advantages over dynamic typing. I am not so sure how easy a variable is to read that has been passed in without any given type?
Example:
A) var value (Scala)
B) String value; (Java)
It's probably easier to see what type B) is representing?
See also: http://www.nobugs.org/blog/archives/2003/05/11/static-typing-vs-dynamic-typing/
smackjer replied ago:
I wonder how anyone can possible get any work done then... In the real world, it's just not that big of a problem.
cbegin replied ago:
First of all....type inference is not dynamic typing. It just means the variable will be typed using the information to the right of the assignment to avoid duplication.
Second, your examples aren't really fair. Trust that in a fair example, Java looks far worse:
// Java is full of unnecessary duplication
// (I had to actually run this to make sure it would work)
Map> countCache = new HashMap>() {{
put("one", new ArrayList(){{add(1);add(2);add(3);}});
}};
// C# is far cleaner, and even more typesafe than Java at the end of the day...
var countCache = new Dictionary> {{"one", new List{1,2,3}}};
# Perhaps Ruby is a little extreme, but still far cleaner
cacheCount = {:one => [1,2,3]}
// I actually think Groovy is the right balance because
// typing is optional, even though you can still do this
def cacheCount = [one:[1,2,3]]
//...and this
String s
Optional typing in Groovy and C# is great, because typing is still very important when defining new classes -- which are types. I think Ruby is a little off on that point. Luckily it wouldn't be hard to create a DSL for an explicit type system for attribute declarations in Ruby (for ORM tools etc.).
Cheers,
Clinton
cbegin replied ago:
DZONE!!!! What is with the comment system! We can't paste code!? What does the "d" stand for in the name?! ;-)
Clinton
lninyo replied ago:
The link doesn't work! how can people be voting this up or down when the article linke doesn't even resolve?
cbegin replied ago:
It works....
Voters For This Link (21)
Voters Against This Link (4)