Seeing Java

In the world of programming there is a particular language known for its…well…thoroughness in doing its job: Java. If any programming language were to build the Great Pyramids, it would probably be Java – and this is no compliment!

A friend of mine is the teaching assistent for a Java class at the University, however, and out of curiousity I recently had him send me a class project. I’ve always ignored Java despite it being one of the most popular programming languages and wondered what I might be missing out.

The rest of this post is a personal reflection on my experience building a program to compare two Poker hands in Java as a “class project” for a first-year Java class.

After some initial set-backs I really enjoyed this project. I’ve been programming a long time and played with lots of different languages, but never done anything substantial in Java. That being said, this was an opportunity for me as a decently-experienced developer to get a first-impression of the language.

For those who are less faimliar with the technical aspects, I’m going to try and clarify some of the technical details, but I apologize if it’s too geeky.

There’s a range of verbosity in the programming world. Some languages are more like that lazy kid in class who never says more than is absolutely necessary – short one-word answers with little expression or attentiveness. Some languages are more like that OCD kid who starts his or her response by pulling out the encyclopedia, a whiteboard, and lots of markers. Each have their own place, but sometimes it gets really old really quick listening to such long explanations for simple questions like, “what’s the temperature outside?”

Java is more like the OCD kid than the lazy one due to strong static typing and verbose syntax. It often gets picked on for taking hundreds of lines of code where other languages accomplish the same task in only a few. This aspect of the language is however one of the reasons some firms making more massive software suites like it – that level of verbosity provides safety checks against certain types of bugs.

I’ve been saturated in the world of Python, MATLAB, and JavaScript for about the last seven or eight years and now PHP. These languages are not at all like Java in this regard, some like Python having been specifically designed to reduce the amount of code required to get.things.done. Henceforth it was quite the shock for me to change habits, but this verbosity didn’t annoy me nearly as much as I anticipated. One things that did really get to me however was that Java has (almost) no type-inferrance. Some languages provide the same protections but do much more work for the programmer reducing how explicity and verbose the code needs to be.

This brings me to the relatively new Java 8 Stream API. If you are a Java programmer and haven’t explored this aspect of the language it’s more than worth your time! Working with streams was actually kind of fun as it brings in that strong type inferrance and adds a modern flavor to the Java world. I found some of the built-in aspects of the streams, such as the aggregation and summary functions, to be pretty useful.

As per the class instructions, I wrote this project in a piece of software called Eclipse. Although anyone can program in Java with a simple notepad or text editor, most people (for most languages) use some kind of IDE, or Integrated Development Environment. These are programs that add helpers and highlighting and tools to make programming easier. Eclipse is kind of a like a tank – huge, slow, and well-known. It wasn’t too bad on my MacBook Pro, but definitely slower and bulkier than I’m used to – like trying to drill a pilot-hole in a wall by holding up a big drill-press.

Technical aspects aside I enjoyed working in a completely new territory. Up front I had some worries if I would be able to handle it in the allowed time and if I would be able to produce decent-quality code. It turned out that I didn’t have much trouble and this probably isn’t all that surprising – not because of my skill, but just because programming really is a skill independent of language choice. While this kind of experiment might pose higher challenges to newer developers, I don’t think it would be that tough for those with a few years under their belts. It’s more akin to switching from crayons to watercolor than it is to switching from a bicycle to a car.

At the end of it all I had just under seven hundred lines of Java that I wrote excluding the code used for testing. I couldn’t help but wonder how many lines of JavaScript it would have taken…

5 thoughts on “Seeing Java

  1. Very interesting hearing this perspective. I’ve almost always heard it in the other direction, people who have learned in Java then moved on to other languages. Probably because this was the first language we worked with in school.

    So when are you re-writing in JavaScript? 🙂

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s