Please please please can we get rid of headers and have modules? I find it super annoying having to specify things half in one place and half in another. Unfortunately, there still seems to be a bit of disagreement on the implementation among the standards committee.
Modern C++ for C Programmers: part 5
41–50 of 82 posts
Re: Modern C++ for C Programmers: part 5
#42Please please please can we get rid of headers and have modules? I find it super annoying having to specify things half in one place and half in another. Unfortunately, there still seems to be a bit of disagreement on the implementation among the standards committee.
Re: Modern C++ for C Programmers: part 5
#43Earlier quoted context omitted.
C compilers can do copy ellision when inlining code as long as the result is identical. That's not quite the same thing as RVO, which deliberately relaxes the notion of "identical result" such that it's possible to write C++ code to detect whether or not RVO was actually performed. That's not possible in C (or shouldn't be).
It's possible that I'm missing something, but I believe that the result is necessarily identical in C, because there can be no observable side-effect of a struct copy in the C abstract machine.
Re: Modern C++ for C Programmers: part 5
#44Earlier quoted context omitted.
It's possible that I'm missing something, but I believe that the result is necessarily identical in C, because there can be no observable side-effect of a struct copy in the C abstract machine.
Don't quote me on this, but I think padding bytes might have different values in certain cases.
Re: Modern C++ for C Programmers: part 5
#45Earlier quoted context omitted.
Also if Rust is not cutting it yet in your specific niche.
I find D to be a good tradeoff between C++ and Rust. I can't stand not having compile-time evaluation, code generation and reflection in Rust and C++ is just too slow to iterate with.
I actually think I forgot how to program in C. It lacks almost every data structure I'd deem useful to getting complex and mixed problems solved quickly. C++ provides many things and is useful if you are in a tight spot or you want/need the speed.
If Rust keeps evolving at a quick pace I think I'll look into it a lot in the future.
D seems to me like a good thing that is better in many ways but has some critical drawbacks for me like not working on many microcontrollers (an area where C++ really shines). On the other hand it isn't radical enough to really dive into it.
Re: Modern C++ for C Programmers: part 5
#46Earlier quoted context omitted.
Includes mixed with #ifdef leaks state across module borders and the whole C preprocessor feels like a dirty hack. What a header actually does depends on compiler flags, #defines from other files and then the order in which you include things as one header file might define something that changes the behavior of another header file. The compiler loses state in between C++-files and caching precompiled header files wa…
Compiling Chromium, the biggest C++ project I know, takes on the order of 8 hours with a somewhat old but quite powerful server. Linking Chromium on my laptop, with 8GB of RAM, required me to increase my swap space from 8GB to 16GB. Going away from C's linker and header file-model, which really doesn't work well for C++, to something based on a proper module system, would be amazing.
Having modules in C++ smells like the connector we're missing in order to accomplish something like that.
Re: Modern C++ for C Programmers: part 5
#47Please please please can we get rid of headers and have modules? I find it super annoying having to specify things half in one place and half in another. Unfortunately, there still seems to be a bit of disagreement on the implementation among the standards committee.
Single-file header libraries are actually all the rage in C++ these days. Here's[1] a list even! [1] https://github.com/nothings/single_file_libs
That single file is the substitute for a package that you can simply put somewhere, include it and it works.
Re: Modern C++ for C Programmers: part 5
#48is there a modern C++ for python programmers? i have ~5 years programming in dynamic/interpreted (python/js) and compiled/gc'd(java/go) languages and i'd like to learn a systems language. i'm reading the rust programming book (and it's really good/easy to grok) but i'd also like to learn C++. the problem is that most books are either too easy (C++ as your first language) or too hard (straight into RAII and templates)…
Yes! And be careful and very picky about what you read! To quote a popular Quora answer [1]: "If you really want to learn C++, I advise against any and all online tutorials and against most books. Without any kind of quality control, many professional book writers published many awful C++ textbooks that may be easy to read and sell well, but teach lies. Stick with the community-verified book list available at StackOv…
Re: Modern C++ for C Programmers: part 5
#49Earlier quoted context omitted.
Single-file header libraries are actually all the rage in C++ these days. Here's[1] a list even! [1] https://github.com/nothings/single_file_libs
This is what you get if you're missing a proper package management that allows users to easily install their libraries. That single file is the substitute for a package that you can simply put somewhere, include it and it works.
Re: Modern C++ for C Programmers: part 5
#50Earlier quoted context omitted.
This is what you get if you're missing a proper package management that allows users to easily install their libraries. That single file is the substitute for a package that you can simply put somewhere, include it and it works.
It takes all sorts, but I prefer the headers. Each project’s copy only gets upgraded explicitly, the debug info is always there, single stepping always works, there’s never a problem with ABI/compiler option mismatches (and you get the unoptimised version in your unoptimised build), anybody that gets the repo automatically gets all the dependencies too.