Happy 20th Birthday Java! What’s your Java story?

I started learning Java in 1996, from the book ‘Learn Java in 21 Days’, published by SAMS. For some reason I even still have the same book:wpid-20150521_081822.jpg

At the time I was working for Royal Sun Alliance and we were doing OS/2 client/server development using Application Manager, against a CICS/COBOL backend. One of the guys I was working with, Mike, said I should take a look at this new language called Java because it can run on any platform. At that time developing on OS/2 and seeing demand slowing for OS/2 AM developers, the promise of a development language not tied to a specific platform seemed an attractive offer, and a potential ticket to move away from OS/2.

I started working through the exercises in the book, building my first Applets – I think one of the first applets I built was a lottery ticket number generator that I had on my webpage at the time. In 1996 it was pretty cool to have interactive content on your web site! Even though this turned out to not be Java’s strong point (most Java development is arguably server side now days), it was where it all got started.

Although I continued to play with Java in my own time, it wasn’t until I changed jobs in 1997 and moved to TSW/Indus, a software house developing Enterprise Asset Manager software, that I had the opportunity to start Java development ‘on the job’. At the time the company had a Powerbuilder/Oracle PL/SQL based client/server product, and while in that first year I cross trained to Powerbuilder, we started prototypes of building a web-based replacement for the Powerbuilder client, against a Java backend. At the time this was using a ‘Java Cartridge’ on Oracle Application Server (I think it was called), and the Java code was invoked CGI-BIN style using HTTP GET query string parameters that were passed into Java code on the server.

At some point pretty soon after these first prototypes the Servlet API came along, and then EJB1.x came along… looking back which was an absolute nightmare from a developer productivity point of view. Somewhere in there I also dabbled with some CORBA based backend running on a server that I think was called IONA (although those memories are long gone now).

I’ve seen a lot of incredible changes in the Java space, and 19 years later from where I started, I’m still coding Java and it’s still going strong!

Enjoy your additional ‘leap second’ on June 30th 2015

This year on June 30th at 23:59:59 UTC, rather than the 59th second ticking to 00, there is an additional second added so clocks will tick to 60 before going to 00.

If this sounds rather odd, check out a more detailed explanation here on Wikipedia.

So what does this mean for us as software developers? Well, for Java JVMs, you can use the provided tzupdater tool (updates described here, and usage described here), download the updated timezone file and apply the update. For other platforms and operating systems, check release notes and updates from your vendors (e.g. For RHEL, check here).

Should you be worried about the impact to your systems? Well that depends on how sensitive your system is to the date/time and synchronization with other systems that you integrate with. For example, the ICE futures exchange have announced they are taking their systems down for an hour overlapping with 23:59:59 on June 30th to avoid any unexpected issues. Whether you have to go that far depends on your system.

 

JEP 222 – REPL proposed for Java SE9

A REPL (Read-Eval-Print-Loop) feature is becoming a common feature for many languages (Scala and Groovy both have a REPL commandline shell), and JEP-222 proposes adding this same feature to Java for SE9. This feature is useful for quickly trying out and evaluating an expression, and will be a valuable addition to Java SE.

Finding min and max values with MongoDB Aggregation

Aggregation operations in MongoDB allow you to process documents to produce computed results. An example is to search for a min or max value. For documents that look like this:

{
  "_id" : ObjectId("5521ae8c0364d302910ec5eb"),
  "color" : "blue",
  "orderDate" : ISODate("2014-07-08T19:53:00Z")
  //other properties
}

You can find the min/earliest date in the collection for an document with matching color of blue with an aggregation query like this:

db.collectionName.aggregate(
[
{ "$match" : { "color":"blue" } },
{ "$group" : { "_id" : "$color",
first: { "$min" : "$orderDate"},
}
])

Implementing this with the Java Driver API looks like this:


DBObject match = new BasicDBObject("$match", new BasicDBObject("color", "blue"));

//$group
DBObject groupFields = new BasicDBObject( "_id", "$color");
groupFields.put("orderDate", new BasicDBObject( "$min", "$orderDate"));
DBObject group = new BasicDBObject("$group", groupFields);

List<DBObject> pipeline = Arrays.asList(match, group);

AggregationOutput output = col.aggregate(pipeline);
for (DBObject result : output.results()) {
//iterate results, only 1 for $min
}