Live data from Hacker News

A list of modern C++ features

github.com

11–20 of 68 posts

Re: A list of modern C++ features

#11
It is worth to note that template-related features make compilation time significantly longer. It might seem no-problem unless you face it in a bigger team, then these extra seconds (or minutes) are multiplied.

Re: A list of modern C++ features

#13

I really wish there would be a linter (I realise it's probably a nearly impossible task) which would complain when you use legacy, unsafe language features. As someone who doesn't work in C++ or have the benefit of 10 years experience to see the flaws, trying to write modern, safe C++ is essentially impossible. I spent a solid week trying to write something safe and only use C++14/17 features when they were available…

That is what Microsoft introduced at CppCon 2015 alongside the C++ Core Guidelines.

Besides the clang-tidy, there is the ongoing efforts to improve VS analyzers, but I guess they will only be fully productized on VS "15", the upcoming release.

I also imagine other C++ linters are improving their C++ Core Guidelines support.

Under C++ Core Guidelines you are supposed to use [[unsafe]] annotation to mark such features.

Re: A list of modern C++ features

#14
post #7

This 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 adoption at scale.

If not the language, the libraries surely will.

Re: A list of modern C++ features

#15
post #9

Earlier quoted context omitted.

clang-tidy does this (or is working towards doing this) http://clang.llvm.org/extra/clang-tidy/checks/list.html

Thanks, that page looks like hell, but I recognise a few terms. http://clang.llvm.org/extra/clang-tidy/ is much more approachable, and gives a solid overview. The introductory sentence gave me project-naming cancer: > clang-tidy is a clang-based C++ “linter” tool. Then why is it called tidy ??? It appears first on page three of google's search results for "C++ linter" in spite of the fact that anything from LLVM is p…

> Then why is it called tidy ???

https://en.wikipedia.org/wiki/HTML_Tidy

Re: A list of modern C++ features

#16
Yeah 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 pure virtual private destructor" and have to explain the new hired mathematician who only has experience in R what the fuck you are doing.

Re: A list of modern C++ features

#17
post #16

Yeah 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…

In a word: C++ is probably not for you(r application).

Re: A list of modern C++ features

#18
post #16

Yeah 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…

Am I the only one who uses C++ as C with classes?

I'd say unfortunately not. Focussing on the classes has the disadvantge it can quickly lead to 'everything is an object' or derived strict OOP mindsets thereby not only ignoring tons of other, more functional, goodies modern c++ has to offer but also leading to what you call 'protected abstract virtual base pure virtual private destructor'.

Re: A list of modern C++ features

#19
post #14
post #7

This 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…

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++ is like cancer infecting the minds of young programmers with buggy habits -- and no amount of features and static analysis will change what lies beneath... :p

Re: A list of modern C++ features

#20
Most 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 latitude/longitude instead.

Post reply on HN