Live data from Hacker News

Modern C++ Programming Course

github.com

141–150 of 221 posts

Re: Modern C++ Programming Course

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

Smart pointers should really be like, chapters 2-10.

In my experience, every useful C++ application requires wrangling some historic smart pointers implementation: Boost, Unreal, libwebrtc, Qt.

Even NVIDIA uses its own smart pointers (thrust::device_ptr) though that's understandable. Also there's stuff like this: https://stackoverflow.com/questions/65938991/how-to-use-lamb... for e.g. TensorRT.

Re: Modern C++ Programming Course

#143
post #96

Earlier quoted context omitted.

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.

Yes! 100% Right, can't believe I left that out. One of the big things is to make sure to use ConstEval if you can do a new verson of c++(20), since ConstExpr isn't guaranteed and can leave stuff in the binary that can hurt size or obfuscation. For example one thing I see alot is lookup tables for hashing who use constexpr and hide some key data in there, but it "may" just randomly do it, and can cause alot of issues.

Re: Modern C++ Programming Course

#144

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

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

I'd be really interested in a write-up of your setup with more details so I can try it.

Re: Modern C++ Programming Course

#145

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…

VS Code is designed to work with these - https://code.visualstudio.com/docs/devcontainers/containers

Re: Modern C++ Programming Course

#147

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

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

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

The thing is, you don't need to do this with Rust as far as I can tell. There may be some benefits, but ultimately your project can easily specify its own compiler version, its own target directory (the default is per-project), etc. There are some shared resources like caches, which you can split if you want to.

I can see why you'd still do this - but, the main reason would be... if you have dependencies on C/C++.

Re: Modern C++ Programming Course

#149

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…

[deleted]

Re: Modern C++ Programming Course

#150

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…

Maybe nix (https://github.com/NixOS/nix) is a better tool for what you're looking for if you're on Linux, you can setup nix shells and work in them, what's installed inside the shell won't be accessible from outside.
Post reply on HN