3 ms·
I think C++ templates have hit a turning point where you can push much more static type information into your program and the compiler errors are increasingly u
by hedora 10y ago
I think C++ templates have hit a turning point where you can push much more static type information into your program and the compiler errors are increasingly useful.
For instance using the json for modern c++ json parser, you can write this:
myclass c = json_node;
and it compile time statically checks that a json->myclass deserializer exists, and gives sane errors if one of the (recursive) subfields of myclass does not have a json deserializer.
This makes json processing in python look like blood letting, and is close (until runtime) to the experience I'd expect from ocaml and other functional languages.
https://github.com/nlohmann/json https://github.com/nlohmann/json
- WildUtah 10y agoC++ type inference and first class lambdas and flexible typed tuples have made it possible to create a real useful type system into C++ programs now. It's quite pleasant. But it robs a lot of much slower languages of their best value proposition. You can now do it all in C++ with correctness guarantees and still run 10x faster than most strong typed systems.
- VodkaHaze 10y agoI mean, even the Google style guide says to avoid complicated template metaprogramming, unless necessary
- netheril96 10y agoAnd Facebook has this `folly` library that is as complicated as the Boost Library.