Live data from Hacker News

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

news.ycombinator.com

141–150 of 184 posts

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

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

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

Having a GC enabled OS doesn't mean the GC runs all the time or it is the only way of allocating memory.

The last generations of Oberon OS had support for video editing applications as an example.

There are real time GC applications in production being used to control weapons systems, including live targeting and soft real time factory automation systems.

Regarding D, using @nogc or -vgc allows the developer to control when the GC works, it at all. What the language lacks is a GC that can match real-time GCs used in soft real time systems.

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

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

As for "Stop Teaching C" video one should also consider this book https://www.amazon.com/Accelerated-C-Practical-Programming-E... Alas, it is c++03. On the other hand it's relatively thin and it begins with the standard library (std::vectors, std::sort, std::string) from the first chapters. So I guess it was the first good book that didn't begin with C language from the start.

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

#144

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

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

Same. And I think you articulated the specific concerns I have about just learning the "modern" version.

It would certainly lower the barrier to entry in learning C++ if this was an unfounded concern.

C++ has some 35 year of history and changes at this point. This point alone adds(for me anyway) to the perceived cognitive load of learning it. C also has a similar length of history but it is a much smaller language.

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

#145

Anyone aware of good, thorough, (online) material to learn C++ template programming?

For this, I can't point to any one source, but I highly suggest looking at the implementations of the C++11 type_traits header. Building off of that would be a great second step.

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

#146

Piggybacking of this post, if anyone has any similar resources for best practices in modern C I'd be interested. There don't seem to be any moocs that go beyond introductory material and K&R obviously doesn't cover modern tools and methods.

My biggest question would be what modern means to you? Does it mean the style of the newest popular C project? The newest standard (C11)? And what devices are you using C for? I'd assume a standard POSIX environment, but you can't be sure with C.

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

#147

Earlier quoted context omitted.

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.

Qt may be inspired by modern C++, but you don't get hands on experience using the STL since Qt re-implements almost the entire thing.

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

#148
Others have talked about how to learn the language but many people often find that hardest thing to do is to even compile their first C++ file. This is the "build system escalation policy" that I personally use, depending on what I need:

1: Experimental, throw-away code: online IDEs or Godbolt if I care about compiler output. You would be surprised how much mileage you can get out of a simple online IDE when you are just learning or exploring a new thing and don't care about preserving your work.

2: Single-file code or small multi-file projects with no dependencies (like exercises or code samples from a book): direct calls to clang++/g++ in the command prompt or a simple build.sh shell script when I have to build multiple files. Make is a fantastic tool for this so you can learn and use that instead. I would actually encourage beginners to play directly with the compiler and learn the basic flags though, but this is personal preference.

3a: Personal projects that pull in other dependencies (either system wide or libraries from github or other sources): Make or cmake would probably work here equally well. I actually prefer cmake for its find_package and external project functionality. Notice the jump in complexity from 2 to 3, this is something you have to deal with and eventually you will have to pick a build tool and learn it.

3b: After learning to use Bazel I have mostly migrated to it for all my personal projects, but there was an initial learning curve for sure (not worse than cmake though).

4: At work: Whatever your company/team/group uses, you will most likely have little input on this if the codebase is old and established.

If you are in Windows you can use vanilla Visual Studio C++ (Community edition is free and has all the bells and whistles) for 1-3, or use Visual Studio + cmake (you can generate VS solution files from cmake).

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

#149
post #99

I found "C++ Primer" by Lippman et al very well written and comprehensive. It includes C++11 features and every chapter has exercises to make sure you understand the content. https://www.amazon.com/Primer-5th-Stanley-B-Lippman/dp/03217...

Already outdated by 6+ years though.

What would you say are important features missing in C++11 that are in the current standard? I ask because I'm trying to get back into C++ development after many years and even C++11 seems like a new language to me.

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

#150
The question assumes that there is a single "proper" way to code in C++ that everyone agrees on. But that's just not the case. For example, Google bans exceptions, operator overloading, and most uses of Boost in their C++ code. Facebook embraces all those things. QT re-invents most of the standard library.

A lot of the C++ language is sort of experimental. Sometimes features get thrown in and then deprecated and/or taken out, like the "export" keyword for templates, or throw specifications. Most programmers have strong opinions about which C++ features are bad. But that's all they are-- opinions. The C++ standard supports pretty much any way of doing things you could imagine-- async, sync, multiple inheritance, functional, you name it.

If you're a novice, my advice is to learn C really well. Then choose a C++ style guide and follow its recommendations closely.

Post reply on HN