4 ms·
Hello waddlesplash! C++ finally has modules as of C++20. Do you think there's any chance that the Haiku source code will be organized around modules instead o
by dharmatech 5y ago
Hello waddlesplash!
C++ finally has modules as of C++20.
Do you think there's any chance that the Haiku source code will be organized around modules instead of header files at some point?
- desi_ninja 5y agoI think they would prioritise basic issues first before refactoring the code
- waddlesplash 5y agoHonestly, I have no idea, because I have not even so much looked at what the actual implementation of modules is like in C++20 yet. Haiku uses almost none of the STL as it is, we write almost all our own containers and use C++ merely as "C with Classes" more than anything else. I think if we had sufficient time and energy, we might have started our own programming language that takes a lot from C++ but would diverge sharply after the "C with Classes" part (we have joked about it before, at least.) For one, some of the paradigms we use a lot in Haiku might serve well as baked-in language features, or could be taken further with compiler support. Memory safety is also another big one; I know Rust is now the "C++ successor with memory safety," but at least to me I think it does not quite fit the bill; though we have an especially esoteric view of what "C++" is (notably I haven't put in the time to really learn Rust, honestly, though some of the other Haiku contributors are fans, and the Rust port to Haiku is sufficiently solid at this point) The biggest thing I think we would ultimately change in any wildly hypothetical programming language we might come up with, though, would probably be ABI stability. C++ is just a huge pain to keep ABI-stable (C is as well, to a lesser extent), and there are all kinds of tricks that are clearly possible now in compilers, in ELF, etc. that there is clearly room for a slightly different language design coupled with a radically different language ABI to make ABI stability much less of a chore to maintain. (We are very big on dynamic linking and stable ABIs, something Rust seems to have basically given up on if it ever really tried, and the same in Go and other newer languages.) I would imagine that modules instead of headers might come about as some kind of development along with ABI stability if nothing else.
- dharmatech 5y agoWow, thanks for sharing all of that, waddlesplash! Interesting to know there's an desire to maybe move beyond C++.
- zozbot234 5y agoRust has optional support for the stable C ABI. I'm not sure what you mean by the C ABI being "a huge pain to keep stable"; it's simple and the requirements for stability are well known, it's also the main choice for FFI in a variety of language ecosystems.
- pjmlp 5y agoBecause in reality there is no such thing as C ABI, only the OS ABI. On OSes that happen to be written in C, most devs tend to misunderstand the OS ABI for C ABI and then use both interchangeably. A new OS update can bring changes, also on platforms whose OS isn't written in C, several C compiler can opt for different kinds of ABI thus not allowed for cross compiler linkage without extra steps.
- waddlesplash 5y agoThe requirements for stability being well known do not make them easy to follow. If you really want stability, you basically have to eschew all use of structs, or add struct versioning, to begin with. Then you can't add or remove parameters from functions, but instead must add new functions only. Those are of course just the first two things; in practice, most libraries do not even try to follow them, and just bump the SONAME version with anything besides a minor bugfix release.