Live data from Hacker News

The reference D compiler is now open source

forum.dlang.org

81–90 of 313 posts

Re: The reference D compiler is now open source

#81
post #28
post #21

Earlier quoted context omitted.

There's a wide range of possibilities int that statement that include the case where you would almost always want D over Rust, and the case where you would almost never want D over Rust. The question is, how much easier is D than Rust, and how much safer is D than C++.

There is no quantitative metric for safety and easyness. If you can afford a garbage collector, D easily wins over Rust. If you really need the safe manual memory management, Rust wins. In between is still a large grey area.

> If you can afford a garbage collector, D easily wins over Rust.

This is the "the only point of the ownership/borrowing model is to avoid GC" myth that I've been working to kill. Rust's model also gets you data race freedom, to name just one other benefit.

Re: The reference D compiler is now open source

#82
post #44

Whats special about D? why should i learn it?

Also, how does D compare to Rust? (If I'm going to learn a new system programming language, which one should I pick?)

D has been around longer, has powerful compile-time metaprogramming tools, and has a very fast compiler. However, it has a garbage collector, and is not entirely memory-safe by default (though is beginning to optionally incorporate some ideas from Rust [edit: or not], maybe making that easier once you put in the work). It seems to follow C or C++ in what sorts of things it makes language-level features.

Rust is newer (though being used in some big projects like Firefox/Servo, Visual Studio Code's search functionality now uses it by default, etc), has (afaiu) a more powerful type system, and is entirely memory-safe by default. However, this makes it somewhat harder to learn at first, and it also has a relatively slow compiler. It follows ML-style languages a bit more, with things like pattern matching and sum types built into the language.

Personally, I prefer Rust, because it feels like a stronger foundation with the ML-like type system and no GC. YMMV though, depending on what is important to you.

Re: The reference D compiler is now open source

#83
post #61

Earlier quoted context omitted.

Is the GC mandatory in D? I was under the impression some time ago that D could run GC-free, but the standard library still widely used GC. Did I just misunderstand?

In my understanding, you're overall correct, but they've also been working on reducing that need, making more and more of it work without a GC.

Currently working on making the Exception handling system usable without the GC. Expect it soon.

Re: The reference D compiler is now open source

#84
post #72
post #53

Please get rid of GC :( I want to have smart pointers instead

No problem, just add the @nogc annotation to your main function. int main(string[] args) @nogc { ... }

I haven't used D much- how much of an impact does that have when using the standard library or other libraries? Is there a good way to use things that assume a GC even when it's disabled?

Re: The reference D compiler is now open source

#85
post #59

Please don't get me wrong, as I don't want to start a flame here, but why do they call D a "systems programming language" when it uses a GC? Or is it optional? I'm just reading through the docs. They do have a command line option to disable the GC but anyway...this GC thing is, imho, a no-go when it comes to systems programming. It reminds me of Go that started as a "systems programming language" too but later switch…

Why does gc disqualify a language as a system's language? P.S. I think of a system's language as one that runs directly on the machine, e.g. Swift, C, go. They operate at the "system" level.

> Why does gc disqualify a language as a system's language?

AFAIK a "system programming language" should have deterministic performances, obviously Go hasn't. But different people might define "systems" differently.

Re: The reference D compiler is now open source

#86
post #45

Earlier quoted context omitted.

For someone who knows zero about D, but is a total Pythonista, how would you compare the meta-programming facilities?

I guess the best comparison to Python would be the dunder methods. You know how in Python a class really is just a dict, right? Like, foo.bar is pretty much syntactic sugar for foo.__get_attribute__(foo.__dict__['bar']) in most cases. Or how a + b is sugar for a.__plus__(b). Well, imagine that all of the things you can do in Python by messing with dunder methods, function decorators, or metaclasses could be precomput…

Well, overriding dunder methods isn't really metaprogramming. It's just method inheritance/override.

Is there anything in D similar to decorators? How does the registration pattern work in D, for instance?

Re: The reference D compiler is now open source

#87
post #61
post #28

Earlier quoted context omitted.

There is no quantitative metric for safety and easyness. If you can afford a garbage collector, D easily wins over Rust. If you really need the safe manual memory management, Rust wins. In between is still a large grey area.

Is the GC mandatory in D? I was under the impression some time ago that D could run GC-free, but the standard library still widely used GC. Did I just misunderstand?

You can go easier on the GC or avoid it altogether. See this article and the discussion:

https://news.ycombinator.com/item?id=13914308

Re: The reference D compiler is now open source

#88

Earlier quoted context omitted.

In my understanding, you're overall correct, but they've also been working on reducing that need, making more and more of it work without a GC.

Currently working on making the Exception handling system usable without the GC. Expect it soon.

Great! (and, congrats on the re-licensing.)

Re: The reference D compiler is now open source

#89
post #56

Earlier quoted context omitted.

Do you have any comment son international legal issues with public domain? Is that not recognized in some places?

Several European countries do not recognize the ability of copyright holders to completely give up their copyright. So it needs a license of some kind.

And that's why the Unlicense has a BSD-style "Anyone is free to…" clause.

Re: The reference D compiler is now open source

#90
post #82
post #44

Earlier quoted context omitted.

Also, how does D compare to Rust? (If I'm going to learn a new system programming language, which one should I pick?)

D has been around longer, has powerful compile-time metaprogramming tools, and has a very fast compiler. However, it has a garbage collector, and is not entirely memory-safe by default (though is beginning to optionally incorporate some ideas from Rust [edit: or not], maybe making that easier once you put in the work). It seems to follow C or C++ in what sorts of things it makes language-level features. Rust is newer…

D's memory safe notions are very different from Rust's.
Post reply on HN