Live data from Hacker News

Ask HN: Best way to learn modern C++?

news.ycombinator.com

111–120 of 184 posts

Re: Ask HN: Best way to learn modern C++?

#111

Earlier quoted context omitted.

Incidentally, SIMD is just waiting on stabilization now; it’s RFC was accepted and the implementation landed. Soon!

Will Rust have idioms for really doing SIMD in Rust ? If I understand correctly, C++ has to drop into assembly to do SIMD (at least so far).

C++ doesn't need Assembly for SIMD.

Most compilers do a reasonable job with auto-vectorization, and if more is needed, there are instrisics.

No need to write straight Assembly.

Re: Ask HN: Best way to learn modern C++?

#112
post #104
post #101

C++ is just C with extra notation for easy modeling of Classes and Objects. While C still remains valuable, C++ is in my opinion questionable and there are many excellent alternatives like Java or C# for doing similar things and much more. I have programmed in C++ for many years and honestly would not suggest it to any one but anyway here are some excellent resources. ftp://bitsavers.informatik.uni-stuttgart.de/pdf/b…

> C++ is just C with extra notation for easy modeling of Classes and Objects. That's far from true today, and I'd even argue it hasn't been true since very early on. Simple example to prove my point: RAII.

So you know https://en.wikipedia.org/wiki/Resource_acquisition_is_initia... Good for you.

"Object Oriented Programming puts the Nouns first and foremost. Why would you go to such lengths to put one part of speech on a pedestal? Why should one kind of concept take precedence over another? It's not as if OOP has suddenly made verbs less important in the way we actually think. It's a strangely skewed perspective." from https://en.wikipedia.org/wiki/Object-oriented_programming criticisms says a lot.

Re: Ask HN: Best way to learn modern C++?

#113
post #48

Earlier quoted context omitted.

First of all, I should say that I feel like bringing up Rust in this thread is inappropriate, and I’m glad the OP was downvoted. To comment briefly on the learning curve, the trade off is basically, C++ is easier to get started, but harder on the high end. Rust is a bit harder for C people to get started, but then the high end is much easier. Rust’s curve is flatter, in a sense. Oh and also: learning one will certain…

>Oh and also: learning one will certainly help you learn the other in many cases. I advocate learning many languages :) Especially the Rust borrow checker will make you mad in the first place, and then teach you something about memory management you will be able to use in C++. It really improves your mental model in places you didn't expect.

does Rust basically have the same 'move' semantics as C++ ?

Re: Ask HN: Best way to learn modern C++?

#114
post #60

If you haven't already I'd suggest learning a functional language first, then coming back to modern C++, because much of the new features are borrowed from other languages. Personally I started doing this then never went back. Seems most of the jobs out there for C++ really aren't that interesting.

Absolutely unnecessary. Modern C++ borrowed some paradigms of functional programming, but learning a functional language isn’t remotely close to being a prerequisite to learning those features.

In terms of jobs, C++ is used heavily, if not the majority of the time in: AAA game development, high performance computing, high frequency trading and quantitative finance, embedded software, image processing and computer vision... honestly, I focused on C++ out of school years ago BECAUSE of how interesting many of the jobs are. They’re also generally more stable and thus competitive over time compared to e.g. web dev, enterprise software, and so on, because the domain knowledge required means you’re a lot more valuable than knowing X and Y design pattern or framework Z.

Re: Ask HN: Best way to learn modern C++?

#115
post #12

May I ask why do you want to learn modern C++? You should check out Rust, it aims to replace C++ and do a better job in memory management, and developer experience in general (cross-platform compatibility, package management, etc)

>replace C++ No one can replace it, but everyone has to try.

Java?

Re: Ask HN: Best way to learn modern C++?

#116
post #111

Earlier quoted context omitted.

Will Rust have idioms for really doing SIMD in Rust ? If I understand correctly, C++ has to drop into assembly to do SIMD (at least so far).

C++ doesn't need Assembly for SIMD. Most compilers do a reasonable job with auto-vectorization, and if more is needed, there are instrisics. No need to write straight Assembly.

OK. (The one time I encountered SIMD in C++ was a decade ago; we had to use assembly then. And even then, we weren't playing with an up-to-the-minute compiler. (In my experience, your comments elsewhere on this article about embedded toolchains were accurate.)

Are the intrinsics standard? If so, what version of the standard were they in? How good is compiler support for them?

Re: Ask HN: Best way to learn modern C++?

#117
post #17

- Tour of C++ ( http://www.stroustrup.com/Tour.html ) - Principles and Practice Using C++ ( http://www.stroustrup.com/programming.html ) - From Mathematics to Generic Programming ( http://www.fm2gp.com/ ) - The Scott Meyers books Some of the Bjarne Stroustrup videos, "Learning and Teaching Modern C++" - https://www.youtube.com/watch?v=fX2W3nNjJIo Some of the Herb Sutter videos, "Writing Good C++14... By Default" - ht…

Would not recommend Principles and Practice Using C++, it is a fluff loaded book seemingly made to sell to university students.

Re: Ask HN: Best way to learn modern C++?

#118

Earlier quoted context omitted.

Incidentally, SIMD is just waiting on stabilization now; it’s RFC was accepted and the implementation landed. Soon!

Will Rust have idioms for really doing SIMD in Rust ? If I understand correctly, C++ has to drop into assembly to do SIMD (at least so far).

I don’t believe that’s correct for C++.

Regardless, yes, that’s the whole point. What’s been accepted is https://doc.rust-lang.org/nightly/core/arch/index.html , that is, intrinsics that map 1-1 to the vendor APIs. (I belive this is the same in C++ but not my area of specialty so I may be wrong)

https://doc.rust-lang.org/nightly/core/simd/index.html is the first level up the abstraction chain; this hasn’t gone through an RFC process yet, but will eventually happen.

On top of that, you have stuff like https://crates.io/crates/faster , which is very high level. Looks like they need to fix up the README... but you get the idea.

Also, autovectorization has existed this entire time. This stuff is for when that falls down.

Re: Ask HN: Best way to learn modern C++?

#119
post #48

Earlier quoted context omitted.

>Oh and also: learning one will certainly help you learn the other in many cases. I advocate learning many languages :) Especially the Rust borrow checker will make you mad in the first place, and then teach you something about memory management you will be able to use in C++. It really improves your mental model in places you didn't expect.

does Rust basically have the same 'move' semantics as C++ ?

Yes and no. The idea is the same, the implementation is very different.

Rust is “move by default, move always means memcpy (and they often can be elided), no move constructors,” to (possibly too) succinctly describe it.

Re: Ask HN: Best way to learn modern C++?

#120

I have a question on this topic which is - is it possible or practical to only learn "modern" C++? Isn't it necessary to be able to understand pre-modern C++ in legacy code bases or to work alongside a co-worker who might code using an older style? Or even to be able to understand documentation and texts about C++ from an earlier era?

I share your concern. Even if one isn't (knowingly) dealing with older C++ code, all of the language rules apply to every line of C++ being compiled.

Just one typo, or misguided use of syntax, and a person might be using some "older" revision of the language without knowing it. And I'm not aware of any tool that will warn the programmer that he/she has done that.

So I'm concerned that programmers schooled only in "modern" C++ will fail to understand that this has occurred, and will either (a) get error messages that don't understand, or (b) get program behavior that they don't anticipate.

I'm curious if people have found this to be a problem in practice.

Post reply on HN