Type erasure misconceptions in Java

Generics were added very late in Java (J2SE 5) and one of the challenges with it was to maintain backward compatibility. Type erasure is a technique that the language and runtime designers chose to overcome this problem. Here is a simple demonstration of type erasure in action. import java.util.ArrayList; import java.util.List;   public class Erasure { public static void main(String args[]) { List<String> ls = new ArrayList<String>(); System.out.println(ls.getClass().getName());   List l.. Read More

IDE provided illusions for Java

Lambda functions, or more specifically the lack of it has always been an annoyance in Java. The closest alternative has been implementation of interfaces as an anonymous class. Here is an example: IntelliJ does a nice folding of this code to give an illusion of closures. This makes reading of the code a little more fun as seen here:

“Server side” languages in 2012

Yes, 2013 just began but this post is about my views on programming languages that I have reasonable amounts of professional experience in. This post was inspired by what one of my former colleagues had to say on couple of days ago. Note that it is not meant to be a rebuttal, it just happens to be the tipping point that got me writing. I come from a very varies lineage:.. Read More

Django middlewares, a strange way to do things

One of the pitfalls of being a polyglot is that it is easy to fall into the trap of drawing parallels rather quickly and incorrectly. In this post, we shall compare java servlet filters, wsgi middlewares and django middlewares. The J2EE story The notion of servlets is well understood in java, it is a piece of code that handles an incoming request and provides some response. The most popular kind.. Read More

Object composition implementation styles

  In the first part, we looked at conceptual implications of the various styles of object implications. Now we shall look at a few common implementations of object composition in conjunction with the concepts presented in the earlier post. Association v/s composition First off, we shall start with an example in C to understand the difference struct node { int data; node *next; }; This is a fairly common definition.. Read More

Implications of object composition styles

Object composition is a concept older than object oriented programming itself. Let us start off with a well understood example of how to represent a rectangle on a Cartesian plane: struct point { int x; int y; } ; struct rectangle { point tl; /* top left corner */ point br; /* bottom right corner */ } Here the rectangle object is a composition of two point objects and tl &.. Read More