Live data from Hacker News

C++11 FAQ

stroustrup.com

91–100 of 121 posts

Re: C++11 FAQ

#91

Earlier quoted context omitted.

This is perhaps one of the more unexpected opinions on C++ I've encountered. When I picked up C++ with Turbo C++ 3.0 in the early '90s, it was already widely regarded as an over-complex behemoth. Donald Knuth said of it in 1993, "Whenever the C++ language designers had two competing ideas as to how they should solve some problem, they said 'OK, we'll do them both'. So the language is too baroque for my taste." The la…

Arguably the std::move stuff and the semantics around it have added uncomfortable complexity to the language, even if it might have been necessary. Other than that I think other advances in C++11 and beyond have made for a quite nicer language to work in. I love C++11 and use it every day, but I think putting references in the language was an 'original sin'. They should have stuck with C's model: it's either a value…

No, the original sin was C's and it was the use of a separate "arrow" operator for accessing fields of a struct through a pointer. Other languages (C#, Java) successfully avoided that. C++ references allow templated code to be agnostic of whether an object is given by value or by reference, because the syntax is now more uniform.

Re: C++11 FAQ

#92

Earlier quoted context omitted.

Surely references have intrinsic value to the programmer? They're a pointer that can't be moved or rebased. Other languages have only references, and in C++ you can use that convention and not have any extra confusion.

References are crazy. There's no simple guideline to use them safely. Check this out: const string& s = max ("a", "b"); cout Standard types and functions, const references, no warnings, everything by the book. But it crashes. There's a similar can of worms related to slicing (treating Derived* as Base* is silently unsafe because arrays and copy constructors exist). C++ is scary.

Works for me in both C++03 and C++14? https://ideone.com/KhfGaN

Re: C++11 FAQ

#93

Earlier quoted context omitted.

I started with C++ around '92, but you are right, C++ was already complex back then, but it was still manageable, you could, sort of, hold its larger picture entirely in your head and still had some elegance to it.

1992 was just the year MFC came out. I would go as far as saying that C++ of the early '90s was at its Nadir of inelegance. I'd go as far as saying that C++ frameworks of the early 90s were the absolute nadir of elegance. STL only started getting into compilers around '95, so we had no standard containers and dozens of different string implementations. The only part of the standard library widely available was iostre…

> 1992 was just the year MFC came out.

Ignoring the nice work of PowerPlant , Turbo Vision and Object Windows Library, because they were too high level for C devs.

So Microsoft ripped off their Application Frameworks (Afx) prototype and we got MFC instead.

Re: C++11 FAQ

#94
post #81

Earlier quoted context omitted.

1992 was just the year MFC came out. I would go as far as saying that C++ of the early '90s was at its Nadir of inelegance. I'd go as far as saying that C++ frameworks of the early 90s were the absolute nadir of elegance. STL only started getting into compilers around '95, so we had no standard containers and dozens of different string implementations. The only part of the standard library widely available was iostre…

> I would go as far as saying that C++ of the early '90s was at its Nadir of inelegance. Yup. '92 C++ was what gave Java such a boost. If we'd somehow started with '98 C++, or better still C++11, Java might never have picked up so much momentum.

Java picked momentum because in 1996, ANSI C++98 wasn't a thing, each compiler was catching up with the standard and many library vendors just gave use C libraries with us having to write C++ wrappers ourselves.

Also in 2000 I was writing K&R C on a HP-UX compiler, let alone the state of C++ compilers for writing portable code.

Re: C++11 FAQ

#95
post #4

Earlier quoted context omitted.

some of the pain points you refer to, esp move semantics, bring a lot of additional performance to the table. Would you feel the same way about C++ if you started now and only had to learn a clean C++11 subset going forward ?

One of C++'s most glaring problems is that everybody only ever uses some subset of some version of the language, but you still need to know basically the entire massive, monstrous language because not everybody uses the same subset and you need to be prepared for anything. On top of that, you're lucky if your employer or potential recipient of contributions (e.g., FOSS project) or whatever has actually codified the s…

It applies to most mainstream languages, even Python has subsets.

Re: C++11 FAQ

#96
post #84

Earlier quoted context omitted.

> A new operator perhaps. That'd invalidate a lot of programs. Just like how the new _ operator in Java is killing a lot of code right now. Every symbol that can be used... has been used. "Move" is the meaning of the operator in any case. Its no less readable than say... Python's __lshift__ or __add__.

AFAIK, _ isn't an operator in Java ( http://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#... ). The language does allow _ to be used as a separator in numeric literals. Is there a new operator in some upcoming version of the language specification?

_ is a keyword in Java 9.

Re: C++11 FAQ

#97
post #93

Earlier quoted context omitted.

1992 was just the year MFC came out. I would go as far as saying that C++ of the early '90s was at its Nadir of inelegance. I'd go as far as saying that C++ frameworks of the early 90s were the absolute nadir of elegance. STL only started getting into compilers around '95, so we had no standard containers and dozens of different string implementations. The only part of the standard library widely available was iostre…

> 1992 was just the year MFC came out. Ignoring the nice work of PowerPlant , Turbo Vision and Object Windows Library, because they were too high level for C devs. So Microsoft ripped off their Application Frameworks (Afx) prototype and we got MFC instead.

OWL and TurboVision... now these are names I haven't heard in a long time. I remember the company I interned at was looking for TurboVision programmers at some point, none were found, soin a true Russian fashion they just wrote their own clone of it.

Re: C++11 FAQ

#98
post #55

Earlier quoted context omitted.

I've often wondered how anybody manages to teach C++ today. I love working with the language, and I understand the reason behind many of the features, but I can't help but feel like it would be impossible to teach to beginners.

"...but I can't help but feel like it would be impossible to teach to beginners." So a relatively easy way to learn C++ is as an 'upgrade' to C, starting of with picking the parts of the language that help you the most: * you start by already knowing C, but maybe not feeling super productive, using it as structs + functions * you set up the C++ compiler (most modern version available), and just continue writing C * y…

RAII, not RIAA :)

RIAA (https://www.riaa.com/) is the ebil music recording capitalists :)

Re: C++11 FAQ

#99
post #92

Earlier quoted context omitted.

References are crazy. There's no simple guideline to use them safely. Check this out: const string& s = max ("a", "b"); cout Standard types and functions, const references, no warnings, everything by the book. But it crashes. There's a similar can of worms related to slicing (treating Derived* as Base* is silently unsafe because arrays and copy constructors exist). C++ is scary.

Works for me in both C++03 and C++14? https://ideone.com/KhfGaN

Your code is not the same as my code and you're probably new to C++. I suggest trying two changes:

1) Replace max("a", "b") with max("b", "a"). Run it, look closely at the result, and be enlightened.

2) Replace max("a", "b") with max("a", "b"). Run it, look at the result, and be enlightened in a different way.

As a small hint, your code invokes unspecified behavior, while my code invokes undefined behavior.

If this exercise doesn't put the fear of C++ into you, then I don't know what will :-)

Re: C++11 FAQ

#100

I've been programming for money for over 20 years and I grew up professionally writing C and then half-migrating to C++, because the latter very naturally captured lots of C patterns and allowed for more succinct expression of the same. It was lean, expressive and elegant . Just needed a bit of Lisp-y closures and it would've been perfect. And then things got completely out of hand. Elegance was nuked from the high o…

This is perhaps one of the more unexpected opinions on C++ I've encountered. When I picked up C++ with Turbo C++ 3.0 in the early '90s, it was already widely regarded as an over-complex behemoth. Donald Knuth said of it in 1993, "Whenever the C++ language designers had two competing ideas as to how they should solve some problem, they said 'OK, we'll do them both'. So the language is too baroque for my taste." The la…

> I find C++ today to be far simpler, more expressive

That is logically impossible, since it hasn't removed anything.

The myopic mantra "just don't use what you don't like" breaks down as soon as you work in a team, where you don't dictate what other's cannot use (let alone what code they inherit).

Post reply on HN