D is Neither C++ Nor java
Friday, September 15th, 2006Get it in your head right now: D is not C++ and D is not Java!
There is a natural tendency when learning a new language to, initially, attempt to use it the same as a language you are more familiar with. This is especially true when the two languages are similar in syntax. Since most newcomers to D seem to primarily come from C++ and Java, and since D is similar to both languages in many respects, people are naturally trying to shoehorn C++ and Java idioms into D, sometimes becoming frustrated when things don’t work as they expect.
Feature requests for functionality found in other languages are not uncommon on the D newsgroup. I personally think Walter has done a great job of sticking to his guns for the most part. Granted, some of the features that he relented on after the community harrassed him have turned out to be incredibly useful. Some have even given D a unique flavor that really sets it apart.
I would love to see reflection/introspection capabilities similar to Java or C#. That would really put D in a unique position, being the statically compiled systems language that it is. I wouldn’t mind seeing a more explicit syntax for properties, but it’s not something I consider a deal breaker. I can do without assignment overloads, but if such a thing ever did make it in, I wouldn’t cry about it.
So I have my opinions and everyone else has their own. But it’s not the feature requests and wishlists in and of themselves that prompted this post. It’s the reasoning behind some of them. I get the impression that some feature requests are made not because they are great ideas that would improve the language, but because they would bring D more in line with language X.
I shall repeat myself: D is not C++ and D is not Java!
One of the reasons so many C++ programmers have such a disdain for Java is because they can not, or will not, take their C++ hats off long enough to learn that Java isn’t C++. I have seen enough microbenchmarks, which are generally useless anyway, coded in Java by C++ programmers to know that C++ programmers can’t write Java code. When you whip out a Java compiler, you have to be wearing a Java hat. Operator overloading is not a feature in Java, so if you are thinking in Java you won’t miss it. The same holds true in reverse, of course — Java programmers need to be wearing a C++ hat when Stroustrup comes off of the shelf.
One more time: D is not C++ and D is not Java!
When you come to the Land of D, drop whatever hat you are wearing at the gate. Keep your fundamentals, because you’ll need those. Keep the memory of what it was like to wear that other hat, because sometimes those C++ or Java tricks may come in handy in the D world. But under no circumstance should you expect to find yourself on familiar terrain. Sometimes you will, but familiar does not mean identical.
The next time you see yourself looking for that C++ or Java feature that D doesn’t have, ask yourself which hat you are wearing. When you have the D hat on, most of the time you’ll find that you just don’t need that feature at all.
Technorati Tags: D Programming Language, C++, Java