
G'day all. On Sun, 2008-10-19 at 23:08 +0200, Achim Schneider wrote:
I'm asking 'cos I'm learning C++ and can't get the proper motivation to do any program I can think of in it: If I need abstraction, I'm thinking Haskell or Scheme, and if I'm thinking performance, C itself more than suffices.
Unless I'm working on a platform where memory is so tight that I
can't afford the cost of vtables, EH, RTTI and extra stack usage,
I always prefer C++ to C. Always. On the sorts of CPUs you find
on desktops and servers, and even most embedded platforms these
days, there is no advantage in using C over C++, and significant
advantages in using C++ over C.
The trouble is that C++ is a tool that's hard to use well. But that's
why they pay us the big bucks, right?
Quoting Derek Elkins
I tend to use C++ whenever I strongly care about data representation (which is admittedly rarely.)
Indeed. Having said that, type families mean that Haskell now gives you much finer control over data representation, though still not fine enough for many applications. The more general thing is that C++ gives you fine control over resources. Resources appear and disappear at predictable times, which in some applications is important. My last point is that C++ has a lot more tool support: compilers, libraries, frameworks, refactoring browsers and so on. Cheers, Andrew Bromage