144 points · by crazypython · 5y ago · 127 comments
As of today, there's only one important looking thing left implemented in D.
So...
I like the idea of using D with a garbage collector and having something like GO, and then turning it off when I want to do something more performance oriented.
How is the performance of D compared to other garbage collected languages when the garbage collector is turned on?
The GC itself isn't very good. The overall language performance, though, is quite good; the allocator isn't usually a bottleneck.
It is a worthwhile tradeoff for fully GC languages like Java. But it isn't worthwhile for D, which uses GC here and there and a lot of non-GC pointers and allocations. D trades things off in the other direction - faster runtime code generation, at the cost of a slower GC.
The more pointers you need to scan, the slower it becomes, and it'll stop all threads
It's fine for a compiler or a cli tool, but it's very bad for anything that runs forever and needs to scale (server and games, specially networked games where the world and number of entities is not fixed) you then need to think about managing your memory and working around the GC a lot; then you think about yourself, why use GC at all..
D needs invest more into non GC stuff and making the GC trully optional, make it possible to link the GC away if you don't need it, make the runtime less dependent on GC (ability to statically make GC usages assert such as 'new', rework associative array, and cleanup the runtime from requiring GC, thread, socket etc etc etc)
I use D everyday, i know how to deal with that kind of issue, but new people don't, and they might be turned off the day they need to workaround GC issues
Won't this depend on the programming style used? If the programmer makes heavy use of functional programming, or for that matter Java-style programming, wouldn't that result in a lot of object churn through the GC?
I'm pretty sure the D guys figured it out, but i'm really curious to see what's the end result in the real world, once it reaches the dirty hands of end-product developers :))
But in most cases, most people will likely just need custom allocators, or just malloc. You can generate arbitrarily less garbage in D progressively.
Mixed allocation strategies is still nice because whatever is in GC memory doesn't need an owner (it has a global owner). Nowadays, the D GC is really unlikely to be a problem whatever your performance requirements. It isn't a problem for corporate users, as you can see on the parent link. Besides the GC performance increased in the last few years.
"Pluggable" GC-based arenas could make it work quite well. People routinely use ECS (entity-component systems) frameworks in GC-less languages like Rust that could mesh quite well with GC.
You do need some extra glue to harmonize the GC-based and GC-less paradigms (such as adding new "GC roots" for any GC'd objects that are being kept "alive" via links from non-GC ones, and demoting them when the references are dropped) but it's quite doable. Rust will probably get facilities for this once "local allocators" are added to the language in a reasonably stable form.
Lots of D code is fundamentally lazy.
For example, chain can be used to "concatenate" two arrays without allocating a byte.
Realistically programming languages take time to adopt culturally but they aren't that difficult
D, C++ (and also C# and Java) are very similar languages. If you learn any of those, learning the others will be easy.
C++ is just the most complicated because of the accidental complexity of the language.
C++ is much closer to something like OCaml than to C or Java.
The "complexity" is not accidental, and it only seems complex because people are not used to languages with static typing systems. C++ is not complex if you mastered something like the Haskell type system.
(C and Java aren't really statically typed; they rely on run-time typing for polymorphism.)
Dude, C++ can still compile C code, right? And how are C++ templates anything like Haskell or OCaml? Aren't they just some fancy text-based code generator thing, at the end of the day?
I'm really curious about this as everything I've seen so far contradicts your perspective.
Or are you talking just about modern C++ (post C++ 11)? That doesn't work as C++ of all kinds is out there in the wild and you'll run into it, at least from external dependencies.
Um, what? Having type information available at runtime is orthogonal to whether or not a language is statically typed.
D also makes generating code at compile time extremely easy which is a performance win at the expense of some compile time (no free lunch) but once again you slide the scale easily as the code the generates it is the same as at runtime.
There are two real backends one can use for these kinds of things, or one for Rust (LLVM) and friends.
Each has their strengths and weaknesses, and some users even switch back and forth depending on what they need at the moment.
I myself am not in the "move to ldc" camp, I like having dmd available for speed.
Oh not to mention it has C interoperability and a native cross-platform GUI library.
People can be very generous in their donations, but consider that Google probably spend 10M a year on Go - of D and Go, regardless of which one you prefer, which one makes you think.
Symmetry seem to be perpetually hiring (The management fee alone on 6Bn must be quite a lot), so worth asking around.
Are there other/any languages that do this?
D is not a simple language, but the solutions it chooses are usually very simple - for example, D has unit testing in the language, this is maybe a day's work in most compilers and yet not many others do it.
It's the same with the builtin documentation generator.
The syntax of the documentation generator is also far more convenient than JSDoc or JavaDoc.
As an individual programmer, it is pretty cool being able to write web apps and homebrew video games with the same language. For a company, you probably aren't going to be that varied, but it can still be good to dive into some special optimizations as needed.
Many of the organizations on this list use D for some combination of its flexibility. They have two areas of interest that need to co-exist and D lets that happen with minimal friction.
You can do that now. Technically the binary contains an embedded runtime, but is that really much different?
Full AOT is possibly coming with the next version of .NET, mainly aimed at non-JIT-capable targets, such as WASM and iPhone. Currently they only work with Mono due to lack of AOT in .NET 5.
60mb + for a HTTP server is not what i call a single binary without runtime
at best it is called packing giant runtime together with user executable hack
and their AOT story is far from being perfect, it has to deal with the fact that C# is a managed language first
so exit system programming needs, it's just not playing on the same field
c# is aimed at webdevs and game scripters with unity
And most importantly, to be able to use a platform that has pretty strong guarantees about backwards compatibility and that is able to run code from 10 years ago without modification, as opposed to D where even a minor version update can end up breaking D's own standard library.
Certainly D has a niche of users who are very passionate about it and for those guys, all the power to you guys and don't bother listening to me... but for most of us, well after 20 years it really hasn't established itself as a reliable language to use beyond that niche. It's no longer 2005, a time when C++ was stagnating and there was a lot of opportunity for a new programming language to sit some where between Java and C. Instead of being released with a roadmap, some promising libraries and frameworks that establish a clear use case where D could shine, and a license that allowed broader community involvement in the implementation of the language and its standard library, it was released as a proprietary compiler that ended up quickly resulting a very fragmented community with a lot of infighting, many missteps and mismanagement made on the part of D's leadership the result of which is that D lost on the order of 5-10 years worth of progress for nothing.
It's now 2021, C++ has advanced significantly since those days, there's many new languages such as Go and Rust that have taken the steam out of D and are progressing far more rapidly... and D, which at one point in time was actually innovating on language design, is now constantly trying to play catch up with other languages and implementing half-assed features. The language is often referred to as a kitchen sink of functionality and I kid you not when I say D is literally in the process of working on adding a quasi-borrow checker to the language just so it can keep up with Rust.
[1] https://pointersgonewild.com/2014/09/09/ds-garbage-collector...
Libraries have never been an issue for me. You get all C libraries trivially, so to the extent that C has libraries, so does D. I also embed R inside my D programs, so I get access to every R library. And if you want to object that "R is slow", I'm not talking about only calling R, I'm also talking about calling R bindings to C++ libraries without having to involve R. I suppose there would be some marginal benefits to having everything written in D, but many people seem more than happy to use languages like Python that access functions written in other languages.
> And most importantly, to be able to use a platform that has pretty strong guarantees about backwards compatibility and that is able to run code from 10 years ago without modification, as opposed to D where even a minor version update can end up breaking D's own standard library.
Breaking changes are not that frequent. You're right, though, if you have a zero-tolerance policy with respect to breaking changes, you can't use D or any other language that has breaking changes.
> it was released as a proprietary compiler that ended up quickly resulting a very fragmented community with a lot of infighting, many missteps and mismanagement made on the part of D's leadership the result of which is that D lost on the order of 5-10 years worth of progress for nothing.
You're referring to things that happened before the pyramids of Egypt were built. Why would someone that has no interest in the language spend time writing comments about ancient, ancient history on Hacker News?
That's certainly a big factor of the network effect. Although, I have to say that I'd probably rate this higher for almost any other popular language than for C# and Java, as with the latter it's quite often that your corporate overlords don't just let you use any library willy-nilly.
Then again, if you're in such a situation, it's quite likely that you don't have a free choice of your language, either. (Unless in weird corner case situations where you could deploy a binary but not depend on a current C#/Java runtime, and your company wouldn't shell out for an AOT C#/Java compiler just for this lone project.)
I do miss Design-by-Contract in every language that doesn't have it, though. And using D might be slightly more likely than using Eiffel…
It is a borrow-checker, and it's a good idea, if you disagree go and write C
An IDE that works amazingly well, autocompletes everything and can refactor everything across many files (D will never get there because it makes heavy use of code generation).
A much more stable and battletested compiler and a surrounding ecosystem. Wealth of libraries for each task, from game to web development.
A lot of work opportunities in C#, not as many in D.
Because of popularity, it's easier to attract other developers to your project.
Missing:
- native compilation, of course
- mateprogramming, ctfe, mixin etc etc
- raw performance
- free c/c++ interop
- optional GC
- manual memory management
At best it is a Java clone that tries to eat NodeJS cake at the same time, but is then eaten alive by GOLANG
C# is plagued with enterprise bullshit (OOP, dependency injection, factory bullshit, one class per file bullshit, etc etc etc)
Worse, it only has a JIT, no AOT native compilation (there is one compiler but AFAIK Microsoft is focusing on JIT) so it can't do system/native development at all
There are plenty of AOT options for .NET, better improve your knowledge.
> - mateprogramming, ctfe, mixin etc etc
Attributes, reflection, compiler plugins, T4 templates, code generators
> - raw performance
So how does D stand in Techpower benchmarks or gRPC serialization performance?
> optional GC
If you know how to actually program in C# you also get some ways of doing it, even more so in C# 9.
> - manual memory management
Available since C# 1.0 via Marshal namespace.
I like D, but lets not pretend C# in 2021 is the same when Alexandrescu wrote the D book.
This is a pretty silly point to make (D also has the other things). D does this in the language and is specified as such - not at runtime, not with compiler extensions, but with actual D code.
And referring to web benchmarks is a poor measure of the language because they are about web framework performance. Weka.IO make apparently the world's fastest file system in D, so there's that.
C# as a language is not working great in AOT environment due the managed and runtime features of the language
that is the reason they are unable to strip more stuff from the executable, it's a mess
so having AOT compilation doesn't mean it's automatically good, when it's bad experience, you have to say it outloud or nothing will improve
everyone can add AOT compilation as bullet points just to pretend the language is capable, because it's obviously not, prove me wrong if you can, but i doubt you can, i have tested, and results are not good, at all
C# supports limited manual memory management through unsafe and manual memory allocation methods, but this is primarily aimed at C/C++ interop. Newer performance oriented features like stackalloc and Span/Memory give most of the benefits of manual memory management without the dangers.
Performance of .NET on Linux is on average better than Java and Go.
Mono has an AOT implementation and Microsoft are expected to release one soon.
C# normal coding style may not be to your preference, but it's become a lot less "enterprisey" in recent years. XML is nowhere to be seen any more, for example.
But yes indeed it's not a very good language if you're wanting to directly manipulate registersand hardware addresses.
so no, real performance scenarios, .net don't do better than GO wich is AOT compiled
mono performance is very bad actually
generics isn't playing on same level as metaprogramming in D, not even close to templates in C++, even Rust do better here
using roslyn compiler API is nice, but again, it is not the same as using the language itself already, the experience is different, it is on other hand much better than what GO has to offer