| Recent Posts | About the Author | Navigation |
|---|---|---|
|
|
David is an occasional blogger, software engineer, Nintendo fanboy, liberal, news magazine addict, voracious TiVo user, and bibliophile. He was born in St. Louis, grew up in southern Indiana, and returned to St. Louis to attend Washington University. He hasn't managed to escape yet. He's a fan of free wine tastings, too many tv shows to name, and eating out. David makes his living developing web applications used internally by his employer. He doesn't blog about work because he's heard too many stories about that causing workplace troubles. There's more on the about page. |
|
| Recent Comments | ||
|
|
||
| Recent Photos | ||
|
|
||
I just read a weblog entry where someone complained about Java, and I feel like I have to stick up for it. First, the relevant portions of the post:
Tonight we went over why Java is such a nice language:
1) no operator overloading.
2) single inheritance.
3) no pointers.
4) platform independence.
Here are my thoughts:
1) Overloading operators in C++ is one of the best features of the language itself.
2) I don't use inheritance. I write all my code from scratch each and every time, writing specific non-reusable (except to me as reference) code that is optimized for whatever the situation is.
3) Pointers are what makes dynamic memory allocation possible. I fell in love with pointers last semester, after I was forced to use double-indirection in many of my programs. Single indirection even used to be a serial killer, but now it's my housepet.
4) Platform independence is perhaps the only good feature of this language. However, it's also its major downfall. For one, variable types have the same size (depending on their declaration) across all platforms, not just whatever word-length is the most efficient to store an int (as is the case with C++) Platform independence makes it a lot easier to debug, as anyone can come up to me with a problem, and I can instantly trace how they got that error to begin with. However, seeing as how Java needs a virtual machine to to run its bloated bytecode, and how most of these VMs are built in C++, it's both a step in the right direction, but its major downfall.
And now my response to each of these points.
1) Operator Overloading. A nice feature, but a frequently misused one. For every time I've wanted to use operator overloading in Java, there have been time when I'd wished someone else hadn't used operator overloading in C++. They often just make working with someone else's code a nightmare.
2) Inheritance. I don't really even know how to respond to this. There are so many reasons that inheritance makes sense, that I don't have the space to list them. All your response tells me is that you don't really understand inheritance or its benefits. Because code optimized for a specific task should often include base classes and sub-classes. I really don't understand how someone could advocate not using inheritance in an OO language. I so overwhelmed by this that I can't even formulate legitimate arguments right now. I'll expand on this point in the morning.
3) Pointers are useful on occasion, but the developers of Java made a (totally justified in my mind) decision to abstract away from memory management. Poor memory management is the single largest cause for errors in programs these days, so Java does garbage collection and doesn't allow you to do pointer manipulation. The issue here is that Java wasn't designed with your strengths in mind, but was designed to be most beneficial to the largest group of people. If you like pointers and memory management, more power to you, I guess, but Java is giving you a gift in not requiring you to muck with it.
4) I'm a bit sleepy, but I couldn't really understand you on this point. Java's platform independence is one of it's major selling points ("Write once, run anywhere"), and a justified one. Because of this platform independence, it is becoming the dominant programming language. And because of its virtual machine, it is well-suited to embedded systems. And I don't really think its byte-code is all that bloated. It's slow because the use of the virtual machine basically makes it into an interpreted language, but the Java compilers (I like Jikes a lot) are quite efficient at producing byte-code. I would wager that they byte-code spit out by javac is just as efficient as machine code output by a C++ compiler like gcc. The speed issue comes when the virtual machine has to convert the byte-code to machine code in real time, just like other interpreted languages.
I have a feeling that I didn't articulate these points very well, as I'm about to fall asleep. I might post on this topic again in the morning in order to make my points clearer.
Posted by on 11 January 2002 at 1:51 AM


