«« Next » « Previous
«« Next » « Previous

Link Details

Link 57717 thumbnail

By bloid
via locut.us
Submitted: Dec 18 / 18:17

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.
  • 21
  • 4
  • 2096
  • 1091

Comments

Add your comment
User 259891 avatar

noblemaster replied ago:

1 votes Vote down Vote up Reply

>>> 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/

User 186462 avatar

smackjer replied ago:

-2 votes Vote down Vote up Reply

I wonder how anyone can possible get any work done then... In the real world, it's just not that big of a problem.

User 205784 avatar

cbegin replied ago:

2 votes Vote down Vote up Reply

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

User 205784 avatar

cbegin replied ago:

1 votes Vote down Vote up Reply

DZONE!!!! What is with the comment system! We can't paste code!? What does the "d" stand for in the name?! ;-)

Clinton

User 262982 avatar

lninyo replied ago:

-1 votes Vote down Vote up Reply

The link doesn't work! how can people be voting this up or down when the article linke doesn't even resolve?

User 205784 avatar

cbegin replied ago:

1 votes Vote down Vote up Reply

It works....

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.