
Lambda functions and closures added to C++ - nickb
http://herbsutter.spaces.live.com/blog/cns/
======
DanielBMarkham
Lambda functions and closures in C++. E-gads man! Wasn't the language complex
enough already!

I have to say: I love it. C++ has always been my favorite language that I
don't program in. It's like kung-fu for programmers. You can attack any
problem. But most times we don't need kung-fu.

There's nothing like "getting in the zone" with a good C++ program. It's a
thing of beauty. And if you're doing stuff that you have to use the tool, like
writing drivers, low-level stuff, doing some "break the rules" programming,
it's the best there is. I wrote a shell extender for windows many years ago in
C++. I got to change the desktop and file system to work the way I wanted it
to. Very neat stuff.

The sad fact is that most of the time you can make more money writing
something with a much higher level language. And you can make it faster and
adapt to the market faster. So C++ is a tougher language to use for startups,
in my opinion (although it is still my favorite)

Can you imagine the trouble you can get into with macros, lambda functions,
and unsafe pointers? How about throwing i some operator overloading? It's like
a playground for nuclear weapons.

~~~
mynameishere
C++ is a pita and it's no surprise that it's actually the highest compensated
language to work in, at least here:

[http://www.indeed.com/salary?q1=lisp&l1=&q2=c%2B%2B&...](http://www.indeed.com/salary?q1=lisp&l1=&q2=c%2B%2B&l2=&q3=java&l3=&q4=c%23&l4=&q5=python&l5=&q6=ruby&l6=&q7=smalltalk&l7=&q8=php&l8=&q9=cobol&l9=&q10=perl&l10=&q11=haskell&l11=)

I suppose the reason is that it can only realistically justify its existence
at the bleeding edge (eg, with graphic engines, drivers, etc) where the work
is inherently difficult as well.

------
pmjordan
I don't know, a lot of the stuff they are doing in C++0x seems to be of the
"throw more syntax at the problem" kind. This is probably one of the better
changes (along with the "auto" type inference and a bunch of library stuff)
but I can't help but think they're at a bit of a lost cause.

If I was to try and "save" C++, I'd probably start from scratch on the
template system. Really though, then I'd just end up with a idiosyncratic
though type-safe implementation of Lisp macros.

Don't get me wrong: I've invested so much time in learning C++ and perfecting
my skills in it that it makes me wish that I wouldn't be saying this, but
every time I have to touch C++ I get "that sinking feeling". (languages I'm
spending more time with these days: various Lisp dialects including Clojure;
Ruby; Java/C# if I have to)

Oh, and live.com doesn't seem to work properly on Opera. Nice.

------
uuilly
C++ is like French. There are lots of idiosychrasies. Bad syntax leads to an
inexplicable reaction (from the complier or Frenchman.) For the first few
years you'll sound like a buffoon. But once you get the hang of it, it rolls
off the tongue. And once you master the slang, you can say things REALLY fast
and very few will understand you. I for one welcome this awkward new grammar
and its unforgiving compiler errors. Vive Le C++0x!

------
BrandonM
Without proper garbage collection, aren't closures just another memory leak
headache?

------
timr
'Bout time. The need to declare functor objects out-of-line to use the STL
algorithms is a huge contributor to code clutter in C++.

The addition of inheriting constructors is also a good thing -- I wish I could
have back some of the hours I've spent re-writing default constructors for
deep class hierarchies.

------
cheponis
Does anybody use C++ anymore? I use Python and, when doing embedded
programming, C (and maybe a pinch of assembly).

I'm playing with Arc.

I suppose people who write Microsoft apps may still write C++ but most of them
have moved to C#.

~~~
trevelyan
I use C++. Garbage collection is nice, but slow. The language is not suitable
for web development, or for GUI development, but it's great for backend
enterprise software/libraries that need to be fast and stable and compile
across most architectures out there.

~~~
kingkongrevenge
> The language is not suitable for web development, or for GUI development

WTF? Are you aware of the ridiculous number of examples in both?

~~~
trevelyan
If you want to do web development or develop a GUI it's easier and faster to
work with another language.

------
msg
C++ here reminds me of Perl, the postmodern language. There are tradeoffs
between legibility and power, but never for the sake of safety or artificial
consistency.

"How does Perl [C++] put the focus onto the creativity of the programmer? Very
simple. Perl [C++] is humble. It doesn't try to tell the programmer how to
program. It lets the programmer decide what rules today, and what sucks. It
doesn't have any theoretical axes to grind. And where it has theoretical axes,
it doesn't grind them. Perl [C++] doesn't have any agenda at all, other than
to be maximally useful to the maximal number of people.

...

Many modern computer languages aspire to be minimalistic. They either succeed
in being minimalistic, in which case they're relatively useless, or they don't
succeed in being truly minimalistic, in which case you can actually solve real
problems with them. A number of languages give lip service to the idea of
minimalism, but merely sweep the complexity of the problem under the carpet of
the programmer. C is a minimalistic language, but only if you don't count all
the libraries that are necessary to use it usefully. C++ is obviously not
trying to be minimalistic. Unix is considered by some to be a minimalistic
operating system, but the fact of the matter is that if you think of Unix as a
programming language, it's far richer than even Perl. Perl is, by and large, a
digested and simplified version of Unix. Perl is the Cliff Notes of Unix."

<http://www.wall.org/~larry/pm.html>

~~~
mleonhard
Perl needs to go back to 1995 and stay out of my century.

It's good to let computers do what computers are good at: repetitive, boring
tasks. That's why modern languages detect typos and report them to the user.
Perl accepts most typos as valid and makes the programmer do the boring work
of analyzing the syntax for correctness.

I'm bitter about wasting 30 minutes tracking down a bug because perl accepted
'if(!$string_generator1-() || !$string_generator2->()) {...}' as valid syntax.
This kind of thing happens to me very often when writing Perl programs.

I think that C++ and Perl are _very_ different. Perhaps their most important
similarity is that they're both older languages. At least C++ is making
progress, while Perl seems to be embracing its backwardness.

------
PieSquared
Whoa. Is this a good thing... or a really bad one? Not sure. C++ is
complicated enough. Then again, CL is pretty complicated too, yet it's what I
would qualify as a beautiful language.

I personally feel that C++ is a language that doesn't truly belong anywhere -
it isn't pure, clean, and low-level, like C, and it isn't completely high-
level. Somehow, I don't think that you can easily 'mix' these two. I'm mildly
surprised that they haven't added an optional GC yet - I seem to remember
reading somewhere that even Bjarne Stourstrop advocated one.

Maybe, instead of making "C++0x", they should just make D an ISO standard...
From what I've seen, D is basically C++ cleaned up, and every time I look at
it, I want to use it instead even more. Check it out if you haven't already.
And it deals flawlessly with legacy C++ and C code, too, so there's really not
many reasons to avoid it.

Oh, and C++ templates are just ugly. I'm reminded of them whenever I see Java
generics too, and let's just say those aren't too nice on the eyes either.
Maybe they should add programmatic macros too. And a pinch of Perl's default
variables!

------
pg
They should just use the closed form solution.

------
xirium
C++0x ? This must be an April Fool.

Edit: No, the truth is stranger than fiction. Gads!

------
huhtenberg

      for_each( w.begin(), w.end(), []( const Widget& w ) { cout << w << " "; } );
    

It's lovely to know that this is possible, but if anyone who ever writes a
_production_ code like this needs to be shot on a spot. Some of the Brainfuck
programs are easier to read than this ... and, yes, I have been using C++ as a
primary development language for over 10 years.

