8 ms·
Back in 2015 I read Effective Modern C++ by Scott Meyers [1], which is his latest entry in the saga of "Effective C++" books. It covers all the new stuff that g
by j1elo 3y ago
Back in 2015 I read Effective Modern C++ by Scott Meyers [1], which is his latest entry in the saga of "Effective C++" books. It covers all the new stuff that got into the language with C++11 and C++14, and shows how modern C++ can be written.
My feeling during the read, and my definite conclusion afterwards, is that I didn't read a collection of new nice additions to the language, but a list of minefields and new fancy ways to crash your program. That there is no chapter which doesn't end up being a list of gotchas. Seemingly every new feature was added as an extension of the language's reputation of being a shotgun that loves your feet. "Oh, now we have lambdas! here are the 32 ways you can fail while using them, and the language will do nothing to help you prevent".
Effective Modern C++ is a very well written book and very instructive. Its flaws are none of the book or writer, but of the language itself.
[1]: https://www.aristeia.com/books.html https://www.aristeia.com/books.html
- limaoscarjuliet 3y agoAgreed 100% The last time C++ "made sense" to me was 1998 reading and practicing Bjarne Strostrup's C++ book. It was better C then and a lot of these improvements made sense.
- bowsamic 3y agoYeah, Effective Modern C++ has always read like a list of warnings. C++ is kind of like Python in that the design of the language does not steer you into making good, idiomatic decisions. No one is going to guess most of the stuff that is taught in that book without reading it first from working with the language or reading other people's code, and really a full list of such things for C++ could be many hundreds or even thousands. I also agree that the new features seem to embrace and extend the "footgun-ness" of C++, rather than attempt to fix it.
- DougBTX 3y agoWhich book would be the equivalent to an Effective Modern Python?
- PaulDavisThe1st 3y ago> the design of the language does not steer you into making good, idiomatic decisions. That's much easier to do when the tasks that the language is suitable for are bounded in some way. There are not many common idioms that are going to be shared (beyong libstdc++) between a realtime audio processing application and a data visualization backend for the web and an embedded system control app and a payroll processing backend.
- bowsamic 3y agoI don't agree. I can think of many languages that obfuscate their idioms that have bounded applicability. Obviously I already mentioned Python, which is obviously bounded to less performant applications (unless you call C code), but another one is SQL. For example, Azure SQL is extremely slow when using sub queries compared to CTEs, but the language does not make this apparent in its design. An example of a language with a smaller domain which makes its idioms obvious through its design is Ruby. An example of a high-performance language that can be used for all those things that makes its idioms obvious through its design is Rust. Another would be, imo, C. > There are not many common idioms that are going to be shared (beyong libstdc++) between a realtime audio processing application and a data visualization backend for the web and an embedded system control app and a payroll processing backend. I also just generally have to disagree with it, but you seem to be using a different definition of idiom to me. From what you said here, you seem to take idiom to be synonymous with "design decision". For me, an idiom is a specific semantic construct, possibly associated with specific syntax, that achieves a specific basic programming task. For example, the idiomatic way to loop with an index in Python is to use enumerate. It's merely the way that most people do the basic things, in a way that is actually good to do. C++ is infamous for a huge number of people using the language dangerously, to the point where there are effectively no idioms outside of specialist communities, and to find them out you need to read books. A significant amount of the basic design of the language needs to be ignored for most purposes.
- PaulDavisThe1st 3y agoOne of the main places I see idioms in other languages is in dealing with containers (and there are some very nice ones). Python in particular, but others too. Slicing, splicing, iterating, mutating, map-reduce etc. etc. While I wouldn't say no to having such idioms available in C++ as language constructs, it is important that C++ continues to provide the lowest level that it can for such tasks (e.g. pointers into arrays or other buffers), and probably the level right above that (libstdc++). Similarly for threads (or more generally, parallel and asynchronous programming) - some other languages make available some really nice idioms for expressing these things, but again it is important for performance and control reasons that C++ continues to provide the current lowest level of access for this (basically a wrapper around pthreads). While things like promises, futures and coprocessing are really useful, they are often inappropriate for highly performant code.
- raincole 3y agoNo kidding. Effective Modern C++ was what got me to actually start learning Rust. That being said I feel Rust has a lot of paper cuts that slow people down too. Perhaps the silver lining is that they are more like barricades than minefields.
- KineticLensman 3y ago> Perhaps the silver lining is that they are more like barricades then minefields As a Rust newby I think they are more like achievements that unlock new capabilities.
- moonchrome 3y agoThere's a name for this feeling [1] [1] https://en.wikipedia.org/wiki/Stockholm_syndrome https://en.wikipedia.org/wiki/Stockholm_syndrome
- spoiler 3y agoSo learning any new skill is a manifestation of Stockholm syndrome?
- Verdex 3y agoFrom your wikipedia link: "and, in fact, it is a "contested illness" due to doubts about the legitimacy of the condition." AND "It was noted that in this case, however, the police were perceived to have acted with little care for the hostages' safety,[6] providing an alternative reason for their unwillingness to testify." Somehow appropriate considering this thread is about how someone's bad experience with C++ has driven them into learning rust.
- PennRobotics 3y agoRust would be so much easier for me if it didn't feel like every. single. keyword. was different than my daily drivers, Python and C---from type names to standard library functions, containers to punctuation. Even "void" isn't safe (hehe pun) from this keyword purge. Beginners, count your blessings. You don't need to unlearn other languages before learning Rust. I sincerely believe the only keywords common to Rust and C are a few control flow keywords (for, if, while; but not switch, goto, or do-while) and "bool"---the latter only because of C99 and stdbool.h
- rewmie 3y ago> My feeling during the read, and my definite conclusion afterwards, is that I didn't read a collection of new nice additions to the language, but a list of minefields and new fancy ways to crash your program. I don't think that's a reasonable take on both the book and C++11/c++14. `Effective Modern C++` is not an intro tutorial, but a book dedicated to trivial and nontrivial gotchas, none of which leads your program to crash. Worst case scenario you just get a compiler error of your own doing, and that's it. I mean, the book covers stuff like the importance of using nullptr instead of NULL, why braced initialization is nice, why and how smart pointers should be used to implement a pimpl, etc. This is hardly mine field territory, and it makes absolutely no sense at all to use these tidbits of all things to justify switching to an entirely new programming language.
- npalli 3y agoScott Meyers was the go-to reference for "expert" C++ knowledge for over twenty years, he retired after his C++14 books came out and a mere two years later he couldn't even keep up with the language to make technical corrections. C++ is a large, intricate language with features that interact in complex and subtle ways, and I no longer trust myself to keep all the relevant facts in mind. As a result, all I can do is thank you for your bug report, because I no longer plan to update my books to incorporate technical corrections. Lacking the ability to fairly evaluate whether a bug report is valid, I think this is the only responsible course of action. https://scottmeyers.blogspot.com/2018/09/the-errata-evaluation-problem.html https://scottmeyers.blogspot.com/2018/09/the-errata-evaluati...
- googlryas 3y agoHeck, even C++ is getting out of hand for Herb Sutter. He might say "ISO C++ is the best tool in the world today to write the programs I want and need", but then he also says "My goal (with cppfront) is to explore whether there's a way we can evolve C++ itself to become 10x simpler, safer, and more toolable." https://github.com/hsutter/cppfront https://github.com/hsutter/cppfront
- cassepipe 3y agoI am really sold on cppfront but I have not had the occasion to use it yet. How usable is it ? Is it closer to a a Proof of concept or a finished tool ?
- darknavi 3y agoAs a C++ fan his cppfront talk was excellent. I'd love to see this work get wider adoption.
- rewmie 3y ago> Heck, even C++ is getting out of hand for Herb Sutter. That's a wildly exaggerated take. Working on something to improve user experience and simplify it is not nor it ever was the same as something getting out of hand. This take is even more absurd when we notice that the main goal of cppfront is to serve as a testing ground ti explore backwards incompatible changes to understand if they actually improve the language. Cppfront is the answer to "why not" questions when ignoring constraints deriving from backwards compatibility.
- dwaite 3y ago"Effective Modern C++" had nothing on "Modern C++ Design", published in 2001. A coworker lovingly referred to it as "The Anarchists Cookbook of C++". My understanding at the time of publication was that there was no shipping compiler that could deal with his implementation library for the book, "Loki". My impression of C++ changes since then has not been that they were adding new capabilities, but rather trying to add proper ways to achieve the desired compile time/runtime/memory behavior without resorting to (at least as much) arcane template metaprogramming.