Friday, June 14, 2013

Java: the bane of computer science freshmen

I didn't start programming until college. My first programming language was Malab/Octave. I fell in love over spring break when I was able to spend the entire week writing and debugging what in retrospect was a very simple program. Octave seemed impenetrable at the time, but my first couple classes after switching to Computer Science had me pining for its simplicity.

Like many other beginning Computer Science classes Java was the class language. And like many other programmers I found it frustrating. The problem is that Java is just not a good a good language for new programmers to learn with. Its verbose; the core library has many redundancies, yet is also is missing many useful features; and virtually requires an IDE.

Java requires a lot of handwaving to achieve the simplest thing. Assigning properties of an object will just about require as many lines as properties. Binding events, running code on a new thread, even reading from a file seem to require way more lines than it should. Complaining about much code might seem like a whining, but with an inexperience programming it can be a showstopper.

Anyone who has written a non trivial Java program can attest that import statements quickly get out of control. My project to create an Android audio book player averages 10% of the lines being import statements. I'm not a full time Java developer, so to avoid looking up Java packages every ten minutes I use eclipse because it auto imports and remove packages based on use. Asking a brand new programmer to use anything more complicated than the command line and a text editor is counter productive. It adds another layer of difficulty to what is already a difficult task, learning about computing.

In some sense these problems aren't a design flaw. Java wasn't created with simple use cases in mind. The use case that the designers had in mind was hundreds or thousands of programmers working on the same project or platform. Code portability and modularity, as well as engineer interchangeability are key design objectives. In those situations the character of Java and the use of IDE's are much more useful.

However, in an academic context, especially early on, the conventions of Java are an impediment. Languages like Ruby, Python, or Go (although new) make a lot more sense in this context. The syntax of these languages is simpler, and in Ruby's case more forgiving. In most cases Java gets in the way of learning concepts.

Over the last couple of years I've reintroduced several friends to programming. They were frustrated by Java, there just wasn't enough success or it wasn't worth the Herculean effort to print "Ross is cool". However after sending them to tryruby.org. They become excited by the same joy I feel when creating something from thought. To me these instances are decisive.

No comments:

Post a Comment