The author of Beyond Java, first edition, 2005 tells as a bare example that Generics, as a feature that does not even change the JVM implementation is something invasive and with a bad implementation. He argues that dynamic typing leads to simpler applications and increased productivity, and boy what a productivity! – I’ve adopted Python 2 years ago as my main language, and have been acquainted to the world of Ruby and its frameworks for 3 months now, and they have proven from the very start this aspects are held via their usage and yes, the solutions you implement using them hold true quality as, among other things, these technologies have “batteries included”, with a complete set of libraries accompanying each that solve a myriad of needs (e.g. testing etc.).
The quote: Yet, the Generics syntax is invasive, and the implementation is worse. In an age when more and more experts assert that dynamic typing leads to simpler applications and productive programmers, Java developers are learning how to build stronger enforcement for static types.
I.e., they are swimming against the current. Badly enough… needless to say anything else. And remember that this book – this 1st edition – was written back in 2005, 6 years ago, already. And as the author states, if you still had not realized that the water surrounding you has started to heat up, you should, “soon enough” (better late than never) as maybe it suddenly boils.
We have talked about the new technologies and that they are by far more productive in terms of the development on types, and it is good to explore them and conclude this by yourself, always. The “explore” part is what was intended by the Enterprise’s image at the top of this post ;)
But now let us go back in time and talk furthermore about the specific Java Generics case:
Although I simpatize mostly with all these visions I just cannot have being narrow minded and I present you a link to an interesting Generics post, in case you ultimately need it.
Despite its non-productivity and non-simplicity there are situations where you want to enforce a collection containing objects of one type (maybe pertaining to a family of inheritance-chained classes), and Generics fits exactly this case as it enforces (secures) that. I as an example once implemented a suite of basic algorithms when studying them at college and I used Generics for the abstract data type implementations, to state that the sortable data structures must contain objects of a type (?) pertaining to a class family with the Class class as the top ancestor (root class) via the Generics’ extends syntax:
Collection<? extends Class>
Again, in terms of usefulness and thinking that we are in a more modern era already, you will use more modern technologies that keep things simpler, and more flexible. With this in mind it is so advisable that you perform this mind shift already (like avoiding to use Generics in Java when it is not really necessary) and try not to lock yourself to this old way (static type enforcement) of thinking and producing code anymore but to a more open (and productive) one instead.
