130 points · by ingve · 10y ago · 75 comments
Why D?
AMA aswell I guess :)
It appears monolithic. There's actually very little content about what it's design goals are, what it's trying to accomplish, or even what interfaces it'll support. I'm assuming POSIX because everyone loves to re-write UNIX and there is a boat load of documentation/implementations and most of these are monolithic.
I'd assume an Object-Oriented language would be better at implementing a microkernel. Objects, in my mind, really represent the idea of a service well so I'd be excited to see what it would look like.
Too bad we're never going to get out 128 core SPARC machines with an open-source microkernel like was prophesied in the Linux-MINIX debate.
Maybe it could even be done with just one small but critical portion and linked, so it isn't such a monumental task.
I would rather see someone take D, Rust, Swift, whateverX and implement something modern, following the concepts explored at Xerox PARC, ETHZ and MSR in terms of OS architectures and development environments.
Supporting POSIX is necessary if the designer wants the OS to run real software.
Pjmlp (correct me if I'm wrong) would rather see exploratory endeavors rather than Yet-another-POSIX-impl. (And for the sake of argument, should that new platform garner steam and you absolutely, 100%, completely and totally need POSIX support! you can get pretty far creating PE/ELF on a non-POSIX OS with an emulation layer with ~3-4% overhead[VMware had a few whitepapers on it, and Unity is a component in production that demonstrates such behavior])
And if he were motivated enough to write a POSIX impl from scratch, while not trivial, it shouldn't be too hard (see: BusyBox, Yocto/Poky, hell, remember the NetBSD days? Any idiot could port to platform foo in a weekend.)
Do you consider iOS, Windows, ChromeOS, Android, IBM i, z/OS, Unisys MCP toy OSes given their architecture and minimal use of POSIX?
POSIX only defines the necessary to write CLI and daemon software, nothing more.
What I consider real software is a bit more than that.
I never felt the need for POSIX when I am not using C.
Or are you suggesting more of an 'embrace and extend' thing, where a new OS supports POSIX for backwards compatibility but adds whatever new API(s) and then tries to grow adoption of those slowly?
I've used both, but can't claim to be much of an expert in either.
Similarities:
• Compile to fast, easy-to-deploy native code
• Abstraction continuum ranging from very low-level C-like style to a high-level more functional style
• Very easy to call C libraries from
• Type inferred and generally less syntactically noisy than C++
Neutral differences:
• D is garbage collected; Rust has a novel memory management system based on linear types. This means D can never compete with Rust in performance and real-time or soft-real-time systems. On the other hand, it means with Rust you will spend more time thinking about memory ownership and other important-but-eliminated-by-GC concerns. Both are easier to deal with than C or C++.
• Syntax: Rust's syntax is not-quite-C-like; D's is very C-like. It comes down to personal preference. I prefer Rust's.
D advantages:
• Metaprogramming: D's metaprogramming is more or less unmatched, though I haven't experimented with Rust compiler plugins at all. You can probably do some funky stuff with Rust, but it doesn't feel as integrated into the language as with D.
• Compiles super fast.
Rust advantages:
• Type system. Rust's type system is ML-esque and generally much more powerful. I suppose this might not be an advantage to everyone, but personally I love how ML-y Rust feels.
• Concurrency.
• Ecosystem?
I think ultimately my choice is that if I'm going to use a compiled GC language, I may as well just use OCaml. D's memory management, or lack thereof, kills it for me personally, but it's a well designed language otherwise IMO.
- http://dlang.org/phobos/std_concurrency.html - http://dlang.org/phobos/std_parallelism.html - http://vibed.org/
std.parallelism and vibe.d in particular are absolute pleasures to work with. As a framework, vibe.d is well designed to avoid unnecessary allocation and runs very efficiently.
D's current GC is quite poor, that's a common complaint. But the recent and forthcoming "nogc" changes are making a significant difference -- it's increasingly easy to avoid the GC altogether.
I think an important wrinkle here is that Rust's ownership model helps prevent many runtime-errors other than memory safety. I'm not sure how D handles problems like iterator invalidation, but I've found it really nice to always know what's able to mutate the state when in a given variable.
1) While the majority of all users will profit from the convenience of the GC, it's not a big deal to use D without a GC. (apart from this kernel, another famous example is the next-level large-scale storage company Weka. They have had such real-time concerns that they invented their own Ethernet protocol - more details: http://dconf.org/2016/talks/zvibel.html) Moreover since last summer D got an amazing support of allocation building block with it's new Allocator API: http://dlang.org/phobos/std_experimental_allocator.html
2) What's Rust's advantage on concurrency? This can be done quite well in D too, see e.g. this book chapter: http://www.informit.com/articles/article.aspx?p=1609144
There are a couple of advantages of D that are important to me and you didn't mention: - error-saving contracts (builtin unittests, assert, in & out blocks, invariants) - OOP (abstract classes, interfaces, ...) - mixins & code generation - compile time function evaluation and introspection (this makes your code even faster) - clean syntax & style (@property methods, lambdas, ...)
As for using GC in a systems programming language, even last a few days ago we had the links from Xerox Star. Originally developed in Mesa, which eventually became Cedar, that made use of GC.
Also the whole set of ETHZ Oberon workstations.
And many other experiences.
The oldest I can find is a Flex computer system developed by the UK Royal Navy in Algol-68RS.
I am pretty convinced, that just like e.g. JavaScript performance, there needs to be someone with enough money to bully the industry with such technologies until they stop being tabu.
I still remember reading from C guys on Usenet that C++ would never be usable for writing OSes.
Yet there are quite a few of them now.
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.
Rust, for example, can be used to write a C-like loadable or linkable module for some other system (JNI, Ruby, Python, etc) with a very tiny or nonexistent runtime required.
Having a GC makes this a little less seamless.
You can write programs in D that have ZERO garbage collection.
In fact, the core libraries (phobos) are being actively rewritten to remove GC altogether.
> I think it is not necessary to validate data you are not using. So basically
> I only scan them so much as to find where they end. Granted it is a bit of
> optimization for a benchmark, but is actually handy in real-life as well.
> After all you could still raise the validation level to maximum if you really
> cared or call one of the validation functions.
https://github.com/kostya/benchmarks/pull/46#issuecomment-14...And yes, I'm aware that Phobos is being rewritten to remove GC. I'll reevaluate D when that's complete.
To any Rust pros here, I'm curious: how long did it take for you to really get to grips with the language, coming from say, a C/C++ background?
In saying that, as with any powerful type system there are always going to become some confounding cases, but for me the trade-off is worth it. It also makes the complexity of your domain more evident up front with shifts experimentation to the compile time phase as opposed to the run-time phase. I prefer the former though, because it is always a joy to have your code compile after a big refactor, and have it run pretty much as you expect.
Facebook uses D a lot internally IIRC, although I'm not sure if many of the tools they made have been open-sourced.
[1] https://www.quora.com/Which-language-has-the-brightest-futur...
> 10x better theorists. Of the three, Rust is the only language with world-class PL theorists on roster. This can be seen in the precise definition of the language and the depth of its technical approach
This argument impressed me. I'm sure Walter Bright does account for a fair share of D's popularity, though, so I take the 10x to mean in numbers :)
C++ was about "We get things fixed, I promise!"
D was about "We get shit done!"
Go was about "We are good enough!"
Rust was about "We try new shiny things!"
(Also, the person who was in the video you're talking about was Niko Matsakis, not Graydon. And it was August 2014, so, so much has changed with Rust since then.)