News for hackers. Stuff that matters.
Re:Modern C++ for C Programmers (2018) by ratorx on Friday July 23, 2021 @08:22PM (#27937280)
It’s not just about writing code though. If you want to properly read code you have to understand all the “advanced” features they have used.

I’m reasonably familiar with C++, but not so much with arcane template meta programs. I never write templates, but it still trips me up from time to time when I have to understand one.

Re:Modern C++ for C Programmers (2018) by truncate on Friday July 23, 2021 @08:31PM (#27937343)
Yeah. All the arcane template stuff, even if I understand for sometime, you're bound to forget it as soon as you stop using it (which you probably should in most times).

It reminds me, every time I try to jump too implementation of some standard library method/class, it just seems like a completely different language to me. And C++ is the language I've most experience with.

Meanwhile, I jump to some Rust or Golang* standard library implementation, it makes perfect sense very quickly. Even though I just use them for hobby projects.

* Go is probably a bad example because it doesn't have any generics. But still love how much more approachable their stdlib code is.

Re:Modern C++ for C Programmers (2018) by beached_whale on Friday July 23, 2021 @10:13PM (#27937851)
A lot of that is that you have to protect against name collisions. You have things like c macro's so methods need to be wrapped in brackets{e.g (min)( a, b ); } and also internal names need to be prefixed with an underscore and start with a capital (e.g _Foo) as that is reserved.

The global namespace still exists so unqualified names that do not have a reserved id( eg _Foo ) cannot be used and need to be qualified (e.g ::std::(min)( a, b );). All this to protect against us.

Some codebases are easier to read, I would rank them from libc++, MS STL, libstdc++ is readability. libstdc++ also seems to have code all over the place and use far more inheritance for composition of things.

Re:Modern C++ for C Programmers (2018) by ncmncm on Friday July 23, 2021 @10:48PM (#27938009)
There is no reason to use "arcane template meta programs" anymore. That is all old-C++ stuff needed to work around missing language and library features. It has been literally years since I coded or even (visibly) used any template meta program construct.

That's not to say it doesn't exist in the implementation of the Standard Library. I just never have any need to see any of it.

Re:Modern C++ for C Programmers (2018) by rightbyte on Friday July 23, 2021 @08:29PM (#27937325)
I guess the messy ugly template headers could be hidden as compiler intrinsics, like in Go with its compiler blessed generics for standard containers. Or how C's printf is implemented as compiler magic instead of vardiac macros.

The complexity needs to be somewhere in the end. A charitable view would be that Cpp's approuch is more ... inclusive?