Java Code Geeks

Thursday, January 8, 2009

Java Vs C++ an analogy

I think any C++ developer tend to think when they move to Java - what they gained and what they lost. I was thinking about Java Vs C++ in terms of memory management and this thought came to my mind. I would like to describe that - working in C++ as if you are preparing food at home vs working in Java is as if you are having your food at a restaurant.
The difference between java and c++ comes clear if we think of having food at a restaurant vs preparing and having food at home. When we have food at restaurant we do not worry about where from the plates are coming (think of who allocates the memory) and who will wash them after having food (think of who frees the memory). So the good think of working in Java or having food at restaurants is that we are free from some house hold activities which are otherwise boring and error prone.
But the actual strength of preparing food at home is that - we can do anything with the food. It all depends upon us to determine how much salt or pepper we need to use in the food. Compared it with having food at restaurant where we have little control over the ingredients of the food (of course I am not referring to open kitchen style of restaurants).
So C++ might still be stronger than Java as there are more freedom given to the developer as what he wants to do - but the developer should be pretty good in it otherwise go out for dinner :-)

No comments: