Live data from Hacker News

Modern C++ Programming Course

github.com

131–140 of 221 posts

Re: Modern C++ Programming Course

#131

Earlier quoted context omitted.

I find it absurd that a programming language which compells someone to set up a containerized OS just to manage their build toolchain could be considered "modern".

It would truly be absurd to claim that C++ is a modern language. A subset of C++ however, is modern. This does not include the toolchain and standard build practices.

Your point stands, but it is/was implied, how I took it at least.

Re: Modern C++ Programming Course

#132
With the context of learning Modern C++, and the author's association with nVidia and CUDA, I share this anecdote: Partially if it helps anyone directly, and partially as an opportunity for someone experienced with C++ to poke holes at it.

I've had great success using ChatGPTv4 to help me write modern C++ that works with CUDA, using prompts like these. (I have not attempted to get it to write parallelized code given loops/serial code as an input):

> Please convert this Rust code to modern C++, compatible with the latest version of the nvcc CUDA compiler: ```rust ```

It will output a compilable/working result, and explain each of the language differences in question. It will make sure to use `std::*` instead of the more rigid C-derived equivalents when able, and take advantage of looping over array pointers etc, vice i++ loops. `auto` var types etc.

Re: Modern C++ Programming Course

#133

> Heap Memory - new, delete Keywords Should "modern" C++ even use new/delete? I'm a C++ n00b, but I thought these can be avoided entirely now.

I noted that - IMHO one of the big advantages to "modern" c++ is the focus on the lifetime of objects with smart pointers rather than the mechanics of heap allocation and pointers. Pushing that down to chapter 19 as "Advanced Topics" seems like a mistake. Arguably the same with std::array vs object[] - the first should "probably" be the default now for teaching new programmers, so covered first (or at least highlighted when discussing array[]-style variables)

I also note a number of the possibly-ambiguous c-style casts in examples, despite already having mentioned the explicit versions (static_cast and the like).

Plus there seems to be a fair bit of system & machine dependent stuff mentioned like it's /always/ true - like stack being at a "higher" address space than the heap and code sections, or the stack growing down. It also says that the Data section is "slower" than the stack which... isn't true? If they're spilled out of registers, they're likely functionally identical? Or at least for small microbenchmarks depend on specific implementation details, like how the pointer to the object is calculated and dereferenced.... And object size and cache interactions... And a million other things...

And that's just the first few chapters I looked at :P

Re: Modern C++ Programming Course

#135
post #96
post #13

Any ideas where to start learning C++ as an embedded developer? I wrote many lines of bare metal C code and want to transit to higher level jobs. I see many expensive or completely free courses, but I am not sure which one is usable in my complicated situation.

It depends on what you target. I do alot of Kernel and really low level C++, and it's a completely different style than even app dev, so you have to be sure you don't go down the completely wrong route. For my target space, there's a few rules for c++. Footguns: A. No STL, it causes to much bloat when binary size is critical. B. (almost) No inheritance or virtual functions. Again, it causes some bloat and adds in som…

[dead]

Re: Modern C++ Programming Course

#136

I've been setting up my little docker image that has both llvm/clang/tidy/clangd and gcc inside with boost with an idea I'd run it and from outside use it to code with live checking and compiling without littering my OS. Now, I feel like I'm doing something that already exists but couldn't really find what everyone use, ought of those that would prefer such a setup. Debugger within is probably a pipe dream, but who k…

I find it absurd that a programming language which compells someone to set up a containerized OS just to manage their build toolchain could be considered "modern".

I guess that's why i went into JavaScript instead of java. I use to write HTML back when i was around 10 years old, back then java applets were the only way you could have something interactive and dynamic on your page, so i started to learn it. After a while i learned that you could do a lot of neat stuff with JavaScript. So i stopped using java.

Re: Modern C++ Programming Course

#137

[flagged]

I don't know why this gets downvoted so much. It seems like a good newbie question.

Agreed, as a Python dev who tried a bit of Rust a while ago, I was wondering exactly the same thing. Bored of the churn and fads with higher level stuff.

Re: Modern C++ Programming Course

#138

I've been setting up my little docker image that has both llvm/clang/tidy/clangd and gcc inside with boost with an idea I'd run it and from outside use it to code with live checking and compiling without littering my OS. Now, I feel like I'm doing something that already exists but couldn't really find what everyone use, ought of those that would prefer such a setup. Debugger within is probably a pipe dream, but who k…

I find it absurd that a programming language which compells someone to set up a containerized OS just to manage their build toolchain could be considered "modern".

I install Rust's toolchain and development tools inside of a container, I also do this with Python and will do it with C++ sometime in the future.

I don't do this because I have to, I do this because I prefer to keep non-system -critical software managed by non-root users and separated from the systems rootfs.

On your common desktop Linux distro, I think C and C++ toolchains are the least difficult to setup and use without a container though (for me). On Gentoo I can just emerge gcc or clang and enable whatever USE flags I want, and they are installed and updated automatically with the rest of my system.

I use the Gentoo system package manager to manage my Rust toolchain as well instead of using rustup, so that it behaves like described above, it's updated and managed automatically and with the rest of my system!

I do realize that many distros have issues with software being out of date though, and that is a big problem! With Gentoo I can install multiple versions of most things in parallel and can very easily package anything that doesn't exist yet.

Also to clarify, I use the system package manager to build and manage my containers, this is how I use the system package manager to manage Rust's toolchain but also have it inside of a container. All of my containers are just nested Gentoos that I can install stuff into with the system package manager. I can also install a package manager into the nested Gentoo and build/install stuff while "inside" of it.

Re: Modern C++ Programming Course

#139
post #96
post #13

Any ideas where to start learning C++ as an embedded developer? I wrote many lines of bare metal C code and want to transit to higher level jobs. I see many expensive or completely free courses, but I am not sure which one is usable in my complicated situation.

It depends on what you target. I do alot of Kernel and really low level C++, and it's a completely different style than even app dev, so you have to be sure you don't go down the completely wrong route. For my target space, there's a few rules for c++. Footguns: A. No STL, it causes to much bloat when binary size is critical. B. (almost) No inheritance or virtual functions. Again, it causes some bloat and adds in som…

I would add constexpr (I guess it might be included with templates?).

You can do some nifty stuff like generate CRC lookup tables at compile time without hardcoding them.

Post reply on HN