Live data from Hacker News

C++: The Documentary

herbsutter.com

91–100 of 334 posts

Re: C++: The Documentary

#91
post #11

It's surprising that C++'s development trend continues. When a game or program is made with C++, it's usually nice because performance is mostly guaranteed. But if someone told me to write C++ myself, I'd cry. There's too much to memorize, and the standards are too varied. When I go to a project site for maintenance and it's a C++ project, I instantly lose energy — because it's just too difficult. I'd be happy if som…

Personally I don't find programming with C++ that hard. The downside is it needs a brain warm-up, and this is per project, but once that flywheel is spinning, I find it almost effortless to write code. I have to go through the same warm-up more or less for any language I work with, so it's not that different than writing Python, Go or Java for me.

I agree.

You don't learn or know C++ in the way you learn or know C.

You never have the total language spec in mind. Much of it you will never (and for some of it should never) come across.

The way I think of it

C is an abstraction of the machine, so thin it's nearly transparent.

C++ is an abstraction over programming paradigms, letting you pick how you think.

Everything else abstracts the machine away, replacing it with a VM, runtime, or model of its own.

The same way a good project has a clear model of the problem it should have a clear C++ pattern in use.

Re: C++: The Documentary

#92
post #15

+90% users in the past 3.5 years huh? That is incredible growth. How is it even measured?

You can hear the engineer in that second question. They hear a wild statistic pulled out of someone's ass and ask what is that sticking to the side?

Re: C++: The Documentary

#93
post #41
post #27

Earlier quoted context omitted.

Honestly, I don't expect to find clients here. Fundamentally, you have to trust me to give me work. The amount of money doesn't really matter much to me.

I mean, the lower rates arouse suspicions. The higher you value your work, the more trustworthy you appear to clients.

Thank you for the advice. I'll think about it. Or maybe just remove the price altogether.

Re: C++: The Documentary

#94
post #31

Earlier quoted context omitted.

If you don't use the STL you end up re-implementing it yourself. Usually poorly.

C+ Standard Template Library is the best designed part of C++ library. It was designed by Alexander Stepanov. https://en.wikipedia.org/wiki/Alexander_Stepanov

So, a few things (aside from the whole nomenclature argument already in another reply)

1. Stepanov's generic programming is a good idea. Every language you've seen with "generics" that's his idea, to the extent "The STL" is generic programming, everybody agreed it's a good idea.

2. But the STL is very old now, so while the idea is good, this is one of the oldest (Stepanov had tried this in other languages before C++) implementations and so other implementations are often better, because they've learned from experience

3. As well as pretty good generic algorithms, the STL also provides a lot of container types (what Rust would call collection types) and these vary not between "excellent" and "mediocre" but between "mediocre" and "inexplicably terrifying". The most charitable explanation is that they're just intended for teaching. If you teach DS&A to a Computer Science class you want the Extrusive Doubly Linked List to teach in class. If you write software you almost certainly never need this type, but it's front an centre in the C++ STL.

There's a single "I guess I would use this" container type, std::vector. It has an insane special case for bool, because WG21 are idiots, but it's otherwise a good enough growable array type and it's not worth building your own instead given the constraints.

Everything else is silly, or bad, or both. std::unordered_map feels like a hash table I made in class in the mid 1990s, but it's actually the provided standard hash table container in C++ 11 onwards. std::list is just that extrusive linked list for some insane reason. The Microsoft standard library maintainer STL could not offer me any justification for what std::deque is actually supposed to be for.

Re: C++: The Documentary

#95

Personal opinion: C++ is the most elegant language I have used (for about 15 years). If you are the 'systemizer' type and like to have an extremely precise mental model of the thing you write down to the last bit, nothing beats C++. I acknowledge the limitations and uncertainties that come from compilers etc, but still

> If you are the 'systemizer' type and like to have an extremely precise mental model of the thing you write down to the last bit, nothing beats C++.

I would say the same thing of Rust.

Re: C++: The Documentary

#97
post #31

Earlier quoted context omitted.

If you don't use the STL you end up re-implementing it yourself. Usually poorly.

C+ Standard Template Library is the best designed part of C++ library. It was designed by Alexander Stepanov. https://en.wikipedia.org/wiki/Alexander_Stepanov

It has some very useful principles, but also some super-annoying gaffes and mis-design aspects. One example: Allocators. What a mess! Or the fact that if a map lookup fails, an exception is thrown. I can't count the times I've had some app just bail out on me with an at() exception, because the author neglected to handle it (and the map/unordered map interface did not force them to). That does not detract from Stepanov's important work.

Re: C++: The Documentary

#98

Earlier quoted context omitted.

No it's not. The language keeps growing, with - new features overlapping old features from previous standards without replacing them or deprecating them (function::copyable_function vs std::function, std::less key for transparent lookup in maps) - new features not usable by the layman (coroutines ...) - Cryptic syntax (reflection...) - Stuff you are told not to use because of performance reason and that cant be fixed…

I wonder how many programming languages would be able to devoid of all or some of these problems when they are 40 years old. It's easy to compare new and old languages, and saying older languages are wrinkly. Let's see how other shiny programming languages look like when they are 40 years old.

Python, Java, Lua, Ruby are ~30 years old, Ada being as old as C++.

Sure, none is perfect and they have cruft and warts, but they are not such a mess as C++ is.

Re: C++: The Documentary

#99

Earlier quoted context omitted.

C+ Standard Template Library is the best designed part of C++ library. It was designed by Alexander Stepanov. https://en.wikipedia.org/wiki/Alexander_Stepanov

So, a few things (aside from the whole nomenclature argument already in another reply) 1. Stepanov's generic programming is a good idea. Every language you've seen with "generics" that's his idea, to the extent "The STL" is generic programming, everybody agreed it's a good idea. 2. But the STL is very old now, so while the idea is good, this is one of the oldest (Stepanov had tried this in other languages before C++)…

> There's a single "I guess I would use this" container type, std::vector.

About that one... I would claim that in a majority of cases where an std::vector is used, what the author really wanted was a similar type, but whose size and capacity are fixed on construction and never change. The standard C++ library does not offer such a type - so people use vector because it's handy.

Agree with your takes on most of the containers. I also dislike how optionals are never used with containers as they were standardized later (and even then, problematically w.r.t. references). Thus, for example, if I lookup an object in a map of T's, the result should IMNSHO be an optional reference to a T.

Re: C++: The Documentary

#100
post #71

Earlier quoted context omitted.

I find C++ not hard at all when working with familiar idioms, restrictions and toolings (familiar to me). But it's hard jumping into new codebases and adjusting yourself to new patterns. Recently I did a lot of programming using C++23 Modules and it was a breeze. There's basically dozens of very nice languages inside C++. That can be a blessing or a curse. I'm anxious for Herb Sutter's CPP2/CPPFront to become a stand…

What type of project actually uses C++ 23 modules in real life? What kind of toolchain enables that? When I worked on Chromium, they were indefinitely in the "maybe in 5-10 years the tooling will be ready" camp.

YC startup. Toolchain was Clang and sh.

Chromium is gonna be more conservative than that for sure.

Post reply on HN