Re: The Problem with Programming
Posted: Nov 29, 2006 3:28 PM
> I fail to see any significant language advances that have
> occurred outside C++.
To be blunt, that is because you _choose_ not to see any significant language advances that have occurred outside C++.
> Garbage collection? Google returns
> close to million hits. Generics? Yes, I know, long error
> messages and buggy compilers etc, but the bottom line is -
> STL is a decade older than Java generics which, please
> correct me if I'm wrong, boil down to a fancy casting
> syntax. Reflection? RTTI. Exceptions? Got it. Closures?
> They're coming in C++0x. So, what exactly are those
> "advances outside C++"?
You can find the same words in C++, but it is not at all the same thing. Language elegance and usability is not a series of check-boxes that one ticks off in a feature list. (Java made that mistake thinking it had to "keep up" with C#.)
Here is my personal experience, and as such I hope you find it interesting since I was working in C++ quite extensively:
Back in 1996, I downloaded the JDK, read all of the sources for the Java libraries, and that taught me both the language and the entire "platform" as it existed at the time, as well as the common approaches to programming in Java as illustrated by the authors of the language. Knowing C++, it literally took me only a few hours to learn all of Java (it was much smaller then). It was brilliant in its simplicity. Far from perfect, but brilliant nonetheless.
In terms of projects that I had worked on, writing a high-speed cross-platform (as it turns out, 16- and 32-bit Windows on x86 were the two primary platforms) data access and management library in C++ took me about 3000 man hours. Doing the same exact project in Java would probably take about 100 hours, except that the functionality is built in already.
I estimate that writing a reasonable optimizing C++ compiler in C++ to compile and link to a native executable would take about 20,000 man hours. (That type of project was simply too large to undertake, but I did build the emitter portion of such a beast.) I wrote (from scratch -- using nothing but the JDK) an optimizing incremental Java compiler in Java that compiles code that _runs_ as native code (via the JVM), and it took about 1500 man hours.
My point is simple: For tasks that I know in C++ that are natural to do in Java as well, Java has a significant edge for me in terms of productivity.
At the same time, there are many projects that I would not undertake in Java, and would choose C++ for. Those projects over time are being confined to smaller and smaller segments of the industry, such as hardware drivers and operating systems.
> Quite educating. Somehow I thought sloppy code was a
> consequence of poor programming practices and could be
> produced in any language. What else is Stroustrup's fault?
> JFK assasination? Alien abductions?
In terms of my own work, I can say that it is much more difficult to produce bug-free code in C++ than it is in Java, and for equivalent functionality in a system, my own estimate in 1996 as a director of engineering (making a decision to move to Java) was that C++ had 5x the LOC as Java for the same functionality, with the extra 4x (mostly error handling, memory management, etc.) being of no business value, and thus being a liability.
If anything, in retrospect I believe my estimate was low, and that the LOC savings is much higher, but that is likely because with Java we ended up doing things that we would never have attempted in C++.
Nonetheless, there are things that you can do in C++ in 10 lines of code that you cannot do in Java. No contest there.
> I really only wanted to point out that the interview topic
> was addressed properly but got dragged instead into
> endless "your language is root of all evil and my language
> is better than yours" discussion.
I spent many years learning and theoretically mastering assembly, C/C++ and Java. They are all "mine".
However, I _enjoy_ Java much more than I enjoyed C++ (and I love programming, and I truly loved programming in C++ .. until I met Java ;-).
> So, I agree to disagree with you Java-guys.
I'm actually a Scala guy now. Someone mentioned it earlier in this thread, and it sounded like a hot new trend, so I jumped right on.
Those Java guys don't know what they're missing ;-)