Hacker News new | ask | show | jobs
by mhh__ 2709 days ago
Even though it doesn't have the same theoretical rigour as Rust or Erlang (Go is a totally different beast), D is a really thoughtful, modern language which I - personally, of course - feel very productive in. Although I'm really behind the times on Rust, metaprogramming feels like a joke in other (Non ML-esque) languages compared to the facilities available in D

Walter Bright, the man who designed most of the language along with Andrei Alexandrescu, are both C++ heavyweights and it shows. Template syntax using template!type instead of template<type> is a great - surface level - example of this attention to detail: Easier on the eyes and orders of magnitude easier for the compiler

1 comments

Would you say that metaprogramming is an important selling point for you ?

If so, it would be a sign for me no to invest in D, as my experience is that easy metaprogramming leads to more abuse than goodies. I

Yes. D metaprogramming is so fucking good that it's easy to do well.

It's really obvious, and even at it's worst it's no worse than C++ (Except much easier to debug due to D's much less fundamentalist type system).

I hate languages that deliberately take features away from the developer: This is why - although I respect the philosophy - I would never choose to use Go, for example.

But to each their own, etc.

> I hate languages that deliberately take features away from the developer: This is why - although I respect the philosophy - I would never choose to use Go, for example.

The don't really take the features away, they move the problem to a proper templating/code generation language. These are language neutral so you don't have to learn a different one for each language, they are often more powerful too. IME the code they generate is a lot easier to deal with than templated code.

In D, you can run full code at compile time and then include that string into the file: So it is it's own code generation language.
> even at it's worst it's no worse than C++

I can't think of a language whose metaprogramming features get abused worse than C++, so saying it's not worse isn't really heaping praise.

I was really referring to the error messages, because you can write C++ style templates (e.g. SFINAE) in D but no one does because D was designed properly so it has proper traits etc. C++ style template messages are uncommon but possible, however D is much much easier to debug because the type system is working with you and basically available in the language - in the sense that you can use traits and reflection to work out what went wrong (as opposed to

stdin. byLineCopy.array.sort!((a, b) => a >b).each!writeln;

This example is everyday code in D, but basically unthinkable in C++ (Possible but try getting it that short without writing your own library). It is also telling that the aesthetic style of the above code (UFCS) is a feature D has had for years but was rejected for inclusion into C++ despite BS backing it.

Ok, it encourages magic. That's what I wanted to know.
Good magic, bear in mind: It's usually really obvious how it works, unlike C++.