[HN Gopher] D 2.096 and other news
       ___________________________________________________________________
        
       D 2.096 and other news
        
       Author : pjmlp
       Score  : 97 points
       Date   : 2021-03-24 15:34 UTC (7 hours ago)
        
 (HTM) web link (dlang.org)
 (TXT) w3m dump (dlang.org)
        
       | crazypython wrote:
       | Daily downloads of D have been growing rapidly for some time now:
       | http://erdani.com/d/downloads.daily.png
        
         | mhh__ wrote:
         | They _may_ have trippled since that site stopped updating. I 'm
         | still working out what we can actually claim as traffic but the
         | unique IP count per day seems to have jumped by quite a bit
        
       | Shadonototro wrote:
       | D is exactly what i wanted C++ to be
       | 
       | I recommend everyone to try it out if you are fed up with
       | clunkiness and slow to compile C++
        
       | forgotpwd16 wrote:
       | How dependent is D nowadays on GC?
        
         | mhh__ wrote:
         | The GC is still a key part of the language _but_ it is
         | increasingly only used for things that you wouldn 't be able to
         | do without a GC anyway (e.g. if you want to pass a closure
         | anywhere without managing it's lifetime you need some kind of
         | GC).
         | 
         | Avoiding the GC has probably never been easier however, and D
         | is already very good at avoiding the garbage in the first
         | place.
         | 
         | I even work on/for D and I'm not a huge fan of the GC, but it
         | is also the case that these questions pop up on sometimes
         | almost quasi-religious grounds: The GC is just a tool, if it
         | gets in your way it's fairly easy to avoid in the sense that
         | _you don 't call in, it doesn't stop_.
        
       | gavinray wrote:
       | They've been putting a lot of work into an experimental automatic
       | C++ header generator lately.
       | 
       | https://dlang.org/changelog/2.096.0.html#dtoh-improvements
       | 
       | Each changelog for the last good handful has seen a lot of work
       | in this area.
       | 
       | I recently had to write and learn a bit of C++ for the first
       | time, and tried at all costs to avoid it (FFI/interop from Rust
       | or D).
       | 
       | I wound up biting the bullet and writing C++ but I learned a lot
       | about FFI in general and how interop works, plus your options
       | available in both languages.
       | 
       | D has this new experimental C++ header generator (which is
       | exciting), plus D has always had:                 extern (C++)
       | 
       | Which is capable of directly linking + invoking most C++ things
       | (except constructors/destructors, it can't handle those, you need
       | a function which calls the constructor from within C++) just
       | given a type definition.
       | 
       | Then you have "d++", which lets you "#include" C/C++ headers.
       | 
       | Under the hood tries to run an automatic syntax conversion. It
       | can't handle <std> but for simple code it works and can spit out
       | the equivalent D.
       | 
       | https://github.com/atilaneves/dpp
       | 
       | Also you've got "dstep", which is "A tool for converting C and
       | Objective-C headers to D modules"
       | 
       | https://github.com/jacob-carlborg/dstep
       | 
       | And finally you have the somewhat abandoned (but as far as I know
       | mostly functional) Calypso, which is a fork of the LLVM-based D
       | compiler that supports direct interop with C++. It's a pain to
       | build though, haven't gotten around to trying to build it, but it
       | does look wicked cool:
       | 
       | https://github.com/Syniurge/Calypso                   pragma
       | (cppmap, "cppheader.h");  // tells Clang to parse cppheader.h but
       | do not import anything            import (C++) NamespaceA.Class1;
       | // imports NamespaceA::Class1       import (C++) NamespaceA;
       | // imports the full namespace       import (C++) *;
       | // imports the entire translation unit
       | 
       | So I am hopeful about the future of the relationship between C++
       | and D. I would really have loved to have not written that C++
       | lol.
        
         | gmueckl wrote:
         | Where is that experimental header generator? Are you talking
         | about the -HC command line argument for dmd?
        
           | gavinray wrote:
           | Yeah, -HC from 2.091.0
           | 
           | https://dlang.org/changelog/2.091.0.html#headers
           | 
           | "DMD can now write C++ header files which contain bindings
           | for declarations in existing D files that were marked as
           | extern(C) or extern(C++)."
        
       | tastyminerals2 wrote:
       | I happily replaced my go to scripting habits of using Python with
       | D. Fast, fast, fast -- all I can say about its compile times and
       | data crunching capabilities.
        
       | EdwinLarkin wrote:
       | How's D for simple microservices where one would use Go?
        
         | Scarbutt wrote:
         | The must impactful difference is going to be
         | libraries/ecosystem. Go has a very rich ecosystem now.
        
         | virmundi wrote:
         | From hangin out on Reddit for dlang, the http server is pretty
         | slow. This has caused people to look elsewhere. Some people are
         | trying to improve the performance, but it's not a high
         | priority.
        
         | gmueckl wrote:
         | Check out vibe.d and the hunt framework. Both would probably
         | get you started in that direction. Vibe.d is quite powerful and
         | flexible, but might not be the easiest framework to get into. I
         | haven't used hunt yet. Last time I looked, I didn't find any
         | docs in a language that I could read.
        
       | mkhalil wrote:
       | Tangential to OP's link, I am suprised at how easy creating
       | Windows apps with gtkD is. I figured there would be a lot more
       | steps/configuring/etc. [0: Video link below]
       | 
       | Seems quicker to get started on a new app than Visual Studio +
       | W10 SDK? (or other offical MS Libs) Then again...that's not a
       | high bar when it comes to VS.
       | 
       | 0: https://www.youtube.com/watch?v=lLft7ynzers&t=410s
        
         | vram22 wrote:
         | gtkD easy only for configuring or for programming too?
        
         | bachmeier wrote:
         | Ron Tarrant put together this really nice gtkD blog with 111
         | posts in it:
         | 
         | https://gtkdcoding.com/
         | 
         | Pretty sure he used Windows.
        
           | pharke wrote:
           | Wow, that's an amazing resource. Thanks for posting it.
        
       | Zababa wrote:
       | The "Ecosystem Task List" is a good idea
       | https://github.com/dlang/ecotasks. I always thought it would be a
       | good idea to have priority lists for ecosystems so that people
       | know where to focus their efforts to help the community the most.
        
       | kyberias wrote:
       | What is the point of putting that zero in the version number when
       | it quite clearly is not a decimal number and now it kind of looks
       | like one and is confusing?
       | 
       | Makes me want to avoid D.
        
       | butterisgood wrote:
       | Anyone able to report on the growth of the D community at all?
       | 
       | Lots of press lately goes to Go and Rust. I even hear about Zig
       | more than I hear about D these days.
       | 
       | Yet I know of at least one company putting their eggs in the D
       | basket (Weka).
       | 
       | Just curious if anyone else feels like this is kind of risky
       | compared to other more-established options. (obviously chicken
       | and egg issues exist).
       | 
       | Haven't used D in quite a few years, but I'm thinking about
       | playing around again soon.
        
         | mhh__ wrote:
         | > Yet I know of at least one company putting their eggs in the
         | D basket (Weka).
         | 
         | Symmetry Investments pay for at least 2 varying-hours staff for
         | the D Language Foundation - including me. This is a recent
         | development. They are seemingly constantly hiring, too.
         | 
         | D is basically designed not to be risky. The whole language is
         | a big collection of simple compromises for the most part, i.e.
         | if you want to write correct code the obvious thing to do is
         | encourage testing and contracts, surprise surprise D has first
         | class unit tests and Ada style function contracts.
        
         | pornel wrote:
         | According to http://www.modulecounts.com crates.io adds more
         | packages in a month than there are on DUB in total.
        
           | petre wrote:
           | Node.js adds several orders of magnitude more packages as
           | well. That doesn't mean much, other than that a lot of
           | disputable quality packages are added, introducing needless
           | entropy and dependency hell. I compiled a _simple_ Rust
           | program (pueue) a few weeks ago which pulled ~290 deps, which
           | served as a reminder, although nothing broke compared to node
           | and also no deprecation and security warnings. Golang is no
           | different.
        
         | Kranar wrote:
         | Certainly D has a lot of support for hobbyists and solo
         | developers, but hasn't seen much adoption from industry.
         | 
         | It's a tough language to sell to a large organization. When
         | you're a solo developer D gives you the flexibility and freedom
         | to pursue the many different paradigms that it supports and
         | create your own mini-dialect of the language that suits you
         | perfectly. You can sprinkle some garbage collection here if you
         | want, some meta programming there if you'd like, or narrow
         | things down to a barebones strongly typed C-like language.
         | There's a great deal of exploratory freedom in that respect.
         | 
         | When you're in industry, those freedoms can become liabilities
         | because you end up paying the cost of the language supporting
         | things you have no use for. I don't want to pay for D's garbage
         | collector and I don't large teams all writing up elaborate
         | template metaprograms that have to be maintained. If I wanted a
         | garbage collector, then C# or Java is almost certainly the
         | better choice. If metaprogramming is what I want, I'd use a
         | Lisp dialect like Clojure. For any specific feature D has that
         | would be a major selling point or competitive advantage for my
         | company, there's another language that is almost certainly far
         | better suited to providing it. There isn't one single language
         | that does everything D has, but there's also no single project
         | that would want to make use of all those features, and this
         | becomes very apparent when you see how fractured the D
         | community is and how many mini-dialects of the language there
         | are. Do I support GC or not? Do I make it compatible with
         | betterC or not (meaning exception support).
         | 
         | Having a kitchen sink like language results in those kinds of
         | trade-offs. Good language for carving out a niche for yourself
         | that can adapt to your specific style of programming and give
         | you as an individual a great deal of expressive freedom... bad
         | for when you need to coordinate with a large team and buckle
         | down on a small set of rigorous and specialized features that
         | are likely better served by using a tool focused on delivering
         | it.
        
           | throwaway316943 wrote:
           | Sounds like it's perfectly suited for indie game development
           | where everything plus the kitchen sink is a must and the more
           | customizable the better.
        
             | Kranar wrote:
             | That's an excellent point actually. I think as a language D
             | could work well for indie games but even there... if you're
             | an indie developer do you go with D or with Unity (which
             | uses C#)?
             | 
             | That said, in principle one could imagine a version of
             | Unity that used D instead of C#, and I think that would be
             | a pretty neat combination.
        
               | p0nce wrote:
               | > if you're an indie developer do you go with D or with
               | Unity (which uses C#)?
               | 
               | You would have to weight this choice against existing
               | engines like Unity/Unreal/Godot vs custom. I released a
               | game with custom engine in D once and what really
               | mattered was that there was no market fit (and no sales).
               | Choosing engine vs custom is a question that only exists
               | if people materialize to play your game ; a lot of
               | successful game shops are prototype-heavy or at least
               | advise that strategy.
        
           | mhh__ wrote:
           | > but there's also no single project that would want to make
           | use of all those features,
           | 
           | In practice, you'd be surprised. Some of the things like
           | -betterC were solely developed as a toy, but nearly
           | everything I can think of in D has a use and is useful when
           | used as intended. The people who do use D in industry use
           | those features - this is still 80-20 as with many things in
           | programming, but (for example) first class unit testing is so
           | blindingly obvious you'll miss it when you don't use D.
           | 
           | One of the reasons why you would use D is that you can pick
           | and choose because one day you will (say) hit a performance
           | wall and need inline assembler, then goodbye clojure (for
           | example). Just do what works for your project, the code is a
           | lot harder anyway.
           | 
           | Obviously it's a self-selecting group, but these problems
           | really don't exist all that much when you are actually
           | writing software - libraries, yes, programs not so much.
        
         | _veelo wrote:
         | I work for another company also putting its eggs in the D
         | basket (SARC). We do not consider this risky because of two
         | main reasons:
         | 
         | 1) D is not dependent on the funding of one big corporation, so
         | our future is not at the mercy of such corporation.
         | 
         | 2) Three highly compatible compilers exist, all of them libre.
         | Inclusion into gcc is probably the best insurance for any
         | language.
         | 
         | The D community may be comparatively small, but for us it is
         | big enough. Changes in and around the language may happen
         | comparatively slowly, but for us they happen fast enough.
         | Tooling may be comparatively limited, but we are actually
         | rather impressed by what is available.
         | 
         | The language itself is of course awesome.
        
         | throwaway316943 wrote:
         | Started exploring D recently and my experience has been that
         | the community is a bit isolated but not nonexistent. You can
         | find answers for most questions but most of those will be in
         | the D forum. There are some good books though.
        
           | gavinray wrote:
           | You'll always get a fairly near-immediate answer on the
           | Discord too.
           | 
           | Yeah, it's not a popular language. Probably won't suddenly
           | take off as one.
           | 
           | But if you like it and you're writing software for yourself,
           | who cares. It has the most practical C++ interop of any
           | language, which may or may not be important to you.
           | 
           | It's got a core community of very active, helpful folk.
        
         | mhh__ wrote:
         | I have the logs for the website downloads, I'll crunch 'em and
         | post them later assuming all goes to plan.
         | 
         | Edit: Please with a big grain of salt while I work out whether
         | I'm over-counting, it looks like we've roughly tripled since
         | the last numbers on Andrei's site.
        
         | elromulous wrote:
         | Imho, D's choice to be garbage collected has prevented wider
         | adoption (that's the case for my usage at least). And as a
         | compiled gc language, it competes squarely with golang,
         | something that's likely hard to do, given the corporate
         | (google) support golang has.
         | 
         | Side note: I met the creater of D, Walter Bright (also of
         | course famous for the digital mars compiler) at going native
         | 2013 (now known as cppcon). Bright was the nicest guy, and was
         | happy to field my questions. We even chatted about rust, which
         | was just a twinkle at the time!
        
           | generichuman wrote:
           | They're replacing a lot of GC'd standard library functions
           | with @nogc functions, so people might not have to depend on
           | the GC soon.
           | 
           | Some people were also working on a reference counted type
           | (that'd replace the GC I guess?) a few years ago, but I don't
           | know what happened to that, or if it did make into the
           | language. There are a few open RC pull requests from 2019 on
           | the d runtime repository.
        
             | diegocg wrote:
             | Walter has plans to add ownership and borrowing to D
             | https://dlang.org/blog/2019/07/15/ownership-and-borrowing-
             | in...
             | 
             | Not sure what the current state is.
        
             | vips7L wrote:
             | Here is a library for smart pointers:
             | https://github.com/atilaneves/automem
        
           | nerdponx wrote:
           | Interestingly, Crystal and Nim also seem to be getting more
           | press than D. And Crystal is more of a direct Go competitor
           | than D is.
        
           | petre wrote:
           | I like the GC so I don't have to bother with manual memory
           | management. It also a simpler GC which works quite
           | predictably and one could work with it or around it. I hope
           | it stays in the language. One could use @nogc if they don't
           | want it. D's GC is also configurable:
           | 
           | https://dlang.org/spec/garbage.html
        
           | banachtarski wrote:
           | As just one anecdote, the mere presence of a GC made me stop
           | looking at D more or less immediately. In terms of
           | positioning, I think D would be better served focusing on a
           | vertical.
        
             | bachmeier wrote:
             | > As just one anecdote, the mere presence of a GC made me
             | stop looking at D more or less immediately.
             | 
             | A lot of people say that, but that's the tip of an iceberg
             | of 500 items that will prevent someone that doesn't want GC
             | from using it. In other words, nobody ever used a language
             | only because it didn't have a GC.
        
               | Kranar wrote:
               | If you're being absolutely extreme then sure that's true.
               | I'd still use Ruby with it's garbage collector to
               | implement a video game instead of using Brainfuck even
               | though Brainfuck doesn't have a GC.
               | 
               | But if we're being reasonable, then I can say me and my
               | company mostly still use C++ because it doesn't have a
               | GC. It's an otherwise horrible language and I'd love to
               | get off it. For a new project making an order matching
               | system for a financial exchange, we are experimenting
               | with Rust as an alternative and it's looking very
               | promising. I want to see a bit more how the async
               | situation plays out because that aspect of the language
               | has me concerned but overall it's a really clean and
               | principled language.
               | 
               | At any rate, the point is that a GC in and of itself is a
               | major deciding factor about whether a language is used or
               | not for many production grade systems.
        
               | bachmeier wrote:
               | > If you're being absolutely extreme then sure that's
               | true.
               | 
               | I wasn't being extreme. I was making a statement based on
               | year after year seeing people make the same claim. After
               | the GC is gone, then it's the legacy C++ code, the lack
               | of documentation, the lack of developers experienced with
               | C++, the tooling, various language issues, and on and on.
               | 
               | The thing is, you can already disable the GC and slap
               | @nogc on your program and you _don 't_ have a GC. Or
               | compile with the -betterC flag and you _don 't_ have a
               | GC. It's not like D requires using the GC. When you say
               | that, the reply is "Yes, but..." followed by issues using
               | D as @nogc.
               | 
               | > we are experimenting with Rust as an alternative and
               | it's looking very promising. I want to see a bit more how
               | the async situation plays out because that aspect of the
               | language has me concerned but overall it's a really clean
               | and principled language.
               | 
               | This is exactly what I'm talking about. The GC is only
               | one of many reasons you're not using D and probably never
               | will. And that's okay, because if you remove the GC,
               | someone like me will never look twice at the language.
        
               | Kranar wrote:
               | If you had said "No one ever decided not to use D because
               | of the GC" or something along those lines sure... I'd
               | agree. But your claim was "No one ever decided to use any
               | language whatsoever because it didn't have a GC." and
               | that's simply untrue. If C++ got a GC I would immediately
               | stop using it and would have never used it to begin with.
               | 
               | All the rest of your points in your follow up post are
               | very specific to D and yes, those other points are all
               | legitimate reasons people don't use D, regardless of its
               | GC. It's simply that your original claim about language
               | preference on the basis of GC was not specific to D and
               | it's certainly false.
        
             | mhh__ wrote:
             | > I think D would be better served focusing on a vertical.
             | 
             | I don't know what that means
        
           | mhh__ wrote:
           | Walter is on here too
           | 
           | > digital mars compiler
           | 
           | And the one/s before that, even. He wrote the first proper
           | C++ compiler to my knowledge, and lots of that shows in D.
        
       | Decabytes wrote:
       | I ended up playing around with D for a bit before moving to Rust
       | and here were my thoughts
       | 
       | Pros
       | 
       | 1. It felt very practical.
       | 
       | 2. Handling packages using Dub was great
       | 
       | 3. The D programming book by Ali Cehreli was a great introduction
       | http://ddili.org/ders/d.en/index.html
       | 
       | 4. A lot of criticism around D were outdated. Whenever you search
       | stuff about D you still find people talking about the split,
       | disabling the GC invalidating over half the std lib (this has
       | changed a lot) etc, from years ago and a lot has changed since
       | then
       | 
       | 5. The forum is very helpful, and I was able to get my issues
       | fixed without anyone telling me to RTFM or being mean
       | 
       | 6. It's about 20 Years old and has some very mature libs (like
       | the gtkD lib)
       | 
       | 7. Running D code like a script with RDMD was great for rapidly
       | learning D
       | 
       | 8. I think having 3 separate compilers is great! DMD, GDC and
       | LDC2 all have their pros and cons
       | 
       | Cons
       | 
       | 1. I found the documentation very difficult to grok. I found it
       | more difficult to understand than Racket's or Rust's
       | 
       | 2. It feels like lot of the momentum of D is gone, and has been
       | replaced by rust, zig, etc
       | 
       | 3. Lack of examples, lack of questions and answers that aren't
       | from 10 years ago
       | 
       | 4. Not a lot of intro materials for people who aren't C/C++
       | programmers
       | 
       | Overall I liked it. Due to a variety of personal reasons I moved
       | on, but if things don't work out with Rust I might be back. I
       | really don't want to try to learn C++ again, I just don't enjoy
       | it.
        
         | Shorel wrote:
         | About cons #2.
         | 
         | Yep, I feel its momentum has been replaced by Rust for some
         | things and Golang for other things.
         | 
         | But zig? No one uses zig for anything serious.
        
           | bachmeier wrote:
           | > its momentum has been replaced by Rust for some things and
           | Golang for other things
           | 
           | People told me the same thing about Go when I started using D
           | back in 2013. Compared to today, D didn't have a lot going on
           | in 2013.
        
           | dralley wrote:
           | >But zig? No one uses zig for anything serious.
           | 
           | There's at least one company using zig for embedded software,
           | _despite_ its pre-release status, because it 's just so much
           | easier to work with than C.
           | 
           | It has a lot of potential. You're not wrong that, at the
           | moment, it's most just _potential_. But people have noticed,
           | and I think once it does finally stabilize in a year or two,
           | it 's going to be a huge for embedded type programming and
           | system libraries that would otherwise be C. The value
           | propositions is pretty huge for those use cases especially.
        
           | e12e wrote:
           | > But zig? No one uses zig for anything serious.
           | 
           | I had the impression zig's corporate sponsor (pex.com) uses
           | zig?
        
         | crazypython wrote:
         | > 5. The forum is very helpful, and I was able to get my issues
         | fixed without anyone telling me to RTFM or being mean
         | 
         | D forum is one of the most gracious and nice. There is a lot of
         | gratitude.
        
           | MaxBarraclough wrote:
           | They also really know their stuff. I suppose that's an
           | advantage of all less mainstream languages and tools, but D's
           | community is particularly impressive.
           | 
           | Another way of putting it: in the C++ community, the average
           | person on a forum is never going to have a seat on the C++
           | standards commitee. They'll never even get close. With a
           | smaller community like with D, you can find forum threads
           | where the forum regulars are discussing the future of the
           | language, and the discussion really has weight on D's
           | evolution.
        
             | mhh__ wrote:
             | Also keep in mind that that pretty small community is able
             | to do what we've done already, e.g. D can pretty much catch
             | C++ exceptions!
        
         | p0nce wrote:
         | > 1. I found the documentation very difficult to grok.
         | 
         | > 3. Lack of examples,
         | 
         | It helps a lot to open issues on the D bugtracker when you
         | encounter those.
        
         | stelonix wrote:
         | Recently I got fed up with C++ for good and have no interest in
         | touching it anymore. There's just a sheer amount of complexity
         | and lack of free (as in beer) tooling that has driven me mad
         | these past years until I finally gave up last month.
         | 
         | Then I checked D and I wanted to try it, but couldn't get a
         | Rider/IntellliJ (can't recall) plugin to work, so I also marked
         | it as lack of tooling; I also couldn't find many code examples,
         | either on github or in communities which weren't old-ass
         | forums.
         | 
         | I finally decided to go back to the sanest language I've used,
         | which is C#. With little effort I could get back to writing
         | code instead of endless yak shaving for simple things. For
         | these kind of projects I'm working, a GC isn't the issue, so
         | that didn't bother me. It feels like asking for modern class-
         | based with c-like-syntax and a good std lib in a language is
         | too much... It's sad that C++ "won" the race being such a
         | cumbersome language with slow compile times and a outdated
         | mindset.
        
           | nix23 wrote:
           | You should checkout Go it sounds you have work to be done,
           | and Go was exactly made for that.
        
             | stelonix wrote:
             | I looked at Go but the lack of generics didn't help, so I
             | ditched it. I'm very excited about it now that they're
             | considering adding it though. Thanks for the tip, I'll
             | check out what changed in the meantime!
        
       | z77dj3kl wrote:
       | The more time I spend with Python, the more it seems to me that a
       | language defined abstractly and having multiple implementations
       | (none "official") seems to be the healthiest compared to one with
       | a reference compiler/interpreter. D seems to have one "reference
       | compiler" and just a "reference manual".
        
         | mhh__ wrote:
         | I'm not sure how this actually applies to D? There are
         | definitely niggles with how dmd is currently implemented but
         | they are usually quite hard to bump into day to day.
        
         | p0nce wrote:
         | This is a valid criticism; yet a spec is "code" that has to be
         | maintained and created, so in the context of open source
         | someone has to do it. An ISO-quality spec needs a lot of
         | efforts to happen.
         | 
         | Thing have been getting slowly better over time, with this
         | small specification: https://dlang.org/spec/intro.html
        
         | djwatson24 wrote:
         | D has three fully functional compilers on Linux, and is
         | probably in better shape than python, rust, even c++ in that
         | regard.
        
           | qznc wrote:
           | There is only one frontend though.
           | 
           | The advantage of multiple compilers is that people find
           | subtle differences which humans miss by only reading the
           | spec. Since D has only one frontend, it does not get that
           | benefit although it can technically claim to have three
           | compilers.
        
         | gmfawcett wrote:
         | You wouldn't have two or more reference compilers -- that would
         | defeat the point. There are three popular D compilers, one of
         | which (DMD) can be considered the reference.
         | 
         | As for "reference manual" -- well, every tool should have a
         | reference manual. The "reference" here has a different
         | connotation. I think you might be conflating "reference manual"
         | with "formal specification", which is not accurate in this case
         | (and in most cases).
        
       ___________________________________________________________________
       (page generated 2021-03-24 23:02 UTC)