A Thought About Java and Python

So I'm diving in Python, and because I've spent the past 4 years heads down as a Java programmer, I can't help but compare and contrast and "wonder if".

First let me explain the primal urge. Python attracts me because it doesn't seem like a "formal" programming language. Java is now used everywhere from universities to NASA and there are a zillion rights and wrongs that have been handed down from those on high and programming in Java now just makes me feel like I'm always doing something wrong. Hacking is downright encouraged in Python which is a fucking relief. Honestly, at this point in my education, I still prefer Java's overall logic that Python lacks, but I'm really attracted to Python's cleanness, relative simplicity and *complete lack of guilt* while using it.

But the problem is that Python is definitely crufty. There are so many spots where you can see how the language has been expanded - by force if necessary - throughout the years. Things like the way running an app works: you write a function that tests to see if matches "__main__", instead of an actual main() function. The fact that *every* method in a class needs to refer to "self" first (i.e.: method(self, otherParam) ) is ugly. And self isn't actually a reserved word, just a "strong convention". Ugh. As I learn more, I find more. In my opinion, Python could definitely use a new version rev, drop backwards compatability and clean up the cruft.

So you can see that I'm digging Python because of it's hackiness, but also disliking it for the same exact reason. And of course, I'm constantly comparing it to Java. Different languages do different things better, but as I run into areas where Java is so much better (db access, portability, packaging in jars) I wish I was back in the Java fold.

Basically, I can't help thinking that Java could be made to work more like Python. I mean, there's Jython, but I don't want to talk about half-ass implementing Python on Java, I'm talking about making Java more programmer friendly like Python.

This is already happening - but mostly on the server side of things. What I'm talking about is the various versions of JSP. The biggest flaw that most server side programmers have is to consider JSP a separate technology, when in reality, JSP is simply an elaborate macro language for creating servlet classes. Jasper parses JSP and creates a class. And that's the key - it doesn't matter *what* you program in using Java as long as the end result is a valid class file. This is the way Jython works: when the Python code is parsed and compiled, the result isn't a .pyc, but a regular .class file. Other examples include Apache's Axis project and their .jws files that produce all the classes that are needed for SOAP and WDSL and JSP 2.0's upcoming .tag files as well that produce tag libraries. All examples of non-full Java producing real classes.

So for all us non-programmers who could give a flying fuck about the GoF and just want to get something cool done in the shortest time and minimum lines possible, there needs to be another option than the increasingly complex and bloated Java, but not just on the server - for use on a daily basis.

I guess if it's not Java, it's not Java. However, something could be "mostly" Java and work more like Python. Would it be optimized? No. Would it be for the hard core geeks? No. Would be useful? Yeah, I think so. But I don't want some random OSS project that no one takes seriously, I'd like a sactioned Sun-backed spec like JSP.

Here's how I envision it. Imagine you had a new type of file called a .jv file. No compiling step needed. When you went to run it, the compiler would automatically be invoked, just like Python creating a normal Java class. There would be a set of libraries automatically imported that wrapped up the commonly used libraries in Java making things like i/o and Collections as simple to use as Python's Dictionaries, lists and open() function. Types would be dynamic, yet strongly typed and autoboxed (of course). It'd be easy to import existing libraries so you can take advantage of the massive amount of stuff produced for Java already, but not have to deal with the crap. Comments would have their own place, as well as neat functionality like overriding operators. No - I'm not asking for a VB for Java, just a version that's meant for higher productivity.

What do you think? I think if I never heard the term "anti-pattern" again, I'd be a happy man.


< Previous         Next >