Live data from Hacker News

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

news.ycombinator.com

131–140 of 184 posts

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

#131
post #111

Earlier quoted context omitted.

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?

Not standard, unless you count "supported with the same semantics in multiple compilers" as good enough.

They are not portable between CPU architectures either way

For reference, C got real alignment support in C11 and C++ in C++17. Without this, even starting on SIMD is risky.

That said, you can go really far with a good C++ math library like Eigen which has singe vectorization in the operations themselves.

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

#132
post #112
post #104

Earlier quoted context omitted.

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

That's quite irrelevant to the conversation though, we weren't talking about whether OOP is good or not. C++ is very far from "C with classes" today.

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

#133

Earlier quoted context omitted.

Large parts of the standard library are designed badly. E.g. io streams are horrible, allocators are questionable.

> Large parts of the standard library are designed badly. That's true, but IMO it's useful to study the standard library to understand what it offers , as opposed to examples of well-designed C++ code.

People who spent many years developing C++ already understand what the standard library offers, regardless on whether they studied that deliberately.

People coming to the language lack the expertise to tell well-designed code from bad-designed. It’s tempting to treat the whole standard library as an example of the former.

Maybe that’s a personal thing but I remember doing that when I just started my career back in 2000. STL wasn’t quite there but MFC was already in wide use. Because I lacked the experience I considered whatever’s there is good, and ended up using not so good parts such as C++ exceptions and macro-driven dynamic serialization.

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

#134

Earlier quoted context omitted.

Depending on the direction you want to go in your career, it's still a major need. Any complex or high-performance computing relies on C/C++ pretty heavily still. It's also a good tool to have in your box for building well-performing cross-platform native apps with Qt. I say this as one who's probably at the same stage as OP. Know some C, and reasonably comfortable with the basics. Application of C++ is a little more…

Qt is about the last library I'd call modern in terms of C++ dialect it employs or requires... (There are worse but deprecated like MFC. Or on par like wxWidgets.)

I suspect your intel on Qt's C++ use is a bit out of date. Qt nowadays uses (and requires) C++11, as well as more modern constructs.

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

#135
post #44

Earlier quoted context omitted.

The issue with D is not mandatory garbage collection, rather its quality and anti-GC religion. Joe Duffy mentioned on his Rustconf talk that Windows devs even with Midori running in front of them, it was still a very hard sell for them to psychology accept it as doable. The problem with Ada was basically expensive SDK, Pascal-like syntax and not being part of OS SDKs. Only systems programming languages that are bundl…

> Only systems programming languages that are bundled with OS SDKs survive on the market... Hmm. To Rust, this would seem to say "get bundled or die". In your view, is it enough to be a free download?

I don't see a free download as being enough.

At very least, there needs to exist painless interoperability with the SDK toolchain, debugging tools, IDE, platform libraries.

Every piece of the puzzle that doesn't quite work like the SDK tools, means additional development/debugging effort.

Naturally the big question is always if the added benefit of using language X outside the expected workflow outweighs the extra development costs.

Just look at C++, it was on the path of being widely adopted by desktop OSes, every C compiler vendor was adding support for it.

Then BSD and Linux large scale adoption happened with GNU manifesto favouring C as the language to write portable software, Java and .NET came into the scene.

Microsoft was probably the only major OS vendor still caring about it, until LLVM happened and the wind started blowing again with C++11.

The embedded space is still an area where C++ is hardly seen, with a few conference talks last year discussing on how to advocate for it.

Now all major C compilers are written in C++, but had Microsoft focused only on .NET or LLVM never happened, and history would probably followed another path.

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

#136
post #132
post #112

Earlier quoted context omitted.

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…

That's quite irrelevant to the conversation though, we weren't talking about whether OOP is good or not. C++ is very far from "C with classes" today.

Ok but still OOP is the central idea and also there is this trend the most annoying one to always try modeling everything as classes and objects.

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

#137
post #44

Earlier quoted context omitted.

Yup. D had a shot, but they screwed it up with (effectively) mandatory garbage collection. Ada also had a shot, I think, but they screwed it up with no C compatibility and expensive SDKs - or something. For some reason, Ada is just not perceived as "cool". It actually seems like a pretty good language!

The issue with D is not mandatory garbage collection, rather its quality and anti-GC religion. Joe Duffy mentioned on his Rustconf talk that Windows devs even with Midori running in front of them, it was still a very hard sell for them to psychology accept it as doable. The problem with Ada was basically expensive SDK, Pascal-like syntax and not being part of OS SDKs. Only systems programming languages that are bundl…

> Windows devs even with Midori running in front of them,

There were GC'ed operating systems in the 80s. The point is not this. It's writing applications where you can maximize your CPU usage.

If it's a game, it means that you want to write your code so that the highest number of objects are visible on screen and are being updated on each tick. If its's a multimedia software, you want to be able to run most sounds / videos in parallel at the same time. If it's an interpreter, you want to have the highest instructions-per-second count.

etc etc... the point is not to have "good enough" performance, it never has been as soon as you use non-trivial apps. It's always "how fast can it be" / "how far can I push it", and an implicit language-level GC puts limits to this.

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

#138
post #105
post #94

Earlier quoted context omitted.

> I would also like to add that it helps to read "The Design and Evolution of C++". I think that book is worth reading even to people who have no intention of going anywhere near C++, as long as they are interested in programming language design and evolution. I wish there were more books like this one to explain the kind of thinking that went into the design of a language and to tell its history.

Agreed. I had commented on the book on HN about a month ago: https://news.ycombinator.com/item?id=16275341 Excerpt from it: "I found that book very interesting in many regards. I had bought and read it several years ago (out of interest, though I have not worked on C++ professionally). Stroustrup goes into a lot of details about the reasons for many design decisions in the language." That's one of the reasons that ma…

Agreed on D&E, but I think it really does need an update now.

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

#139
post #126

Earlier quoted context omitted.

> if you know some let me know “This Week in Rust” lists explicit job postings. One of the latest companies looking for Rust programmers is a little company you may have heard of: Facebook. That said, many places are hiring good programmers and putting them on Rust projects, rather than hiring Rust programmers explicitly. There aren’t many pure Rust shops yet, so they need a broader skill set.

I'm pretty good in C as well (less C++). I just would like to know beforehand if I could grow into a Rust role there.

Yeah, that's the issue with these kinds of roles. You'd have to ask each company, of course.

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

#140

IMO, the classic C++ book/author is still the best: Effective C++. Don't forget about the sequels, including the mostly overlooked Effective STL (which I happen to like better than the first two books). And to address the modern part of this question, I'll add that Scott Meyers has written Effective Modern C++ as well, but I'd read that last after getting the hang of C++03. No matter what people say, I tend to believ…

It's a pity that one of the most recommended books is about the pitfalls of C++ and is by someone on his own admission has never written production C++ code.

Of course it's a very good book though.

My recommendation is for "Accelerated C++" by Koenig and Moo. It's rooted in actual teaching experience and compared to most C++ books is pretty slim.

The only negatives these days is that it is a bit old and (still) expensive.

Post reply on HN