Saturday, October 23, 2004

I hate C++

I hate C++, no, really. I've been a C++ fan since I started programming in 1991 and learned about it from a friend, Brian McDonnell, who worked on CLIPS for NASA and was a big OOP fan. It was the first language I learned (in tandem with "C") by mistaking the ARM for a more complete textbook ("annotated") rather than the compiler-writer's guide that it was. And that led to the dragon book as my third computer science text. A rough way to start, but very fun, and Larry Wall is spot on about the value of hubris.

Enough about me.

What happened to the joy of C++? And wasn't the moo book a gas? Clearly I enjoy the stuff. But now I hate C++. The explanation is easy: tools.

After a solid year of Java at its finest, returning to C++ and no good unit test libraries (cppunit being about it), no mock objects, no IDEA or decent Eclipse support, no ant or maven, no good coverage tools, no good code analysis, no good dependency analysis on and on and on. Tools make the programmer. And C++ has dog food for tools compared to the wealth of open-source projects for Java. Now that I'm working on a C++ project, my development efforts are at least doubled for the same work, and I continually feel that I am leaving imporant parts of best practices out of the picture. Nor does it look like that's about to change anytime.

And that is why I hate C++. Goodbye, dear friend.

7 comments:

Emerson said...

An interesting, though perhaps not original sentiment. I often wonder why so many people hate C++ with a passion. Yes some of it is the tools, but i can't say i agree thats the only only cause. After all, plenty of people still hated it before IDEA or Eclipse or MockObjects existed.

As someone who uses C++, Java, and C# indiscriminately, i believe that the issue is often confused. When a lot of people say they hate a language what they really mean is that they hate the API, or in the C++ case, the lack of API.

Unlike Java and C#, C++ doesn't have a standard unified set of objects which allow you to hit the ground running. Instead it has the standard C runtime and the standard template library (STL), neither of which are particularly nice to use or even relevant when faced with todays programming challenges.

I genuinely like C++, as an expressive OO language i believe that it is still unmatched.

Unfortunately i think that 80% of all code written in all languages is throw away. And the code that isn't doesn't owe its quality to the syntax in which it is constructed.

Code quality comes from abstraction and clarity of thought. No tool will make a bad programmer good and a good programmer can write good code with or without the tools. The tools just make it easier.

As long as you have some way of getting an overview of your architecture and the OO relationships that are presented therein you can write good code.

Anything beyond that just enables you to write good code faster. And in some cases having advanced tools can actually encourage bad code. If you've never had to use VI to ^I edit > 1K ^Esc lines of code you've never have to worry about how clean and well ordered your objects are, or how consistent your naming is.

I don't want a tool that does the thinking for me, i want a tool that helps me do more thinking and less repetition.

It frustrates me no end that so many Java programmers just don't know how to program. When you start debating the usefullness of inheritance in a language which is built on a single polymorphic base class then you probably need to pick up a textbook and start reading or use the "deligate the programming to someone who knows what they are doing pattern".

Brian Oxley said...

I appreciate your comments. I've always been a C++ fan and there's lots of things about Java which absolutely sucks. But after a while working with great tools and a mediocre language, I'm surprised to find it so painful to work with mediocre tools and a great language.

Anonymous said...

In fact, many of these kinds of tools *are* available for C++.

For example for Ant there is now a CC task so you can compile C++ files: http://ant-contrib.sourceforge.net/cc.html

For C++ code coverage there are numerous commercial tools like the one from Numega: http://www.compuware.com/products/devpartner/1587_ENG_HTML.htm

Eclipse does have some plug-ins for C++:
http://www-106.ibm.com/developerworks/opensource/library/os-ecc/?ca=dgr-ln

I think one difference is that many of the analogous tools are commercial in C++ rather than open source which may be part of why they have not been widely adopted.

Another explanation is that the C++ developers are more ornery and hetrogeneous than the Java community. Hell, there is not even agreement on standard libraries for standard things like database access, multi-threading, graphics, gui, the list goes on. One of the big things that Java and Perl have going for them is more widely adopted standard libraries.

Anonymous said...

actually Eclipse CAN be used for both C and C++ afaik.
And it's actually pretty good at it.

Anonymous said...

> I genuinely like C++, as an expressive
> OO language i believe that it is still
> unmatched.

It's just because you and many others know nothing about Ada and how expressive Ada is.
The only area C++ is not unmatched in is a buggy software. I've got sick and tired hearing that nothing's better than C++ from lemmings writing then their software with buffer overflows.

Popularity is not directly tied with quality. Ada vs. C++ is a very good example.

In fact, it'll be a great step forward to replace C++ with Ada.

Anonymous said...

stfu about wow gold I dont care already pissed off enough with this c++ course and the stupid confusing loops.

Anonymous said...

I must agree on the Ada point. I programmed in Ada for a number of years now for my work. At first I hated the switch from C++ to Ada (standard resistance to change). But after seeing how much easier it is to express your concepts in Ada, how much more readable it is, how much less time debugging yours AND others code (next to zero compared to C++), the ... I can't imagine having to program in C++ again. And with other great languages such as Python and the simplicity of web programming for GUIs, the need for C++ will hopefully diminish. And the great proclamation of add "r-value reference declarators" in the cxx05 standard only goes to show how much this language has gone off the deep end... Have you used your r-value reference declarator today? ;-)