It's a monster language, the Godzilla of the programming languages. But it gets the job done, as long as you use only 10% of its features.
A list of modern C++ features
31–40 of 68 posts
Re: A list of modern C++ features
#32Yeah more features is exactly what C++ needed... Am I the only one who uses C++ as C with classes? Sometimes I use vectors or strings and I like default values in functions and other minor improvements to C. I don't want to reimplement the n'th version of string concatenation when I can just use the "+" operator, sure... and there starts the rabbit hole. Before you know it you have a "protected abstract virtual base…
Re: A list of modern C++ features
#33Most features are very good. My favorite ones are range-based loops, lambdas, and strongly-typed enums. The things I dislike most are pairs and tuples. They make the code enormously harder to read, understand and debug, compared to non-standard classes or structures with meaningful member names. Even this guide promotes them in “using Coordinate = std::pair ;” Please, never do that, create your own class with x/y or…
Re: A list of modern C++ features
#34Earlier quoted context omitted.
Or even better, at some point they should introduce "safe mode" or "strict mode", where you turn on a compiler flag.
aka -Weverything ;)
Re: A list of modern C++ features
#35The one feature that really annoys me is the std::optional. This is awesome and very needed feature however it is too clunky for something that should be used very frequently. Swift does such a nice job with its '?' operator, I wish C++ had something similar.
Re: A list of modern C++ features
#36Re: A list of modern C++ features
#37Most features are very good. My favorite ones are range-based loops, lambdas, and strongly-typed enums. The things I dislike most are pairs and tuples. They make the code enormously harder to read, understand and debug, compared to non-standard classes or structures with meaningful member names. Even this guide promotes them in “using Coordinate = std::pair ;” Please, never do that, create your own class with x/y or…
Sometimes all the meaning is in the name of a thing (or in the name of a function returning such a thing) and member names dont help but hurt. x/y is a good example, why not a/b? I prefer not having to make these decisions. Also tuple assignment syntax is very nice from a usability standpoint (I don't think C++ has it, but e.g. Python has).
auto [a, b] = function_returning_pair();
Of course, tuple unpacking was already possible before if the variables were already declared: int a, b;
std::tie(a, b) = function_returning_pair();Re: A list of modern C++ features
#38This made me think of the passage below from Edsger Dijkstra's ACM Turing Lecture from 1972. Back then there was no C++. "I remember from a symposium on higher level programming language a lecture given in defense of PL/1 by a man who described himself as one of its devoted users. But within a one-hour lecture in praise of PL/1. he managed to ask for the addition of about fifty new “features”, little supposing that t…
And every time there was a language designed against PL/I like languages, with the goal of fighting complexity, its adoption by the industry lead to feature growth and becoming just as complex, usually with solutions hindering by backwards compatibility. Yes C++ is complex, but so are Python, Ruby, Ada, Fortran, C#, F#, Haskell, OCaml, Java... Even Go will get caught in the complexity game if it gets enterprise adopt…
Re: A list of modern C++ features
#39Most features are very good. My favorite ones are range-based loops, lambdas, and strongly-typed enums. The things I dislike most are pairs and tuples. They make the code enormously harder to read, understand and debug, compared to non-standard classes or structures with meaningful member names. Even this guide promotes them in “using Coordinate = std::pair ;” Please, never do that, create your own class with x/y or…
If you use the members a lot, a struct with named members really is much easier to read, though.
Re: A list of modern C++ features
#40Earlier quoted context omitted.
The big difference here is how additions in C++ tend to work - e.g. keeping all of the deprecated ill-defined legacy and growning features on it like tumors until there are no more symbols left. Unlike Ada and Python which aren't afraid of throwing away poor design and were overall more thought out in the first place (especially Ada). Its not a "complexity game" in so much as poor design being over-compensated for. C…
How specially Ada?! The only thing Ada has thrown away was GC support that no compiler vendor has ever bothered to implement. What other features were thrown away across Ada83, Ada95, Ada2005 and Ada2012? If I present you Ada random code snippet X, are you sure you will be able to say which language version it requires? Also Python is the poster child of what happens when you throw compatibility away.
And what, exactly, happened?
For years I avoided Python3. Updating my code base was a hassle I did not want to deal with.
Finally, a few months ago, I had some spare time and took the dive.
And nothing bad happened. I did not even spend hours on it. At this point, all the libraries I need exist for Python3, and the automated tools update my code for Python3 without manual intervention almost every time.