

Verity Stob's guide to upcoming C++0x - ableal
http://www.theregister.co.uk/2009/05/07/verity_stob_cplusplus/

======
e4m
I'm not sure why C++ is the butt of so many jokes. Making fun of it just seems
to be the in thing to do. I bet most of the jokers have never seriously used
it.

Personally, I get a lot of use out of C++ and actually enjoy using it. Sure,
it can get complex at times when doing really hard stuff, but it'll force you
to stop and understand the implications of what it is you are doing thus
forcing you to do it correctly.

C++ won't let you get away with half the crap that many other languages will.
Knowing C++ will make you a better programmer in all languages. Try it and
see.

~~~
old-gregg
In this context, first time ever since I joined HN, I'll be brave to openly
say this out loud: _C++ is my favorite language_. Ughh... I did it! :)

A little background: I started coding in x86 ASM (because some idiot told me
that was the only language computers understood when I was 14), switched to
Pascal, then C, then C++, then I got my 1st job as VB6 oracle-to-form data
pusher, then I did 5 years of very exciting C++ library development, i.e.
other programmers were my customers. [highly recommend this - much easier to
market&sell than any other market, learn from DHH, Trolltech or MySQL AB]

In 2002 I moved to higher level languages: Python, some Perl and lots of Ruby
and Javascript. And honestly I'm not _that_ more productive coding Ruby than I
was ever in C++. Yeah, it's nice to read an entire file, break it down into an
array of lines, grep them with some regexp and apply a function on each result
- all that in a single line of code, but... well, read on:

C++ allows for some beautiful _type-safe and performant_ high-level design
constructs that Java, Python or even Ruby can't touch: just combine multiple
inheritance with medium-complexity templates and see what you can do. Only
Haskell gives me the same type-safe, nearly as fast and flexible (yet very
high level) material to build software of. Being a realist, I don't see
Haskell ever "making it" into the industry, but the updated C++ definitely
will.

Duck typed languages are nice, but require _enormous_ layers of unit tests to
protect yourself from stupid things like misspelled variable names or even
renamed/missing code files. Building with Rails without unit testing is a
suicide. Doing Haskell without unit testing is actually isn't that bad. And
this requirement to test the shit out of your code [2-to-1 ratios aren't
uncommon] kills the spirit of exploratory programming for me. Moreover, 200x
speed penalty means that simple O(n) algorithms won't cut it for an average
data set, forcing you to build more complex solutions just because your
language can't scan a big-ass array under 10ms. Moreover, most high-level
languages live inside of a VM, which makes them useless for general purpose
software development: they represent "fuck you" approach, i.e. they'll easily
call your C library, but won't let you easily call them. JAR is as good to me
as my swap file: I can't afford to carry around JVM on my back just because I
want to call your Java code from Haskell or C++.

~~~
ubernostrum
"And this requirement to test the shit out of your code [2-to-1 ratios aren't
uncommon] kills the spirit of exploratory programming for me."

Which is why most of us don't write unit tests when we're in the exploratory
phase of something.

"Moreover, 200x speed penalty means that simple O(n) algorithms won't cut it
for an average data set, forcing you to build more complex solutions just
because your language can't scan a big-ass array under 10ms."

I think that you and I have different ideas of what an "average" data set is,
then, or the performance constraints expected of it. Although given the number
of mathematicians and professional scientists who crunch their data in Python
these days (see: NumPy, SciPy), I'd also suspect that maybe you should
investigate this a bit more deeply.

------
abrahamsen
The learning curve will be less steep with the new standard, even if the hill
is taller. Much of the work on the new standard is focused on making libraries
easier to use, including giving better error messages.

This will facilitate the "Accelerated C++" approach, namely teaching the
libraries first, and the base language later.

The other side of this is that it will likely also widen the gap between those
who use C++ libraries, and those who write them.

~~~
gchpaco
I have grave difficulties believing this, precisely because in the name of
backward compatibility they haven't removed any of the nonsense that made C++
so difficult to wrap one's brain around. Instead, they added even more.

None of the corner cases that make C++ so hard to parse have actually been
removed, so tools are still hard to write and unreliable. Nothing has been
done to allow a user to express where pointer aliasing can occur and, more
importantly, where it cannot, so many forms of important numeric optimizations
are still extremely difficult. There are still at least three languages
possibly intermingled at any given time--macros, template computation (a la
Boost), and regular C++, each with its own style of assertion now. Rather than
relaxing a restriction on type ordering they invented a whole new function
syntax. Managing the variable closure around upward funargs (returning a
lambda) is the programmer's responsibility, with a subtle stack smash if you
get it wrong, or if anything you call with a lambda stores it somewhere behind
your back. Two types of characters aren't enough; now char, char16_t,
char32_t, and wchar_t all coexist. You can now create a const char string two
ways, one of which is UTF-8 encoded and one of which is encoded any damned way
the compiler writer pleases. The raw string syntax, another invention, further
complicates the lexer. Objects now silently need a move constructor in certain
circumstances to avoid silent, behind the scenes copies. You can't even
reliably say "x = y;" any more; operator = can be deleted from whatever type x
is. Rather than put the onus on the (admittedly horribly overworked, due to
the previous crap) compiler writers to constant fold, now we have constexpr,
just like const except different!

This is not a programming language. This is a train wreck. Supposedly this
language is "close to the metal" but even the simplest operations can perform
unbounded amounts of work behind your back (for example, due to implicit
conversions, or operator overloading). This language is consumed with a focus
on the irrelevant.

The Reg article, while very snarky, is not an unreasonable position to be
taking here.

~~~
ableal
That's a bit depressing, but, hey, look on the bright side: now we may get
strong AI out of people trying to generate and parse C++.

Though my bet is still on spam and anti-spam, they have better incentives.

~~~
gchpaco
Every couple of years the part of my brain responsible for making good
decisions shuts off and I start looking at what all is required to parse C++,
and in particular how you parse it in, say, yacc. As far as I can tell it is
done by magic.

With the operator suffix extensions, though, I think C++ has broken new ground
again. It is now the only allegedly serious language that requires a symbol
table to _lex_.

------
jcl
_I mean, next year will surely be too late for an '0x' standard? Actually the
C-plus-plusers point out it could be delayed until 200A, or indeed until
200F._

Yick. Arc may be a "hundred-year language", but if the C++ committee delays to
200A, that would make C++ a six-thousand-year language (8202 in decimal).

~~~
TallGuyShort
Who cares about it representing a year - C++0x is a cool name all by itself!

------
swolchok
Perhaps I misread the article, but isn't it unusually heavy on the snark and
light on content for HN?

~~~
jcl
It's not a bad overview. The Register is snarky by nature.

------
ableal
Seems they're not quite done nailing legs to C++. I suppose it will run
faster, but "easily understandable by anyone with half a dozen brains" is my
take.

[Confession: I once caused the Bell Labs 'cfront' tape to be ordered, and
loaded into unsuspecting Vaxen innocently running BSD Unix, at an otherwise
reputable school. I allege, in my defense, that I mostly used it only as "a
better C" (back then, C did not have function prototypes); and that, at the
time, no other grad students were noticeably (further) deranged by the
availability of C++.]

~~~
old-gregg
Well... I'd say C++ even with these latest improvements is much easier to
grasp than Haskell, for example. The question is if the steep learning curve
can be justified.

I'd say that for some it makes sense. Updated C++ will be a fairly high-level
language with absolute access to bare metal and near 100% compatibility with
C, that's very unique. And the world is in a desperate need for a
_deterministic_ (i.e. _optionally_ garbage-collected) bare-metal replacement
for C for systems programming. D could be it, but Walter just won't let the
community to have some control of it.

Moreover, I suspect some of these improvements around the type system will
allow C++ compilers to generate faster code than C compiler could ever achieve
because programmer's intentions will be better expressed.

I only wish they expanded the standard library more. As far as I'm concerned,
C++ doesn't really have a standard lib: STL is often awkward to use and very
limited, for instance std::string is next to useless and iostream is such a
pain... Then we have Boost, it comes with insane build times, incomprehensible
compile error messages and multi-platform issues, so most C++ programs mostly
fall back to C lib for basics like I/O, or to platform-dependent frameworks
like MFC.

I also hope that external templates will work as promised. In the current
form, templatized C++ works well only in a form of one giant file where
everything is included in the correct order. Perhaps this is why every single
C++ project in my relatively long C++ career has been using the language in "C
with classes" form despite my best attempts to convince people that templates
aren't always evil.

~~~
ableal
True, but it's become a specialist need - like construction machinery and
heavy trucks. I wrote some C++ a few years ago (objects, STL, etc.) in a case
where it had been chosen mostly out of inertia - Python could have been used
with similar performance and less code (and did get used afterwards for other
cases).

Speaking of Python and C++: possibly some of us would wish to write Python and
get C++. Mark Dufour has been persistently plugging away at a Python-to-C++
compiler (and welcomes help): <http://shed-skin.blogspot.com/>

~~~
old-gregg
If you avoid web programming and SQL-heavy enterprise development C++ is very
much mainstream and wouldn't call it a specialist need. Actually, the kind of
open source projects I enjoy to tinker with [when not at work] is all C/C++:
Qt, Webkit, SQLite, various compilers and interpreters, search engines, etc.

~~~
dchest
SQLite is written in C.

------
Bjoern
For all you C++ fans out there, you will find this enlightening.

<http://www.jwz.org/doc/worse-is-better.html>

------
jcromartie
C++0A... I love it.

