Hacker News new | ask | show | jobs
by hellofunk 2109 days ago
> it has become obvious that learning and using all of C++ is beyond impractical.

Doesn’t really make sense why you’d want to anyway. Why would you want to use all of any language? C++ offers so many features because of its extraordinary flexibility and application to a wide range of domains. Unless you’re writing an app that is a game that also trades high frequency transactions on the financial exchange, while performing physics simulation and 2-D vector rendering, all while serving up a Web server, it would not make sense why you need to use all of the language. It’s perfectly fine to find those parts of a language that you are personally interested in.

4 comments

I find I need to learn it all because I write code that interacts with other code. I find myself reading example code that uses advanced C++ constructs, or sleuthing though a 3rd party library to understand it. Every time I find a library with a "modern C++" take on a problem (json parsing, etc.) I know I am going to have to dust off my knowledge and even learn something to make use of it. Very high cost. It is just a tough ecosystem to exist in as somebody who isn't 100% c++.

I remember starting out with Python and only knowing a subset of it, but as soon as I started writing real apps that interacted with the larger Python ecosystem, I found myself having to learn the full language (or at least a lot more than I did writing my own isolated code).

All the template SNIFAE stuff hidden in highly generic libraries for is going to become quite simplified with C++ 20 concepts. Also, to be honest, it wasn't _all_ that complicated as long as you kept a few patterns in mind.
The set of features a language provides is part of an unwritten contract:

We write our code such that it minimizes the amount of effort to read it, under the assumption the reader knows the language.

This way, it makes sense not to use a library for something that can already be cleanly expressed by the language because this introduces additional mental overhead for the reader.

Yet is doesn't make sense to avoid modern, simplifying language constructions, as we can assume these are known by the reader.

This unwritten contract is jeopardized by an overload of language features, as suddenly we may want to avoid certain features considered complicated. Hence, the notion of optimal code becomes more subjective.

It becomes a problem when using code written by other people. Since everybody is using a different subset of C++, a project with external dependencies quickly becomes a hodgepodge of different idioms, coding practices and language subsets and as a result becomes harder to maintain. Some of the language features are incompatible with others (e.g. using exceptions for error handling vs disabling exceptions for performance).
Pretty close to none of the things added to C++ over the years are specific to certain kinds of problems. It's not like you can't write a game/hft/physics/svg rendering perfectly well in C.
All of the work on compile time programming in the last few versions is definitely for performance-oriented domains (certainly others may choose to take advantage of it as well). If you don’t need that kind of performance or don’t need to have complicated logic run at compile time to save on those runtime costs, those features may not be so necessary for you.

And there are definitely things that these features provide that are impossible in C.