Some experimental compiler builds (Calypso) can compile D for use with C++ libraries as complex as Qt.
You can start porting your D project to C by using DPP- it allows you to #include C headers within D- and use macros. Putting "extern(C):" at the top of your file let's you interoperate between C and D.
Andrei Alexandrescu wrote Modern C++ Design, and is the co-captain of D. The captain of D created the first end-to-end C++ compiler.
Still, long compile cycles are my kryptonite... 0 productivity. Horrible. Back when I was doing java, I patched hibernate to serialize and deserialize the generated code, so startuptimes would be lowered with about 80%.
My setup back then used hot code replacement, but so many people would just simply wait 1-3minutes for every single change...
In comparison, CRT headers (when compiled as C, not as C++, as in that case additional C++ bloat is added) are usually a few dozen to a few hundred lines of simple declaration code. Compared to C++, it's very hard to make a C project compile slowly.
C++ does not have a BDFL like other languages, C++ evolution is governed by a committee. In other words, Stroustrup himself needs to submit any changes he wants to the committee and there is a vote ...
C++20 modules should partially solve the header processing problem, but it will take years until it will become widespread in big companies.
A very educational experience!
I think they're missing the point of why people use C - there's no magic. It's pretty much the wysiwyg of high level -> asm. If you want a systems language with magic there's C++. If you want a safe one there's Rust.
Personally if I were going to make C better, I'd add a better macro/template feature so you don't have to write generic code as a define block with slashes all over, something like Go's defer, and some low level stack unwinding support. Maybe tuples as struts with numbered fields, but no magic syntax sugar. And that's it. No crazy operators, type theory things, or anything that doesn't do exactly what the code says. Because then it's not C.
But what do I know?
Strict aliasing and weak typing say hello.
> wysiwyg of high level -> asm
Except neither GCC nor Clang compile even remotely predictable ASM. It's easier to predict OCaml assembly output than the GCC's one.
What do you mean by weak typing? That can you cast away basically anything?
>It's easier to predict OCaml assembly output than the GCC's one
Surely you are kidding. If that were true, why doesn't OCaml curb-stomp C in benchmarks? IMO GCC's output isn't even a little surprising, esp. once you've gained experience with its favorite optimizations.
- casting away types unsafely is required for many common patterns in C, including any form of runtime polymorphism
- basically anything involving numerics has a good chance of happily casting for you without asking you or telling you
Which patterns? I'm thinking of stuff like the Berkeley Sockets API, which you can absolutely implement safely.
re numerics: fortunately, that's 100% amenable to static analysis (see -Wconversion, -Wsign-conversion in gcc/clang and coverity's warnings about potentially unsafe casts - e.g. promoting an int to a long is always safe, but an int to a float not necessarily) and follows very straightforward rules.
Exactly because nobody (except backend writers) can predict what C compiler backends emit, especially when abusing undefined behaviour.
I've never actually looked at the output of an OCaml compiler, I have to say I'm surprised by how clean it is. But I wouldn't call it more predictable than that C's output.
You forgot about -O2/3.
You are confusing predictability with performance. OCaml is way more predictable exactly because it generates way more straightforward code.
On the other hand, GCC could do all kind of stuff, generating any sort of assembly. It can even rewrite fairly complex math functions, simplifying them.
Parent was talking about predictable ASM, not about performant ASM.
"No magic" is meant as shorthand for "the minimal amount of magic we can reasonably expect given the history of the language and requirements for backward compatibility, and the least magic of any high level language with more than 3 users." Please don't make me do this again for the number 3.
It's not about magic, you were talking about
> It's pretty much the wysiwyg of high level -> asm
which is not true until you use some ancient compiler from bell labs era. Modern C compilers emit totally unpredictable asm.
Everyone with this opinion needs to read this[0].
This is why it was not rare to see defense company or Airbus financing those research.
To make the time even harder, in that niche space, you already have decent enough languages like Nim and Zig etc.
So yeah, the market is really pretty saturated, I don't even have time and project idea to try them all, let alone bring them to work.
In the age of Go and Rust, which already have a hard time finding niches, I don't really think there's any room for a language like this. And on the other hand, from a research standpoint, it's probably a lot more interesting to build a new language from the ground up.