Thoughts about Java and Python.

In my Computer Science course I was asked to write a program, in Java, that would compute the powers of 2 from 2^1 to 2^20 using only a while statement. At first I tried, with just the basics that we had learned so far, to create the program. Things did not go well because I couldn’t get the powers to work correctly using pre or post decrements. After I looked through the extensive Java Math library here is the solution I came up with:
public class week02_ex3 {
public static void main(String[] args) {
int count = 1;
int multiplier = 2;

while (count <= 20) {
System.out.println("Powers of 2^"+ count +"=" + java.lang.Math.pow(multiplier,count));
count++;
}
}
}
Coming from a completely Python world, I wondered how I would have implemented the same program in Python. This solution is probably not the most elegant solution but Java was very heavy on the brain while I wrote it.
count = 1
multiplier = 2

while count:
if count <= 20:
print "Powers of 2^%s = %s" % (count, multiplier**count)
count = count + 1
A couple of things I really missed from Java when coming back to writing Python were:

Post and pre increment, I understand why Python doesn’t have them but damn are they useful
Brackets for the while statement, I know brackets are horrible and messy but it really makes the start/stop of a code block easy to follow…fuck Ruby and its “end” command that is just ugly.

I really like the way Python’s “print” values work. It is much nicer to use %s inside the code and then add % (count, multiplier**count) at the end of the statement rather than using the “+” and variable names.
In the Python world Java gets a lot of shit from a lot of people. Granted, Java does have its share of problems and oddities but it is an extremely powerful, well backed language. Oracle’s support of Java after their acquisition of Sun Microsystems has dramatically increased since a great number of their products are built on Java. Probably the strongest piece of the Java programming language is the Java Virtual Machine. The JVM is so versatile, that, practically, every language can be run on it. There are implementations for Ruby (JRuby), Python (Jython)[1], and even, my favorite web framework, Django (Django-Jython)[2].
With Django and Python gaining traction in the Enterprise world Django-Jython and Jython are perfect building blocks for organizations that *have* to run Java for some of their applications or middleware but want the ease of use that comes with Django and Python for their internal or even external web teams. I like where things are going and I am on the bandwagon with both languages.
[1]: http://www.jython.org/
[2]: http://code.google.com/p/django-jython/