[HN Gopher] Features of D That I Love
       ___________________________________________________________________
        
       Features of D That I Love
        
       Author : vips7L
       Score  : 35 points
       Date   : 2025-07-02 16:45 UTC (6 hours ago)
        
 (HTM) web link (bradley.chatha.dev)
 (TXT) w3m dump (bradley.chatha.dev)
        
       | Alifatisk wrote:
       | I like D, it's fascinating and powerful language. It made it even
       | more curious when I watched Tsodings video on D. One thing that
       | came to my mind when reading the article is that things like
       | int.init instead of 0 and $ as shorthand for array.length does
       | add to the mental load.
       | 
       | One good memory I had is a couple of years ago when I built a
       | little forum using D. Man the site was blazing fast, like the
       | interaction was instant. Good times.
        
       | OskarS wrote:
       | The "invariants" thing is fantastic, I haven't seen anything like
       | that before and it's great. The C++26 contract stuff is fine, but
       | this seems like a really great way of ensuring type invariants, I
       | think I'd use this way more if it was in C++.
        
         | almostgotcaught wrote:
         | > Invariants are functions that run at the start and end of
         | every public member function
         | 
         | these are just runtime assertions
         | 
         | EDIT: how am i getting downvoted for copy-pasting literally
         | what the article verifies?
        
           | jayd16 wrote:
           | I think there's something to be said about them running
           | automatically that is lost when you say they're just asserts.
        
           | readthenotes1 wrote:
           | Maybe it's the editorial "just"?
           | 
           | Like: software programs can't be that difficult to create
           | properly because they are just 1s and 0s.
        
         | destructionator wrote:
         | Just a personal anecdote, Walter Bright's Digital Mars C++
         | compiler also had the contracts (D started life almost
         | literally as recycled code from Mr. Bright's other compilers -
         | he wrote a native Java compiler, a Javascript 1.3 stdlib, and a
         | C++ compiler with a bunch of extensions.... smash those
         | together and you have the early D releases!).
         | 
         | Anyway, I used the DM C++ compiler originally because it was
         | the only one I could download to the high school computers
         | without filling out a form, and pimply-face youth me saw
         | "DESIGN BY CONTRACT" at the top of the website and got kinda
         | excited thinking it was a way to make some easy money coding
         | online.
         | 
         | Imagine my disappointment when I saw it was just
         | in/out/invariant/assert features. (I'm pretty sure D had just
         | come out when I saw that, but I saw `import` instead of
         | `#include` and dismissed it as a weenie language. Came back a
         | couple years later and cursed my younger self for being a fool!
         | lol)
        
         | 12_throw_away wrote:
         | Yeah, these look excellent. Am curious if D's invariants can be
         | traced back to Ada/Spark at all (I don't know much about Ada
         | except that it has these sorts of safety features).
        
       | eric-p7 wrote:
       | It's a mystery why D isn't far more popular than it is. Fast
       | compilation, familiar syntax, and supports a wider range of
       | programming paradigms than most (any?) other language.
        
         | nickpp wrote:
         | Lack of large "sponsors".
        
         | zem wrote:
         | scala is probably the poster child for supporting every
         | paradigm you might want to use :) oz/mozart has more but that
         | was essentially a research/teaching language specifically
         | designed to use a wide range of paradigms in order to
         | demonstrate them.
        
         | nicoburns wrote:
         | I'd say that the compiler not being open source during the
         | period when it might otherwise have become popular is probably
         | a pretty big factor.
        
           | destructionator wrote:
           | The D parts of the compiler were released under the GPL from
           | almost the beginning, since 2002. By 2004, a full open source
           | compiler - what we now call gdc, officially part of gcc - was
           | released using this GPL code. D was pretty popular in these
           | years.
        
         | Keyframe wrote:
         | I spent quite a few year on/with it back in the day. There was
         | D1 which was like a better C, and then there was D2 which was
         | like a better C++. Personally I preferred where D1 was going
         | (and Tango instead of Phobos) but even with D2 it really made
         | the day compared to what was out there and to this day still to
         | an extent is. The thing that killed it for me, and I know at
         | least a couple of friends as well (outside of internal politics
         | at a time) was what kills pretty much all exotics once you
         | start using it. Lack of (up-to-date) libraries / bindings and
         | tooling. At the end of the day that's what you do use for most
         | of the work you're doing anyways - libraries. So suddenly
         | you're doing all these bindings and battling tools instead of
         | working on actual problem at hand. This gets tiresome real
         | quick.
         | 
         | For some reason, and mostly that being Mozilla, Rust got quite
         | an initial kick to overcome that initial hurdle in haste. We're
         | not going to mention a lot of those libs are stale in Rust
         | world, but at least they're there and that kind of gives you
         | momentum to go forward. Whatever you're trying to do, there's a
         | non-zero chance there's a library or something out there for
         | you in Rust.. and we got there real quick which then encouraged
         | people to proceed.
         | 
         | That's just like my opinion, man.. but I think a key part is
         | that first lib bindings hurdle which Rust somehow went over
         | real quick for a critical mass of it; D hasn't.
         | 
         | Love the D though lol, and Walter is a 10000x programmer if you
         | ever saw one but it might be time to hang the hat. I can only
         | imagine how a community like Rust or I don't know Zig of those
         | up-and-coming would benefit from his help and insights. He'd
         | probably single-handedly make rust compile 100x faster. One can
         | hope.
        
           | steveklabnik wrote:
           | I spent time back in the day with D as well, incidentally. I
           | wonder if we crossed paths back then.
        
             | Keyframe wrote:
             | for sure we did, Steve! Sometimes multiple times a day
             | even, hah. Check out @keyframe2 on bsky or @keyframe on the
             | evil platform and let's reconnect.
        
               | steveklabnik wrote:
               | Ha, that was so long ago I can barely remember a lot of
               | it. I'll give you a follow!
        
       | mamcx wrote:
       | I don't use D but think that error handling is one major feature:
       | 
       | https://dlang.org/articles/exception-safe.html
       | 
       | In concrete, looks to me to be the only language that covers the
       | major ways to do it.
       | 
       | (In concrete the `scope` way is the one I found inspiring. . I
       | think the exceptions can go and be replace by it for langs where
       | exceptions are removed)
        
       | elcritch wrote:
       | > Syntax - UFCS (Uniform Function Call Syntax)
       | 
       | UFCS is such an underrated language feature. When you have UFCS
       | you can toss out 90% of the uses of methods in favor of just
       | plain ole functions. Add generic functions and concepts and you
       | rarely end up needing OO support.
        
         | jayd16 wrote:
         | If all you're doing is accessing public members, sure.
        
       ___________________________________________________________________
       (page generated 2025-07-02 23:00 UTC)