I got more involved with Tcl over time ( http://tcl.apache.org/ and some other stuff) and over the past couple of years have been moving towards Ruby for most of my scripting/web needs.
{set i 1} - eval'ed once at start time.
{ $i <= 100 } - an expression that is checked each time to determine whether to continue
{ incr i } - eval'ed each time
{ ... the rest ... } the body is eval'ed each time.
Everything in Tcl is like that - it's extremely easy to figure out and there are no surprises. It's also extremely easy to implement. Here's Hecl's for loop:
case FOR:
/* The 'for' command. */
/* start */
interp.eval(argv[1]);
/* test */
while (Thing.isTrue(interp.eval(argv[2]))) {
try {
/* body */
interp.eval(argv[4]);
} catch (HeclException e) {
if (e.code.equals(HeclException.BREAK)) {
break;
} else if (e.code.equals(HeclException.CONTINUE)) {
} else {
throw e;
}
}
/* next */
interp.eval(argv[3]);
}
break;
That's not a good idiom, because it only allows you to loop over small ranges:
>>> for i in range(1000000000):
... print i
...
python2.4(1261) malloc: *** vm_allocate(size=4000002048) failed (error code=3)
python2.4(1261) malloc: *** error: can't allocate region
python2.4(1261) malloc: *** set a breakpoint in szone_error to debug
Traceback (most recent call last):
File "<stdin>", line 1, in ?
MemoryError
Why attempt to allocate such a large list when you just want to do something several times?
xrange() addresses the problem you describe and has been in Python since, like, forever. However, range() is nicer for learning the language, since it's easy to see how it composes into a list.
I think if you want to talk about advantages though, with Fortran you're going to want to talk about the speed, not the brevity. Ruby is quite poky by comparison.
Oh, for sure, but I'd hate to get drawn into the world's Nth general discussion of the advantages and disadvantages of programming languages. That would be dull.