News for hackers. Stuff that matters.
Re:Metaprogramming is less fun in D by echelon on Friday April 21, 2017 @11:57AM (#14166684)
Does D have much of a use case left?

Java and C# are statically typed, garbage collected languages with a huge adoption and massive amounts of tooling.

D's attempt to become an alternative to C and C++ was eclipsed by Rust, which doesn't have the GC overhead and has a ton of other really compelling features.

There are a bunch of other new and exciting languages too: Go, Nim, ...

Why would anyone choose D today? (Serious question.)

Re:Metaprogramming is less fun in D by Ace17 on Friday April 21, 2017 @02:11PM (#14167855)
> D's attempt to become an alternative to C and C++ was eclipsed by Rust, which doesn't have the GC overhead and has a ton of other really compelling features.

Rust isn't just a better C++, it imposes a new paradigm over resource management (lifetime oriented programming?). If you're coming from C++, you have to change your way of thinking. D doesn't try to make you follow any paradigm (for the better and for the worse) ; and its syntax will feel natural and terse for a C++ programmer.

My experience (10 people team) has shown all C++ programmers can learn D very quickly. Is this the case for Rust?

> Why would anyone choose D today? (Serious question.) Native speed, on-demand deterministic destruction, on-demand memory safety, metaprogramming, fast compile times, terse syntax.

Re:Metaprogramming is less fun in D by oddity on Friday April 21, 2017 @02:56PM (#14168301)
I'm tempted to think that Rust doesn't really impose a new paradigm over resource management so much as it standardizes and enforces the common conventions of C++ resource management.

A major pain point probably is that people never really followed the "conventions" of C++ resource management as rigidly as Rust enforces them.

Re:Metaprogramming is less fun in D by lbrandy on Friday April 21, 2017 @03:12PM (#14168452)
> A major pain point probably is that people never really followed the "conventions" of C++ resource management as rigidly as Rust enforces them.

That's exactly right. Rust does a great job moving idiomatic C++ best practices into the type system and actually forcing you to do it "right". And alot of the early pain people run into when switching to Rust is learning how to do this. I suspect very experienced C++ programmers have alot less challenge getting spun up on Rust. It's sorta front-loading the pain of discovering and learning C++'s best practices.

As a side effect, though, it means alot of Rust evangelism misses the mark as it mostly reveals their own C++ weaknesses (this is, on a different level, an indictment of C++, and its learning curve, but not really in the ways the evangelists often believe).

Re:Metaprogramming is less fun in D by SamReidHughes on Friday April 21, 2017 @04:43PM (#14169281)
I'd amend this to say it's a subset of the C++ conventions.
Re:Metaprogramming is less fun in D by mhh__ on Friday April 21, 2017 @03:27PM (#14168600)
Productivity. D is a very pragmatic systems language. C++ interop is basically unparalleled, UFCS makes writing libraries less traumatic and CTFE is just plain useful. On top of this, the type system is both concurrency aware and has the best generics I've ever used (Subjective as it gets, but that's my experience). If you want safety guarantees just tag a scope as @safe. Also, static reflection works really well.

Compiles(with DMD, ldc and gdc are still fast but are not as fast) are fast and

D is not really comparable with Go (For example). D is much more complex (and I my opinion simpler to write through said complexity, but obviously opinions differ), whereas Go is supposed to be simple to learn and implement.

Re:Metaprogramming is less fun in D by shakna on Friday April 21, 2017 @12:05PM (#14166766)
I wrote my thesis in D.

I considered C/++, Rust, Go, Nim and D.

D won because:

* Less manual memory management

* Awesome compile-time errors (this is absolutely key)

* Super easy tooling setup

* High-level abstractions in stdlib

* Still reasonably fast

* AOT compiled, which was a hard requirement for what I was researching

Re:Metaprogramming is less fun in D by kazinator on Friday April 21, 2017 @02:01PM (#14167755)
> I wrote my thesis in D.

Really? So like your abstract goes in the main function, or how does that work? Do you use reference types for citations or just external symbols?

Good choice of language; though, who wants a "Ph. C++" or "Ph. Rust" affixed to their name, know what I mean?

Re:Metaprogramming is less fun in D by WalterBright on Friday April 21, 2017 @02:53PM (#14168272)
> Really? So like your abstract goes in the main function, or how does that work? Do you use reference types for citations or just external symbols?

D has a documentation generator (Ddoc) as part of the language. It turned out to be useful as a standalone documentation generator. The dlang.org website is built using Ddoc, and I've even published a couple books in Ddoc. It feels a bit weird running a compiler over your marked up text, but that feeling passes after a while :-)

Re:Metaprogramming is less fun in D by systems on Friday April 21, 2017 @03:41PM (#14168746)
can D be used as drop in replacement for c++ in something like metatrader

i think, it might be worth it if you guy investigate areas like these, many trading platforms have interfaced to c/c++ if D and be added as a drop in replacement, with some more safety guarantees, you have a big niche market here that D can survive on for a long time

Re:Metaprogramming is less fun in D by petre on Saturday April 22, 2017 @03:03AM (#14171457)
D interfaces very well with C/C++ code and libraries. It was designed to do that from the begining. Some D libs are actually bindings to C/C++ libraries. You don't need to replace existing C++ code/libraries, you can just integrate them in a D project.
Re:Metaprogramming is less fun in D by shakna on Friday April 21, 2017 @02:11PM (#14167853)
You jest, but aren't as far afield as you might think.

I used a combination of Literate D [0] and pandoc to create the finished paper.

Ph. PLT still really doesn't stand out.

[0] https://github.com/zyedidia/Literate

Re:Metaprogramming is less fun in D by dom96 on Friday April 21, 2017 @12:15PM (#14166863)
Interesting. I'm curious in particular where Nim fell short, any chance you could elaborate?
Re:Metaprogramming is less fun in D by shakna on Friday April 21, 2017 @12:23PM (#14166942)
It was in a rough time for Nim, around the transition from the old name, when the documentation was still being rewritten, and metaprogramming was a magic few knew or used.

D and it's errors were just easier.

Not to say Nim isn't on my radar for new things, it just didn't quite fit at the time. (However, my first prototype was in Nim!)

Re:Metaprogramming is less fun in D by dom96 on Friday April 21, 2017 @02:29PM (#14168040)
Makes sense. Thank you for answering, is your thesis available for reading anywhere?
Re:Metaprogramming is less fun in D by shakna on Friday April 21, 2017 @02:39PM (#14168131)
Anytime.

Unfortunately not, as I no longer have the right to publish it, and it hasn't appeared in the journal yet.

But basically, partial evaluation of the AST to create a fully type-inferenced statically typed F-expr Lisp. Makes JITing faster.

Re:Metaprogramming is less fun in D by systems on Friday April 21, 2017 @12:37PM (#14167092)
but this is really a poor argument for D your thesis code, isn't necessarily code that will be used by many people or shared with many developer (you didnt even share a link to the source code)

a thesis, just produce a proof of concept

D is unpopular , and I really believe that going after c++ was a bad idea .. if this was not clear at first, it should be clear by now, yet almost 100% of the article i see on D never stop from claiming how much better it is compare to c++

I guess the lesson learned from D's unpopularity is, when creating something dont focus on one competing tool

I recall how one time Linus Torvald, bashed subversion on how "Its goal is to be a mostly compatible successor to the widely used Concurrent Versions System" -- Wikipedia

Was a horrible design choice from the start

By focusing on C++ they added a GC, as an advantage (because C++ didnt have a GC) but now that many people priase Rust for not having a GC and arguing they prefer C++ over D for it ... now they are trying to dis-integrate the GC ... very reactive, design decision ... and i doubt this will help much

Re:Metaprogramming is less fun in D by shakna on Friday April 21, 2017 @01:12PM (#14167379)
> yet almost 100% of the article i see on D never stop from claiming how much better it is compare to c++

And I see the same from Rust and Go communities, hell I see it in Swift and Java communities a fair bit too.

That's not a real argument for or against a language. It just says the community will actually compare itself to other languages in similar fields. X vs Y articles are dime a dozen.

Some of Ds library inspired things in the new C standards, and D is influenced by other languages. I fail to see how that is a bad thing.

Common Lisp influenced Closure.

CoffeeScript influenced ES2005.

C has influenced Go.

Python, Nim.

That's just natural evolution. A language trying to become more flexible, is a good thing.

Re:Metaprogramming is less fun in D by WalterBright on Friday April 21, 2017 @08:55PM (#14170559)
It's quicker to teach a language by pointing out how it differs from a similar language that the student may know.
Re:Metaprogramming is less fun in D by nix0n on Friday April 21, 2017 @03:36PM (#14168685)
As someone who contends against the horrors of C++ daily, I wish the best of success for both Rust and D.

C++ is an incredibly popular collection of footguns and its replacement is a noble design goal.

Conversely, SVN is one of the tools which I use to archaeologize within a C++ codebase. It might not be right for the Linux kernel or other FOSS projects, but in the corporate world it works fine.

Re:Metaprogramming is less fun in D by rbehrends on Friday April 21, 2017 @04:03PM (#14168961)
> Java and C# are statically typed, garbage collected languages with a huge adoption and massive amounts of tooling.

1. Java and C# are designed around JIT compilation, which results in a number of architectural choices that may or may not be to your liking.

2. The JVM and CLR are pretty heavyweight pieces of machinery.

3. Neither Java nor C# are particularly well-suited for working "close to the metal".

> D's attempt to become an alternative to C and C++ was eclipsed by Rust, which doesn't have the GC overhead and has a ton of other really compelling features.

This goes both ways: Rust doesn't have a GC, so if you want one, you're out of luck. For example, for most of what I'm doing – where GC works fine –, Rust offers me no benefit, but significant costs (note that this is a matter of application domains: the ones that Rust is designed for are simply not ones that matter much to me).

> There are a bunch of other new and exciting languages too: Go, Nim, ...

Go and Nim are indeed the languages that D is competing with more directly, but there's nothing wrong with having competition in this area, given that all of them are relatively new.

Re:Metaprogramming is less fun in D by charles-salvia on Friday April 21, 2017 @03:25PM (#14168571)
While I kind of like D, it's hard to really make the case for using it. The thing is, it simply doesn't provide that much of a significant advantage over modern C++14/17 to make it worthwhile. At least Rust introduces an entirely innovative new concept with the borrow checker. D is just basically C++ with optional garbage collection and better syntax for meta programming, but without the vast Universe of existing C++ libraries to leverage.
Re:Metaprogramming is less fun in D by Ace17 on Saturday April 22, 2017 @01:34AM (#14171244)
> D is just basically C++ with optional garbage collection and better syntax for meta programming, but without the vast Universe of existing C++ libraries to leverage.

Phobos, the D standard library, makes C++ standard library look very small. C++14 standard library still can't do "ls", "execvp", "socket" in a portable way (but we finally got std::thread and std::function!). Phobos can do all of this, and also haves support for md5, gzip, diff, sort, getopt, json, xml, ...

Thus the need for an external library is a lot less likely than it is in C or C++, and you almost never spend time rewrapping native stuff: it's already done by Phobos.

And in the end, if you need to use some specialized library, D can call C and C++ functions with zero overhead (I have D projects that use CGAL and SDL).

Re:Metaprogramming is less fun in D by mhh__ on Friday April 21, 2017 @03:43PM (#14168771)
D compile times alone are an advantage. I should probably point out that D can actually do some (More than anyone else) C++ interop.
Re:Metaprogramming is less fun in D by destructionator on Friday April 21, 2017 @05:06PM (#14169426)
D also has nice opt-in reflection as an advantage over C++ (though there are C++ tools to make up for it, to an extent).

The reflection is IMO the killer individual feature (well, hand-in-hand with the codegen to actually use it). The rest is just the benefit of 1000 small things that all add up to a greater whole.

Re:Metaprogramming is less fun in D by charles-salvia on Friday April 21, 2017 @07:51PM (#14170330)
Yeah, automatic static reflection for serialization of standard-layout structs in C++ would certainly be nice. You can achieve something like that with std::tuple, but it's certainly not comparable to first-class serialization.

PS, I used to enjoy your posts on SDN, before the site owner threw a fit. :-)

Re:Metaprogramming is less fun in D by p0nce on Friday April 21, 2017 @06:57PM (#14170104)
In my line of work (real-time), C++ typically reigns supreme but D is just as fast and more productive, so why not use it? It's not really about meta-programming, for me it wins on the basics.

And is we talk meta-programming, I think D goes further in the Stepanov style: https://www.youtube.com/watch?v=LIb3L4vKZ7U

Re:Metaprogramming is less fun in D by jackmott on Friday April 21, 2017 @12:03PM (#14166740)
D is GC optional, so that makes it pretty different than Java and C# and Go.

It also compiles to native exes as the normal procedure. You can do that with Java / C# in special cases though.

D is much easier to pick up than Rust. Rust seems to take the runtime overhead of Java/C# and put it into your brain overhead during typing time.

D has very fast compile times, Rust has very slow compile times.

Re:Metaprogramming is less fun in D by ruleabidinguser on Friday April 21, 2017 @01:22PM (#14167451)
I would like to use D if I could dump the GC, but it appears they don't make that easy, even though as you say it is possible. For me smart pointers make memory management seem not so daunting.
Re:Metaprogramming is less fun in D by bachmeier on Friday April 21, 2017 @02:12PM (#14167871)
It's actually pretty easy. Just mark your code as @nogc, and it won't compile if there's anything that could potentially trigger a garbage collection. You obviously lose some functionality this way, but there's nothing difficult about avoiding the GC.
Re:Metaprogramming is less fun in D by mhh__ on Friday April 21, 2017 @03:30PM (#14168623)
There are smart pointer libaries, and also implementing ref counting is much more straightforward than in C++ because the type system knows whether data is being shared or not.

I should add that the GC actually works perfectly fine for normal work, it justs not up to the competition (Partly because of having to work with traditional dynamic memory).