I have to put in a plug for a very high level language, python. Python has a very clean syntax like this:
def double(x):
return x + x
It has list comprehensions:
myList = [double(i) for i in range(5)]
# myList is now [0, 2, 4, 6, 8]
To do the same thing in Java:
public Class Example {
public static void main( String [] argv ) {
static int double( int x ) { return x + x; }
ArrayList myList = new ArrayList();
for( int i = 0; i < 5; i++ ) {
myList.add( double(i) );
}
}
Much more typing.
Python supports anonymous functions, and mapping operations:
myList = map(lambda x: x + x, [0, 1, 2, 3, 4])
# myList now is [0, 2, 4, 6, 8]
The "lambda x: x + x" means "make me a function that takes x and doubles it, but I don't care what it is named." Then the "map" says "take that function that I just made up and apply it to each of the items of the list '[0, 1, 2, 3, 4]' in turn." There is no Java equivalent.
I could write the sum of squares like this:
sum( map(lambda x: x * x, [1, 2, 3]) )
# this returns 1^2 + 2^2 + 3^2 = 1 + 4 + 9 = 14
As a benefit, you can use Jython (listed below) to *compile* python into Java bytecode, so anywhere that you can run Java you can write your program in python and then have it run on the Java Virtual Machine.