February 05, 2004

I'm A C Double-Plus

Whenever I see "C++", I can't help but think of "Brave New World" and the "Alpha Double Plus" social strata. I'm not sure why I make that connection, but it's always there. I know, I know, the "++" is the postincrement operator...I get the pun, but I never think of it that way. It's interesting how this one-cut-above C mentality is so relavant to C++.

The most interesting thing about C++ is the incredible tension created by having an object-oriented language that worships efficiency. Kevin's comment on C++ culture prompted me to think more about this. C++ values the raw, no "frills" approach. The language is constructed so that you know where every CPU cycle is going. Hm...I have a "virtual" keyword, that will cost a few extra cycles and a slightly bigger footprint. Hm...I'm using "new", so the object will be on the heap instead of the stack and the memory will take longer to allocate. Even "iterators" are glorified pointers, not first class objects. Case and point...see how long it took for "string" to be a fundamental part of the language.

Whereas other languages focus on the programmer, C++ focuses on the binary code that will ultimately be produced. Rather than the language being an expression, it's a bitwise specification. Rather than allowing the compiler to choose anything for you, you must choose it all yourself.

Here lies the tension. Fundamentally, object-oriented programming cares more about the way code is expressed than executed, but C++ cares so heavily about execution. I think this is why Java is such a popular alternative to C++. With Java, you get very reasonable execution speed without the agony of dealing with a specification heavy language such as C++.

Remember, programming languages were created for man, not man for the languages.

Posted by enigma at February 5, 2004 06:49 PM
Comments

Certainly--the whole idea with C++ was that you could use as much or as little OOP as you want based on your needs, as opposed to other OOP languages at the time.

It comes back to what you consider "reasonable execution speed". I'm all in favor of making the computer do more work... that's what it's there for, after all. But the "computers will soon be fast enough that the performance won't matter" argument is a very old one and doesn't show signs of settling soon.

At my last job one of the teams worked on a Java-based web app to manage network elements. The project ran into a number of significant issues, performance among them; and this was before we even got to the point of asking how well it would scale (yes, yes, it's anecdotal).

Specifically regarding Java, I think I dislike it so much simply because there's a "Java way" to do everything--and they impose unecessary limitations to keep you contained within their paradigm (for example, Java is rather pedantic about what it considers to be a valid boolean type). It's always seemed rather dogmatic and puts me off. I lean towards the Perl philosophy when I want a language created for man (as a counter-example, the Perl concept of "truth" is much more flexible (and hence somewhat complicated, but that's life, right?)). Perl can be dogmatic too, but there are so many dogmas to choose from!

That comes back to balancing needs and appealing to taste, which both fit conveniently under that broad idea of programming culture.

Also, I'd argue that OOP is more data-centric than code-centric. However, in light of your point this is a trivial semantic distinction.

Posted by: Kevin Worcester at February 6, 2004 01:15 PM
Post a comment









Remember personal info?




Type in the security code: