5 ms·
I didn't say D wasn't suitable for writing OSes. Might as well throw Singularity into the list of GCed operating systems. I did say D is unsuitable for real-ti
by PeCaN 10y ago
I didn't say D wasn't suitable for writing OSes. Might as well throw Singularity into the list of GCed operating systems.
I did say D is unsuitable for real-time and soft-real-time programs, OS or otherwise. You can't write an RTOS in D.
- pjmlp 10y agoSure, I was just kind of brainstorming how much better GCed operating systems could be. As for RTOS, maybe you eventually could assuming future major improvements and compilers like the Atego JDK, but there is little to gain versus what Ada, SPARK and eventually Rust already offer today.
- Matthias247 10y agoFor hard realtime systems most kinds of dynamic memory allocations are a no-go. A lot of programs with such requirements have everything statically allocated, others use some static memory pools and custom allocators that those. I think that should also work with D - with the problem of losing lots of the standard library. I think the most problematic area is somewhere in between: Applications that want a mostly realtime performance without having to put too much work on guaranteeing it (e.g. Games, Low Latency Audio Processing, ...).
- WalterBright 10y ago> You can't write an RTOS in D. Can't is a pretty strong word. You can write C-style code in D that compiles and behaves identically to C, including malloc/free.
- PeCaN 10y agoI… I just got corrected by Walter Bright. That's true. You actually can write an RTOS in D, and it would still be more pleasant than in C (thanks to D's excellent metaprogramming). The problem I have with opt-out GC in D is that it leaves you with very little else as far as memory safety goes—you have RAII, but nothing like Rust or Cyclone or other languages that are explicitly safe without a GC. You can leak, you can crash, you can have race conditions, etc, almost as easily as in C. Some sort of D version of unique_ptr would get you part of the way there, but it's still not as complete as Rust.
- WalterBright 10y agoD does have @safe, which does a good job of preventing large classes of unsafe pointer issues. It is not perfect yet (we're working on it) but it is far better than "nothing like", and far better than C/C++. For example, it does array bounds checking.
- PeCaN 10y agoInteresting, I didn't know about @safe. I need to study D more! At the moment I'm pretty happy with OCaml and learning Rust, but D definitely has me interested (especially when the no-GC stdlib completes).