Thursday, July 25, 2013

Java Generics: Technical Book Review

This post is a book review (as part of O'Reilly Blogger Program) of the following book:
  1. Name: Java Generics
  2. Authors: Maurice Naftalin, Philip Wadler
  3. Released: 2006
It's perhaps too late to be reviewing this book, as technical books quickly become outdated. The book was written at the time of a Java release that  marked the "new beginnings" of the formidable Java platform, the Java 5 release, back in 2005. This book review is written in 2013. Generics are an inseparable part of Java Programming Language. Though you'd like to think that it were (somehow) optional to know Generics, it's not the reality. You must be thorough with Generics. I agree that not all of us are library or API designers/implementors, but all of us are users of Java API; and a well-written, "modern" Java API uses Generics heavily. As a result, it quickly becomes imperative to know what Java Generics are.

And if you want to understand Generics, this is the book to get and read. Look no further. The treatment of Generics has not changed (and perhaps will not change) across Java releases. What was true in 2006 about them will be true for quite some time (with minor improvements). And both Naftalin and Wadler have done an exceedingly good job of providing a thorough, lively and almost perfect treatment of this arguably the most divisive Java language feature.

The prerequisite to reading this book (like, perhaps any other book) is to look at both Generics as a concept and their particular implementation adopted by the Java Platform with an open mind. If you have preconcived notions about this (which is not bad), this book is not for you. You should then be on the Java Community Process (JCP) mailing list about Generics.

I appreciate this book mainly because it tries to "inform", not "impress". Many (even popular) technical books tend to do the opposite. With lucid examples, the book helps getting to the bottom of the "whys". It also brings out the synergy between the Java 5 language features that makes the whole greater than just the sum of its parts. After/while reading the book, you might see how the controversial autoboxing/unboxing, varargs methods, the foreach loop work in unison to deliver toward a common goal -- typesafe collections of Java objects.

It's likely that you just hate the compile-time type safety. Perhaps you come from a refreshing and liberal dynamic scripting language like JavaScript and believe that compile-time type safety does not alleviate you of testing your code. You should then consume Generics as a necessary evil when programming in Java. But even then, if you are willing to accept that type safety has some benefits especially in the context of the Java programming language, read this book.

Tuesday, May 28, 2013

Are we becoming devicive?

No, there's no typo. I mean devicive and not divisive (which sadly, we are becoming with all these compartments we tend to create).  But I just coined this word:


devi·cive [dih-vahy-siv, -vis-iv]
Adjective
Tending to show off expensive devices; gadgety
This occurred to me when my son's school had an "after-school electronics party" where they were supposed to bring in a small electronic gadget and share it with it others. They were allowed to be creative in picking such a device. My son is in 2nd grade.

He complained on the day before the party, "Baba, we have this party tomorrow and everyone plans to bring in iPod Touch, iPad, Xbox, Samsung Phone, Nintendo DS, and so on. What should I carry?" I knew that a day like this might come. I just did not know that it would be this soon. I was rather disappointed that at the electronics party, the kids are not bringing in those electronic devices that spark some fun. I didn't realize that Apple gadgets, Android-Samsung smartphones and Nintendo DS's are supposed to make us parents stop thinking :-). Are these devices what we want 2nd graders to think of, when we mean Electronics?



A binary clock
I looked around the house and suggested to him of the gadget that is by his desk and has faithfully displayed the time every time ;) -- his binary clock! It fit the bill and he's always liked it and he was so happy to have made that choice. I was of course proud that I didn't have to make a trip to Apple Store. I was more proud of my son because he spontaneously accepted this suggestion even when peer pressure is not easily surmountable. In fact, later on, somebody told him, "Hey buddy, I liked your binary clock!" and he was very happy!

Don't get me wrong. I did not want to seem different for the sake of being different, nor did I want to suggest that my 2nd grader son knows how to read a binary clock. It was just a sensible choice (I thought) we made when confronted with an unexpected situation (which is what life is all about). I wish I had created (made) a small electronic device along with him, but alas, there was not enough time.

Again, it's not that I hate the devices. I love them. I like creative products that many companies come up with. And I believe that Apple, Sony, Google, Microsoft, Nintendo have done a great job in creating such devices, but I don't think those devices should distort (or conveniently enhance!) our understanding of Electronics -- our 2nd graders' notions of electronic gadgets don't have to start and end with an iDevice.

Sunday, January 13, 2013

RIP, Aaron Swartz ...

Sometimes, some deaths are just gut-wrenching. Aaron's death was one such incident.

Aaron, a master computer programmer, an Internet activist committed suicide at 26. You can read up all about it for the Internet search will find you all the relevant details quickly.

I, like many others, didn't even know about Aaron, the man behind the name, until I read about his untimely death. But in hours of my discovery of his genius, this news and the whole unfortunate aftermath, I was grieving his death like that of my family member.

13 felonies for the crime (!) he committed? All he wanted was a fair treatment of his alleged crime and it was not granted. I shudder even now as I write this. Maybe we should rename justice.gov to law.gov, there's no justice.