News for hackers. Stuff that matters.
Re:Why C++ is not my favourite language by dtf on Friday August 28, 2009 @12:44PM (#791709)
I guess he's not a systems programmer. What language did Slava Pestov turn to when he recently re-wrote Factor's VM?

C++ programmers: we do the dirty work so you don't have to.

Re:Why C++ is not my favourite language by Legion on Friday August 28, 2009 @12:51PM (#791723)
Indeed. So many of these articles can be boiled down to:

"As long as we limit the comparison to things (our language) does well, and exclude things C/C++ do that (our language) can't do at all, (our language) totally 0wnz C/C++".

Re:Why C++ is not my favourite language by acg on Friday August 28, 2009 @01:22PM (#791800)
Hardly, I know many people who spent years learning C++ in the 90's only to avoid it now. The reason is they had no love for the language. The C++ language design has serious flaws that whenever someone brings them up there's the usual, rolling of the eyes and the "yeah we know" sort of look. The if you criticise you must be a dumb attitude is encouraged by the C++ community too, and that was not borrowed from the C community: where the emphasis was beautiful tight code (like the K&R manual itself).

Lets face it C++ is something like 30 years old this year. For a 30 year language to have so many flaws, and for newer languages to make a better job of integrating OO while still keeping the power: you have to ask whether the C++ community really knows all about technology and nothing about design. The whole project has been mislead from start to finish. It strikes me it had to take a couple of ada programmers to write the STL.

Re:Why C++ is not my favourite language by dtf on Friday August 28, 2009 @01:44PM (#791851)
C++ hits a certain sweet spot. In some cases - whether you like it or not - it's just the right tool for the job. Two examples I can think of are:

* VM implementations (I mentioned Factor, but also HotSpot, Microsoft's CLR, SquirrelFish, TraceMonkey, V8 and Opera's Carakan are all high-performance VMs written in C++ (x). Note also that all major layout engines are written in C++. Complex but fast and highly-tuned beasts)

* Production rendering. PRMan, MentalRay and pretty much every other renderer in day-to-day use on film and video post-production are written in C++.

People who write these systems care deeply about performance. They'll dip into assembly when they have to. While fast, C won't cut it because in these cases, it doesn't give you enough abstraction to avoid making your code a mess (strong typing, operator overloading and templates in particular, but also virtual method dispatch)*. I'm sure if you ask them, they'd tell you that they'd love to use something nicer and more modern. But it doesn't yet exist.

This is not to say that C++ is the right tool for writing web applications, or even the average desktop application, or even - increasingly these days - games. But somebody needs to write the stack underneath, and that stack needs to be fast.

(x) note Mono as an example of a VM that sticks with C. But it contains a lot of object-oriented shennanigans that probably could be better expressed in C++, and the core developers came from a strong C culture.

Re:Why C++ is not my favourite language by eru on Friday August 28, 2009 @04:39PM (#792240)
How about D? A friend of mine uses it as a better C++ for mathematical programming (optimization, graphs and so on).

Perhaps nobody would have invented C++ if D would have come earlier.

Re:Why C++ is not my favourite language by dtf on Friday August 28, 2009 @05:11PM (#792299)
Yes, D shows a great deal of promise. Maybe I'm short-sighted, but at the moment it's the only language I can see being a viable replacement for what C++ does well. D was invented by Walter Bright, after he had written a C++ compiler (and somehow kept his marbles). I think it was his take on a better C++. Quite a few other clever people have jumped on board to help with the design since.
Re:Why C++ is not my favourite language by acg on Friday August 28, 2009 @01:55PM (#791871)
Two things:

- Of course there are lots of good things written in C++, there are also lots of dreadful things. This is not a reflection on the language so much but the talent of the developers involved. If nothing good had been written in the language in the last 30 years then it would be a real disaster.

- C continues to be used for very large projects, you only have to look at linux. One of the problems with C++ is the amount of bad programming there is. Perhaps this is because such poor examples are given by the in the Standard C++ Programming book.

There is of course objective-C, I wonder whether the first version of Doom was objective-C: there is a high possibility given it's NextStep lineage.

I'm not sure if I'd go this far but have your read: http://thread.gmane.org/gmane.comp.version-control.git/57643...

Re:Why C++ is not my favourite language by dtf on Friday August 28, 2009 @02:15PM (#791912)
I think the Doom engine was written in C (and assembler), but the level-editing tools were in Objective-C. Again, the right tool for the right job - Objective-C's dynamic dispatch greatly helps user interface programming compared to bare C, whereas the Doom engine probably had no need for it.
Re:Why C++ is not my favourite language by ilyak on Friday August 28, 2009 @01:31PM (#791830)
Please never, never, never ever write C/C++.

С - simple and stable, C++ - huge and changing. C - portable and easily parseable, C++ - unpredictable and unparseable. C - good, C++ - bad.

Re:Why C++ is not my favourite language by acg on Friday August 28, 2009 @01:40PM (#791844)
I hear good stories about D from colleagues:

http://digitalmars.com/d/2.0/overview.html

Re:Why C++ is not my favourite language by dtf on Friday August 28, 2009 @02:29PM (#791955)
D's great for at least two reasons:

1) it set out to be a no-compromise systems programming language

2) it's being designed by people with an deep and intimate knowledge of C++ (Walter Bright wrote a C++ compiler - no mean feat, and Alexander Stepanov was Mr STL)

These guys know the good, the bad and the ugly of C++ much better than most. From the stuff I've seen so far (check out Stepanov's presentations on an iterator-free STL, or adding functional purity, and also look at the work on making floating point more rigorous) this could finally be a worthy successor.

Re:Why C++ is not my favourite language by eru on Friday August 28, 2009 @04:44PM (#792250)
3) You can declare functions to be pure. A lot of optimizations become possible.
Re:Why C++ is not my favourite language by Legion on Friday August 28, 2009 @04:04PM (#792170)
Actually, my reason for writing "C/C++" was simply because they're the two languages I see targeted by articles like these. It wasn't to lump them together as one; it was like writing "Ruby/Python".
Re:Why C++ is not my favourite language by polos on Friday August 28, 2009 @01:49PM (#791860)
So, you don't use a C++ compiler for your C code?

The old C infrastructure is really outdated already -- you can use C and a very limited subset of C++ (without OO), and be perfectly happy.

Re:Why C++ is not my favourite language by ilyak on Friday August 28, 2009 @04:45PM (#792257)
No, I'm using GCC.

How's it outdated? Linux kernel is written in it.

As for limited subset, people would push and push the boundaries until your code grows fangs and horns

Re:Why C++ is not my favourite language by UncleOxidant on Friday August 28, 2009 @02:23PM (#791937)
It seems like a language like OCaml could do quite well in the VM implementation space: it has very low-level imperative constructs that can be used to optimize, yet also has very good features that allow for generic programming (modules, functors, type inferrance).