l33tminion: Sporktacular (Spork)
Sam ([personal profile] l33tminion) wrote2008-06-05 10:30 pm
Entry tags:

Defective C

In the classroom, C++ seemed like a modern language. When I took Java, I thought it seemed rather like C++. When I took C, I thought it seemed rather messy. When I saw C++ again, this time in real code, I was shocked. Every time I've seen C++ code in actual use, it seems far more messy and incomprehensible than Java or even C. Brushing up on C++ for work, I've come to agree with the author of the C++ FQA: C++ is a horrible language.

An interesting question: How critical should a programming reference / guide / source be of the language it discusses? One of my favorite programming books is Effective Java, which I feel improved my Java skills immensely. That book contains a very detailed account of all the weaknesses of Java and notes patterns to avoid copying from the Java standard library, yet the book is very positive about Java as a whole. I'm just starting a book called Let Over Lambda, whose author apparently thinks lisp-style macros are the very definition of win, and it's very interesting so far. And the above FQA is proving quite useful in getting myself reoriented for hacking C++.

[identity profile] takumi.livejournal.com 2008-06-06 06:43 pm (UTC)(link)
C++ is only as good as the author(s) writing it. C++ is not for everyone. You have to put a lot of thought into your design and pay attention to details. You can write some very powerful and efficient programs in C++ that most "modern" languages cannot come close to. In the end, it's all about using the right tool for the right job. For example, Java makes great server side applications, but I have yet to find a client Java application that didn't piss me off due to its lack of performance and being a massive resource hog. :) We use Ruby on Rails for our web application because it's very database intensive, which lends itself well to Ruby, but it might not be the best choice for everyone's web application. etc etc.

[identity profile] takumi.livejournal.com 2008-06-06 09:42 pm (UTC)(link)
And be less readable and maintainable. :)

[identity profile] takumi.livejournal.com 2008-06-06 10:57 pm (UTC)(link)
See above point. C++ code is only as good as the author(s) writing it. Well designed C++ code is very readible and maintainable. Problem is, most "C++" programmers are anything but. They're really C programmers for the most part.

[identity profile] takumi.livejournal.com 2008-06-06 06:45 pm (UTC)(link)
Also, you might consider using Qt (www.trolltech.com) in conjunction with your C++. It's an awesome cross-platform library.
ext_81047: (Default)

[identity profile] kihou.livejournal.com 2008-06-10 08:46 pm (UTC)(link)
The thing with C++ is that you can do anything dumb you can do with C, and you can do all sorts of new stuff. It's very hard to add features without increasing the potential for them to be used poorly.

I think being able to be critical of something even if you support it overall makes you more useful and believable in any situation. Nothing is perfect, so if you don't address drawbacks or tradeoffs, you don't present a complete picture. Of course, I much prefer teaching programming with a language than teaching a programming language without the greater context of programming.
ext_81047: (Default)

[identity profile] kihou.livejournal.com 2008-06-10 10:29 pm (UTC)(link)
Lisp macros are certainly better than C macros or turing-complete C++ templates, though I haven't used them enough to have much of an opinion on them. (My crazy-scheme-course was mostly template free.) I think the big thing with C++ is that it tries to do everything when a lot of what it was trying to do wasn't well understood at the time, plus backwards-compatibility baggage. I do think that a lot of the problems they point out are directly or indirectly caused by backwards-computability fish. *shrug* I'm still a fan of the concept of C++ templates (I like compile-time error checking (which has led me to abuse C++ templates for static asserts in the past)), and operator overloading when operators exist. C++ is, however, probably the only language I like to use that I wouldn't want to teach anyone. Unless you count LaTeX programming.