Ruby could work, I have heard that it's pretty good
It is...until i started with Ruby a short while ago, i was exclusively a java developer. Learning Ruby was the best thing i've done in quite a while; it is just so much more elegant and efficient.
From java-guy's perspective many of ruby's features are simply freaky, but in a good way. While getting into it with some tutorials i kept thinking, "are they serious? this really works?"
I just couldn't believe that all those things that required lots of lines of code in java could be done as efficiently as i just saw them, as i was used to doing them the java way.
This is a really good ebook:
http://ruby-doc.org/docs/ProgrammingRuby/html/index.html
E.g. it makes a lot of use of passing code blocks to methods, not unlike function pointers or algorithms that are encapsulated in anonymous inner classes. It feels strange to make excessive use of such features, but they simply make sense and are easy to use in ruby.
Iterations are similar...in java, one needs lots of control statements to declare an iterator or a "for" loop in order to run a code block against each element of an array or a collection. In ruby, you just pass the code that is supposed to be applied to each element as a parameter to a method of the array - with no risk of the "error of one" and so on.
It's similar with executing a piece of code n times - integers have a method that accepts a code block.
example:
5.times{|i| puts i}
The object "5" (declared and initialized automatically, right on the spot) has the method "times" which accepts the code block in parenthesis and calls it as many times as its own value. The count of the calls is passed to the code block as the parameter "i".
The java counterpart would be much sluggier:
for (int i=1;i<=5;i++{
system.out.println(i);
}
Another cool thing is the treatment of series of objects. E.g. [4..8] is a valid declaration of an array containing the values of 4 up to 8. But i can't only do this with native types, but also any of my own classes, if they define the methods "compare" and "succ"...e.g. this:
a=[MyClass.new(4)..MyClass.new(8)]
a.each{|item| puts item.toString}
"Each" is a method of arrays and collections which accepts a code block that is applied to each item in the array, declared to be called "item" in the code block. The java counterpart (assuming that it is important that all the objects have to be created before being written to system.out):
MyClass[] a=new MyClass[5];
for(int i=0;i<=5;i++){
a
=new MyClass(i+4);
}
for(int i=0;i<=5;i++){
system.out.println(a.toString());
}
As you see, this is very prone to that famous "error of one" and an indexOutOfBoundsException in case of the array, as the constructor parameters and the array indices are shifted by four and there are five entries in total, not four (8-4=4)...ruby effectively avoids both problems and gets straight to the point, it does not clutter the code with needless flow control syntax.
Yet another cool feature is metaprogramming. Setters and getters are declared in a single line:
"attr_accessor :myField"
This declares a field "myField" and automatically generates setters and getters. So far, so good...the cool thing is, the setters and getters are called just like a direct access to the field. The bold parts in getMyField() andsetMyField() are redundant (because there is no other generally acceptable way to access a field) and therefore left out, they just cost keystrokes. Instead, the field can be accessed as if it were public, but these are actually calls to accessor methods:
a=myObject.myField
myObject.myField=b <-- this is a valid method call syntax, not a direct assigmnent!
This means that one can change direct assignments to a setter call by simply defining the setter, without requiring to change all direct assignments of that field to the method call syntax of a setter method...