Remix.run Logo
dataflow 2 days ago

> It's a mystery why D isn't far more popular than it is.

There's no mystery. It's a jack of all trades, master of none. E.g., the virality of the GC makes it a non-starter for its primary audience (C/C++ developers). The need to compile and the extra verbosity makes it a bad substitute for scripting like Python. Etc.

Basically, name any large niche you'd expect it to fill and you'll probably find there's a tool already better suited for that niche.

bachmeier 2 days ago | parent | next [-]

> the virality of the GC makes it a non-starter for its primary audience (C/C++ developers)

No. If you were to say you need the GC to use all features of the language and standard library, of course, the GC does important things, but to claim a C developer wouldn't be comfortable with it because of the GC is nonsense. Just don't allocate with the GC and use the same mechanisms you'd use with C (and then build on top of them with things like @safe, reference counting, and unique pointers).

dataflow 2 days ago | parent | next [-]

>> the virality of the GC

> Just don't allocate with the GC

"virality" is not just a word you can ignore.

bachmeier 2 days ago | parent [-]

I don't understand. If you're a C programmer and want to avoid the GC, there's nothing to be viral.

dataflow 2 days ago | parent [-]

> If you're a C programmer and want to avoid the GC, there's nothing to be viral.

What you're suggesting is the moral equivalent of "it's easy to avoid diseases, just avoid contact with those infected", or "it's easy to avoid allergens, just avoid foods you're allergic to", or "it's easy to avoid contamination, just set up a cleanroom", or "it's easy to write deterministic code, just avoid randomness", etc.

Yes, there are things that are easy to achieve in the vacuum of outer space, but that's not where most people are interested in living.

brabel 2 days ago | parent | next [-]

Completely agree after trying it. Anything that may throw an Exception requires GC. There goes 80% of D code you could use. The rest becomes inaccessible for other, similar reasons quite often. Try writing D with @nogc and it takes 10 minutes to understand that. They want to make the situation better but there’s just not enough people to tackle the huge amount of work that requires (I.e. changing most of the stdlib)

dataflow 2 days ago | parent | next [-]

> Try writing D with @nogc and it takes 10 minutes to understand that.

Thank you. Yes, exactly. The problems aren't even subtle; it's impossible to miss them if you actually try. I don't recall even finding a reasonable way to concatenate or split strings on the heap and return them without a GC, let alone anything more complicated. It boggles my mind that people repeat the talking point that it's somehow practical to program with @nogc when the most basic operations are so painful. Nobody is going to drool at the idea of spending days/weeks of their lives reinventing nonstandard second-class-citizen counterparts to basic types like strings just to use a new language.

> They want to make the situation better but there’s just not enough people to tackle the huge amount of work that requires (I.e. changing most of the stdlib)

I don't agree that it's lack of manpower that's the problem -- at least, not yet. I think it's primarily the unwillingness to even admit this is a problem (an existential problem for the language, I think) and confront it instead of denying the reality, and secondarily the inertia and ecosystem around the existing language outside the standard library. It's not like the problem is subtle (like you said, a few minutes of coding makes it painfully obvious) or novel. The language has been out there for over a decade and a half, and people have been asking for no-GC version nearly that long. Yet, at least to the extent I've had the energy to follow it, the response has always been the canned you-can-totally-program-D-without-a-GC denials you see repeated for the millionth time here, or (at best) silence. If this sentiment has changed and I'm unaware of it, that's already significant progress.

Maybe the unwillingness to confront reality is due to the lack of manpower and how daunting the problem looks; I'm not sure. But it seems as bright as daylight that D is not going to be successful without solving this problem.

WalterBright a day ago | parent | next [-]

I use:

https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ba...

It's pretty minimalist on purpose. I don't much care for kitchen sink types.

The BetterC is the no-gc version. Use the -betterC switch on the compiler.

Or, if you want a string result,

    import core.stdc.stdlib;

    string concat(string s1, string s2)
    {
        const length = s1.length + s2.length;
        char* p = cast(char*)malloc(length);
        assert(p);
        p[0 .. s1.length] = s1;
        p[s1.length .. s1.length + s2.length] = s2;
        return cast(string)p[0 .. length];
    }
I tend to not use this sort of function because it doesn't manage its own memory. I use barray instead because it manages its memory using RAII. D provides enormous flexibility in managing memory. Or, you can just leave it to the gc to do it for you.
dataflow a day ago | parent [-]

> I use: https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ba... It's pretty minimalist on purpose. I don't much care for kitchen sink types.

I feel you're demonstrating exactly the problems I highlighted through your example here -- including the very lack of acknowledgment of the overall problem.

WalterBright a day ago | parent [-]

The problem is there is no such thing as a string type that doesn't have problems one way or another.

The very simplest and straightforward way is to use the gc to manage the memory. It works very very well. All the other schemes have serious compromises.

That's why you can use the method most appropriate in D for the particular usage. I routinely use several different methods.

Zardoz84 a day ago | parent | prev [-]

Part of the problem it's trying to do too many things in too many fronts. They try to implement a borrow-checker a la Rust. But feels very poorly compared against the Rust version. It haves a "optional" GC, but it's a subpar GC. And lacks a way to use alternative GCs.

And funny, C++ has been copying many features that DLang have for many time ago. Beginning with the type inference (ie using "auto" to declare vars). And now, contractual programing and static reflection.

I really loved the language, but it's very sad that never manages to take off and become more popular and well maintained.

WalterBright 4 hours ago | parent | next [-]

> But feels very poorly compared against the Rust version.

It's a prototype to gauge the interest in having a borrow checker in the language. I did not continue with it because the interest is not there.

pjmlp a day ago | parent | prev | next [-]

That has been the main problem from my point of view, too much pivoting looking for the right crowd, without finalizing what was done before.

And while some features in other languages might have seen an implementation first in D, claiming first to the finish line as it usually comes up, even on this thread, hardly does anything for language adoption.

On the contrary, it is one reason less leave those languages, as eventually they get the features, and already have the ecosystem.

WalterBright 4 hours ago | parent [-]

If you don't mind waiting 10 years, sure!

pjmlp 14 minutes ago | parent [-]

I have been waiting for a good story how to sell D for adoption, since Andrei published his book.

Most of the stuff that interested me back in 2007, is now available across in C#, F#, JVM languages, Swift, OCaml, Haskell, with a better ecosystem and IDE tooling.

And then there is C++26 and Rust 2024.

You achieved a lot as language designer, but it is still not clear how the community would keep the language going forward in lets say 10 years from now.

gpderetta a day ago | parent | prev [-]

> Beginning with the type inference (ie using "auto" to declare vars).

GCC (and possibly other compilers) had typeof in the '90s well before D was first released. Macros in the form:

   #define    TYPEOF(name, expr) typeof(expr) name = expr
Were widely in use since then.

I'm sure that C++ borrowed concepts from D, but type deduction (not inference BTW) is not one of them.

WalterBright 4 hours ago | parent [-]

Extensions are not part of the language, which means that programmers tend to avoid using them.

bachmeier a day ago | parent | prev [-]

This completely misses the point of my original comment. A C programmer that wants to continue to use their knowledge and existing code will be very happy using D. You're describing someone that wants to use D without the garbage collector. Those are two completely different cases.

I've been happily using D for a better experience with C code for more than a decade. First, because it's extremely rare to need to completely avoid the GC for everything in your program. Second, because everything you want and need from C is available, but you can use it from a more convenient language. Sure, exceptions won't work if you're avoiding the GC (which doesn't have anything to do with C), but so what. It's not like C programmers are currently using exceptions. You can continue to use whatever mechanism you're using now.

zem a day ago | parent [-]

> Sure, exceptions won't work if you're avoiding the GC (which doesn't have anything to do with C), but so what. It's not like C programmers are currently using exceptions.

that works if your main use case for d is as a top-level wrapper program that is basically calling a bunch of c libraries. if you want to use d libraries you will run into ones that need the gc pretty quickly.

WalterBright 4 hours ago | parent [-]

I don't see how GC allocate exceptions would be a problem unless you're generating thousands of exceptions. Throwing an exception should, by definition, be an exceptional case.

bmacho a day ago | parent | prev [-]

According to them[0], D as better C is indeed just C with less footguns and some additional optional features like RAII (that one can use or not) or more comptime assumptions (again, that one can use or ignore).

I don't think what hinders their adoption is their direction, everything they say they accomplished/plan to accomplish is ideal IMO.

[0] : https://dlang.org/spec/betterc.html#retained

dataflow a day ago | parent [-]

> D as better C is indeed just C with less footguns and some additional features like RAII (that one can use or not) or more comptime assumptions (again, that one can use, or ignore)

Having strictly more features (if we even assume that, which I don't think is accurate) does not imply better.

Javascript is just JSON with more features too. Is it a mystery that people don't ship Javascript code everywhere instead of JSON?

WalterBright 4 hours ago | parent [-]

What the "more features" do is replace the clumsy/inadequate/risky methods used in a less powerful language like C. For example, you don't need to use the C preprocessor to do metaprogramming. D offers a world class metaprogramming capability.

Another example is D enables nested functions. Yes, there are ways in C to do the equivalent, but they are clumsy and indirect.

unclad5968 2 days ago | parent | prev [-]

If I'm just coding C except a new syntax, why wouldn't I just stick with C?

dataflow 2 days ago | parent [-]

It's not just new syntax, you get other nice features too.

WalterBright a day ago | parent | prev | next [-]

With D you don't have to use multiple languages, such as mixing Python with C. D is The One Language to Rule Them All.

(D's ability to use C code is to make use of existing C code. There's not much point to writing C code to use with D.)

dataflow a day ago | parent | next [-]

> D is The One Language to Rule Them All.

That's kind of why I said it's the "jack of all trades". It's not a bad language, it just doesn't beat any existing languages I know of in their own niches (hence "master of none"), so few people are going to find it useful to drop any existing languages and use D in lieu of them.

jibal a day ago | parent [-]

It's amusing to see someone telling the designer and implementer of a language that he has put decades of effort into that "it's not a bad language".

WalterBright a day ago | parent | next [-]

I often hear a lot worse :-) No worries, it doesn't bother me. What pleases me are the people who use D, like it, and tell me they make more money using D because D is much more productive to write code in.

D also attracts expert programmers who are very comfortable using the GC when appropriate, stack allocation when appropriate, malloc/free, even ref counting. These are just tools in the toolbox, like I use socket wrenches, end wrenches, box wrenches, crow foot wrenches, pipe wrenches, monkey wrenches, etc. I don't try to use socket wrenches for everything.

BTW, the GC makes managing memory in compile time function execution trivial. Something that non-GC languages struggle with.

dataflow 19 hours ago | parent [-]

> What pleases me are the people who use D, like it, and tell me they make more money using D because D is much more productive to write code in.

I guess what I've been trying to say is that you would find yourself pleased much, much more often (and D being much more successful) if you recognized and addressed these high-level issues that people have been pointing out for decades, instead of denying them and going on forums telling customers why their expectations are wrong or unnecessary. I'm saying this because D really is a great piece of technology that got a lot of things right, except a few crucial details for some of the most crucial users. And it has had so much potential - potential that has been gradually lost largely because you haven't even recognized the flaws and hurdles that come with it.

It remind me of the infamous Dropbox comment. It's as if you invented FTP, but then whenever people told you it's hard to store & share files, you kept insisting that it's trivial with just a few simple steps on Linux, completely missing the massive market opportunity and the barriers you're telling people to walk through. https://news.ycombinator.com/item?id=9224

And I'm not saying all this out of out hate for D, but out of (at least past) love for it. I desperately wanted to see it succeed, but I gave up because I realized you simply did not see the Achilles heel that frustrates many of its users and that has held back its potential.

WalterBright 15 hours ago | parent [-]

Anyone is free to propose things for D, we have a process for it, or you can just post your idea in the D forum. Many do. You don't have to sit back and hope someone else does it.

tialaramex a day ago | parent | prev [-]

It's better than the feedback I would have for, to give an example, Bjarne Stroustrup. Bjarne has spent so far as I can tell almost all of his adult life on C++. It's a huge bloated mess, and though there are many other guilty parties I don't think I can even say he was a good influence.

jibal 6 hours ago | parent [-]

You and Dataflow seem to have no idea how the real world works.

quietbritishjim a day ago | parent | prev [-]

One of C++'s great weaknesses is that it is just a huge language with too much stuff in. There are lots of reasons why this is, not worth re-exploring, but the point stands.

There is a great irony that a replacement to C++ should have lots of features in it. (Not necessarily the same too-many features.) One of the key requirements of a real C++ alternative would be fewer language features.

pjmlp a day ago | parent | next [-]

It is telling that Ada and Rust are only ones that many people in the C++ community would ever consider.

Because at the scale many companies use C++, the additions into ISO C++, for how bad WG21 process currently might be, don't land there because a group of academics found a cool feature, rather some company or individual has seen it as a must have feature for their industry.

Sadly also a similar reason on how you end up with extension spaghetti on Khronos APIs, CSS levels or what have you.

Naturally any wannabe C++ replacement to be taken seriously by such industries, has to offer similar flexibility in featuritis.

quietbritishjim a day ago | parent [-]

> Because at the scale many companies use C++, the additions into ISO C++, for how bad WG21 process currently might be, don't land there because a group of academics found a cool feature, rather some company or individual has seen it as a must have feature for their industry.

Maybe it's just me but, sorry, I cannot parse this sentence.

trealira a day ago | parent [-]

I'm not them, but I'll try reordering the sentence to help you parse it better.

As bad as the WG21 process might be, the additions into ISO C++ don't land there because a group of academics found a cool feature; they land there because some company or individual has seen it as a must-have feature for their industry.

quietbritishjim a day ago | parent [-]

Thank you :-)

feelamee a day ago | parent | prev [-]

Why is a big number of features a problem? You can ignore them if you don't like/need them. Can you briefly explain which features can be thrown out and language will not miss a lot without them?

quietbritishjim a day ago | parent [-]

> Why is a big number of features a problem? You can ignore them if you don't like/need them.

You 100% cannot do that. I mean, you can if you're writing some toy project just for your own use. But as soon as you start interacting with other programmers, it's inevitable that some will use some other subset of language features.

> Can you briefly explain which features can be thrown out and language will not miss a lot without them?

I don't think that it's controversial that C++ is a huge language with many features, and I doubt I'm the best person to rehash that. One often quoted example is the multitude of ways to initialise a variable (Foo x = y; Foo x(y); Foo x = {y}; Foo x{y} and for default initialisation Foo x; Foo x = {}; Foo x{}; Foo x() (not really - that's the most vexing parse); Foo x = Foo()). There's multiple syntaxes to define a function including auto and decltype(auto) return types. There are const, consteval and constexpr - you may know the difference but I've forgotten. There are so many templating features that I wouldn't know where to start. Concepts are layered on top of that - which are useful and a good idea but no denying that it's layering extra complexity on top (which can be said for many C++ features). I've really just scratched the surface.

The thing is, I learned C++ over 20 years ago, when the latest standard was C++03 (which was essentially the same as C++98). Even at the time, C++ seemed like a bit of a chunky language (e.g., compared to C or Object Pascal - languages tended to be simpler back then), but it was achievable to mostly understand it all. But each revision that passed has added a huge volume of features. So I really feel how big C++ is because it's even big compared to (an older version of) itself. I've mostly kept up over the years but I can't imagine how I would properly learn the language today from scratch - I feel like you don't really stand a chance unless you've also been closely following it for decades.

GoblinSlayer a day ago | parent | prev | next [-]

When you use many languages, don't you become a jack of all trades, master of none? Also it's not obvious python is good for scripting, bash is better at short scripts, statically typed languages are better at long scripts, and you can't use it in CI yaml scripts. Python is more famous for data science and AI, not for scripting.

dataflow a day ago | parent | next [-]

I used "scripting" loosely (Python source files are frequently called Python scripts), I wasn't referring to shell scripts specifically. Feel free to pretend I said Bash or data science or whatever you want.

Re: your first sentence: I neither understand the logic nor do I understand how insulting the developer is going to help D succeed here even if the logic was sound.

GoblinSlayer a day ago | parent [-]

You handle technology as an emotional being? Well, that's strange. I thought it's more about tradeoffs.

bravetraveler a day ago | parent | prev [-]

Python is useful for scripts that go beyond strings. For instance: making a series of API calls, parsing/processing/mutating.

That's not data science or AI; "more famous" -- ridiculous distinction.

Fun fact: Ansible is orchestrated Python. Half your Linux distribution of choice is a pile of Python scripts. It's everywhere.

zem 2 days ago | parent | prev | next [-]

it should at the very least fit the same niche golang does

dataflow 2 days ago | parent | next [-]

I almost mentioned Go as another example of what it doesn't substitute for, but decided to cut off the list. But no, I don't think it fits that niche either. Go has a lot of features D doesn't have. Just off the top of my head: it's very simple, it doesn't have pointer arithmetic (yes, that's a feature here), it performs escape analysis to automatically extend the lifetime of objects that escape the stack frame, etc.

WalterBright a day ago | parent [-]

D does not allow pointer arithmetic in code marked @safe.

D does escape analysis from an alternative direction. If a pointer is qualified with `scope`, the compiler guarantees it does not escape the stack frame.

dataflow a day ago | parent [-]

I'm well aware of those, and they obviously don't fill the gaps here.

globular-toast 2 days ago | parent | prev [-]

Well that shouldn't be a mystery. Golang was marketed by Google.

p0nce a day ago | parent | prev [-]

The full quote is: “Jack of all trades master of none, though oftentimes better than master of one.”

sltkr a day ago | parent | next [-]

That's not “the” full quote; it's a modern variation of the classic quote.

Chinjut a day ago | parent | prev [-]

There is no documented instance of your "full quote" prior to the 21st century. It's certainly not the origin of the phrase "Jack of all trades, master of none".