News for hackers. Stuff that matters.
Re:Trying out C++20's modules with Clang and Make by 38 on Sunday October 15, 2023 @11:24AM (#37890505)
https://wikipedia.org/wiki/Poe's_law

modern languages dont adopt them because they are terrible. a header import just dumps all the declarations into the global scope, so you have no idea where function or type usages comes from.

Re:Trying out C++20's modules with Clang and Make by jprete on Sunday October 15, 2023 @11:32AM (#37890574)
I consider them much worse than that. Header files are explicitly a copy-paste of the included text file into your source. There’s no rule that they have to only contain declarations, or that they have to appear at the top of source files, or that they have to be .h files. All of those are usage conventions and not required by the language itself. The full capabilities of headers to muck with your code are arbitrarily large.
Re:Trying out C++20's modules with Clang and Make by Galanwe on Sunday October 15, 2023 @12:28PM (#37891114)
It's the same for pretty much any language. There is nothing special about header files...

> There’s no rule that they have to only contain declarations

Same thing in Python, you can write statements at the top level of a module, and it will be executed whenever someone first import that module...

> or that they have to appear at the top of source files

Same thing in Python, you can `import` anywhere, and the context/order matters and overwrites existing scope declarations.

> or that they have to be .h files

Same thing in Python, the extension doesn't matter if you use import lib, only if you use the `import` keyword does the name/path matters.

Re:Trying out C++20's modules with Clang and Make by 38 on Sunday October 15, 2023 @01:14PM (#37891539)
> It's the same for pretty much any language.

no, its not. just off the top, I can say that D, Go, Nim, Rust and Zig dont do this.

also this isn't really an argument. instead of actually disagreeing with the original premise "headers are terrible" (which you cant), you've started a new argument, which is "other languages use headers", which no one was contesting.

Re:Trying out C++20's modules with Clang and Make by rsaxvc on Sunday October 15, 2023 @01:14PM (#37891533)
That's the best(weirdest?) part! I used to have a job porting LabView and matlab to C/C++, since headers don't even have to include full statements, so share our test data and coefficients like so:

static const float FIR_FILTER={ #include "fir_coefs.csv" };

Re:Trying out C++20's modules with Clang and Make by mathstuf on Sunday October 15, 2023 @05:36PM (#37893605)
FWIW, the `#embed`/`std::embed` proposal is the preferable solution here. There's a lot of time spent in the compiler parsing those ASCII floats into bytes (and I've seen `clang-format` take ages to format a block of `0xXX` bytes in an array).