Live data from Hacker News

How does D improve on C++17?

p0nce.github.io

11–20 of 77 posts

Re: How does D improve on C++17?

#11

I'm curious how many people out there on HN actully use D and what for? I don't typically see D based projects here on HN so it would be interesting to find out about any use cases where D was found a perfect fit.

WalterBright uses it in his compiler.

>WalterBright uses it in his compiler.

Ironically, the dmd compiler is written in C++.

Re: How does D improve on C++17?

#12

D looks like a really interesting language, I had never checked it out prior to reading this. unittest blocks look like they'd be super helpful. And it has modules, which I consider a must-have. In what areas would D excel? What are its downsides? What did you like and dislike the most? I'd be really interested in hearing about people's experiences.

A bit of an overlooked area where D excels are its support for transitive immutability and function purity. We're discovering more and more things that are now practical because of this.

Re: How does D improve on C++17?

#13

Earlier quoted context omitted.

WalterBright uses it in his compiler.

>WalterBright uses it in his compiler. Ironically, the dmd compiler is written in C++.

D didn't exist when the dmd compiler was written. But Daniel Murphy has written a C++ to D converter, and it's looking like the next release will have dmd written in D.

Re: How does D improve on C++17?

#14

Earlier quoted context omitted.

>WalterBright uses it in his compiler. Ironically, the dmd compiler is written in C++.

D didn't exist when the dmd compiler was written. But Daniel Murphy has written a C++ to D converter, and it's looking like the next release will have dmd written in D.

>it's looking like the next release will have dmd written in D.

Is that going to make it trickier for GDC/LDC to stay in sync with DMD? (Either way, it's exciting news!)

Re: How does D improve on C++17?

#15

Earlier quoted context omitted.

D didn't exist when the dmd compiler was written. But Daniel Murphy has written a C++ to D converter, and it's looking like the next release will have dmd written in D.

>it's looking like the next release will have dmd written in D. Is that going to make it trickier for GDC/LDC to stay in sync with DMD? (Either way, it's exciting news!)

Tricky or not, they're on board with the jump.

Re: How does D improve on C++17?

#16

I'm curious how many people out there on HN actully use D and what for? I don't typically see D based projects here on HN so it would be interesting to find out about any use cases where D was found a perfect fit.

I use D for ... almost everything. https://github.com/CyberShadow?tab=repositories

Here's a bit of code from a personal shopping comparison program I wrote a few days ago, which combines some standard library constructs with my own libraries:

  string findProduct(string name)
  {
      return
          ("http://www.tp-link.com/en/search/?q=" ~ encodeComponent(name))
          .download
          .readText
          .toXML
          .xmlParse
          .I!(doc => zip(
              doc
              .findAll("#productResult > li > dl > dt > a")
              .map!(e => e.attributes["href"])
          ,    
              doc
              .findAll("#productResult > li > dl > dt > a")
              .map!(e => e.children[$-1].text.strip)
          ))
          .filter!(t => !icmp(t[1], name))
          .I!(r => r.empty ? null : "http://www.tp-link.com" ~ r.front[0])
      ;
  }

Re: How does D improve on C++17?

#17
post #5

D looks like a really interesting language, I had never checked it out prior to reading this. unittest blocks look like they'd be super helpful. And it has modules, which I consider a must-have. In what areas would D excel? What are its downsides? What did you like and dislike the most? I'd be really interested in hearing about people's experiences.

As a D programmer currently making a small game engine + networked rts game in the language, invariant blocks are another thing I really enjoy about the language: http://dlang.org/contracts.html#Invariants Lets you specify contracts which are asserted on construction and destruction, it's great. The meta programming is also wonderful for things like serialization of data, simply iterating over a type's members at com…

I'm always on the look out for improvements to C++, and it's been a while since I looked at D... Hope you don't mind if I ask you a couple questions.

Can you still turn off the GC? Lets say I don't like exceptions, and that I don't mind implementing library code on my own, would turning GC off impact anything else?

How is the story for deploying executables to mac/win/lin? Is it as easy as C/C++?

Also, do you know if anybody's shipped high quality games with it before? It's been a while now, I'd hope so, but I haven't heard of any. Pretty sure no AAA games have used it but maybe some indie?

Re: How does D improve on C++17?

#18
post #17
post #5

Earlier quoted context omitted.

As a D programmer currently making a small game engine + networked rts game in the language, invariant blocks are another thing I really enjoy about the language: http://dlang.org/contracts.html#Invariants Lets you specify contracts which are asserted on construction and destruction, it's great. The meta programming is also wonderful for things like serialization of data, simply iterating over a type's members at com…

I'm always on the look out for improvements to C++, and it's been a while since I looked at D... Hope you don't mind if I ask you a couple questions. Can you still turn off the GC? Lets say I don't like exceptions, and that I don't mind implementing library code on my own, would turning GC off impact anything else? How is the story for deploying executables to mac/win/lin? Is it as easy as C/C++? Also, do you know if…

> Can you still turn off the GC? Lets say I don't like exceptions, and that I don't mind implementing library code on my own, would turning GC off impact anything else?

You can turn off the GC in the sense that memory allocation will always request more memory from the OS instead of occasionally starting a collect cycle. However, you can alternatively use manual memory management (malloc/free, allocators/RAII on top of that, etc.), which will never trigger the GC.

> How is the story for deploying executables to mac/win/lin? Is it as easy as C/C++?

Yes. I think for Posix systems, you can optionally link dynamically to the runtime/standard library.

> Also, do you know if anybody's shipped high quality games with it before?

IIRC, Remedy Games used D for engine scripting on XBox 360. Manu Evans talked about this at DConf 2013.

Here's a commercial indie game written in D: http://www.inventivedingo.com/mayhemig

Re: How does D improve on C++17?

#19

D looks like a really interesting language, I had never checked it out prior to reading this. unittest blocks look like they'd be super helpful. And it has modules, which I consider a must-have. In what areas would D excel? What are its downsides? What did you like and dislike the most? I'd be really interested in hearing about people's experiences.

> In what areas would D excel?

Making games? :) I'm half joking here, Kenta Cho has made tons of shoot'em up games, mostly written in D (and released as Open Source) for years:

https://en.wikipedia.org/wiki/ABA_Games

Re: How does D improve on C++17?

#20
> D has no need for a preprocessor

How does this work, specifically conditional compilation? I have lots of code like this:

   #if __APPLE__
      /* do things the OS X way */
   #else
     /* do things the Linux way */
   #endif

Where the OS X way calls functions that do not exist on Linux, and vice-versa. How does D handle this?
Post reply on HN