Live data from Hacker News

A list of modern C++ features

github.com

41–50 of 68 posts

Re: A list of modern C++ features

#41

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.

Agreed. The template stuff blows me away, feels completely foreign to me. I'm barely catching up to C++11's features and looking at the '14/'17 stuff gives me that feeling of being assigned a ton of homework.

Re: A list of modern C++ features

#42

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…

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).

Maybe sometimes, but not this time.

The author named their pair "Coordinate". In math and in computer graphics there’s widely known convention the fields of Cartesian coordinates are named x/y and not a/b.

When you’ll start writing code that use and/or modify those Coordinate values, meaningful names in C++ source and in the debugger help a lot.

Re: A list of modern C++ features

#43
I really wish a group of really smart dev get together and come up with a new language based just on the modern C++. Perhaps even call it MC++ (Modern C++). Make it's syntax as simple and easy to learn as Python and yet give us the performance close to the compiled C++. I'd take that knowing very well that I can't do all the powerful stuff I could with C, yet I have a safe and idiot-proof language to work with in my hands.

Re: A list of modern C++ features

#44

I really wish a group of really smart dev get together and come up with a new language based just on the modern C++. Perhaps even call it MC++ (Modern C++). Make it's syntax as simple and easy to learn as Python and yet give us the performance close to the compiled C++. I'd take that knowing very well that I can't do all the powerful stuff I could with C, yet I have a safe and idiot-proof language to work with in my…

Rust?

Re: A list of modern C++ features

#45
post #24
post #23

Earlier quoted context omitted.

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.

What I meant to emphasize was that Ada was well designed in the first place, and yes GC was a problem and so were some of the restrictions and aspects of the standard libraries. For example, a big one was unconstrained types for generic actuals... C is a mine-field of devastating design flaws which have caused many people to die because of decades old decisions made on a whim and any change to basic libraries to make…

> C is a mine-field of devastating design flaws which have caused many people to die because of decades old decisions made on a whim...

Wow. Hyperbole much?

I get that you don't like C, but you sound like a raving lunatic who is completely unconnected with reality.

Devastating design flaws? Flaws I can agree with. Devastating? That sounds a bit overstated.

Caused many people to die? I call BS. (Yes, I'm pretty sure you might be able to document a few. But you said "many", and I'm calling you on it.)

Decisions made on a whim? Again, BS. In fact, at this point you're just making stuff up.

Re: A list of modern C++ features

#46

I really wish a group of really smart dev get together and come up with a new language based just on the modern C++. Perhaps even call it MC++ (Modern C++). Make it's syntax as simple and easy to learn as Python and yet give us the performance close to the compiled C++. I'd take that knowing very well that I can't do all the powerful stuff I could with C, yet I have a safe and idiot-proof language to work with in my…

Rust?

A very heavily biased rookie response. Not trying to be snarky.

Rust would be an obvious choice for what I described. It's been on my personal list for a while to learn Rust and make use of it. I think I will pretty soon.

I've been demotivated (to start) by reading over here on HN or elsewhere about how much of a learning curve it is to learn Rust. Perhaps, it was the bias that I already know what C++ was like in terms of syntax and idioms that made me ask for a choice with least friction.

Re: A list of modern C++ features

#47
post #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).

Disagree. C++ has the philosophy of "You don't pay for what you don't use". Just use the parts that help with your problem. If your problem grows and you need more, you aren't trapped - the language has more. But if you don't need it, don't use it.

For that matter, I'd argue that this is a reasonable approach for every language.

Re: A list of modern C++ features

#48

Earlier quoted context omitted.

Which is hella annoying. -Wall -Wextra is very needed, -Wconversion is nice but already borderline annoying, but enabling everything would just be a mess.

-Wc++98-compat is especially annoying.

You guys don't use -pedantic? :D

Re: A list of modern C++ features

#49

I really wish a group of really smart dev get together and come up with a new language based just on the modern C++. Perhaps even call it MC++ (Modern C++). Make it's syntax as simple and easy to learn as Python and yet give us the performance close to the compiled C++. I'd take that knowing very well that I can't do all the powerful stuff I could with C, yet I have a safe and idiot-proof language to work with in my…

Nim is closer to that ideal than Rust, I think; Rust requires provable object ownership that doesn't go bad, Nim uses an (optional, but strongly suggested) GC.

Nim's syntax is mostly pythonic, and it's metaproramming language is Nim (unlike C++'s abominable template metaprogramming language).

Re: A list of modern C++ features

#50
post #24

Earlier quoted context omitted.

What I meant to emphasize was that Ada was well designed in the first place, and yes GC was a problem and so were some of the restrictions and aspects of the standard libraries. For example, a big one was unconstrained types for generic actuals... C is a mine-field of devastating design flaws which have caused many people to die because of decades old decisions made on a whim and any change to basic libraries to make…

> C is a mine-field of devastating design flaws which have caused many people to die because of decades old decisions made on a whim... Wow. Hyperbole much? I get that you don't like C, but you sound like a raving lunatic who is completely unconnected with reality. Devastating design flaws? Flaws I can agree with. Devastating? That sounds a bit overstated. Caused many people to die? I call BS. (Yes, I'm pretty sure y…

First of all what if I am lunatic xD

There are so many parts of C that are unsafe that a secondary tool is needed to have an reasonable type-checking and that tends to be devastating if they can be easily avoided by even safety critical engineers.

https://users.ece.cmu.edu/~koopman/pubs/koopman14_toyota_ua_... "Toyota does not claim to have followed MISRA Guidelines"

And honestly I dont think we agree on what "a few" is. In my book if any more than 4 or 10 people die from a solved problem in computer science (like strong typing, mutexes, and range checking) that is already way too yes many

As far as decisions on a whim compare the two language design efforts and i'll let you decide:

http://www.adapower.com/index.php?Command=Class&ClassID=FAQ&... "The requirements were not a language specification, but instead they attempted to define rigorously the needed characteristics in a form that could be critically reviewed."

https://www.codingunit.com/the-history-of-the-c-language “It’s entirely Dennis Ritchie’s work”

Post reply on HN