3 ms·
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 modu
by TheAceOfHearts 12y ago
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.
- Profan 12y agoAs 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 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 compile-time to generate serialization code, cutting out much bloated code. It's worth noting that it's metaprogramming for humans, _compared_ to c++, but sometimes leaves a bit to be desired documentation-wise, all the building blocks are there, but sometimes you'd like to not need to reinvent the wheel every time you attempt some metaprogramming-related task. Things I don't enjoy include the core language's reliance on the GC, including things like exceptions relying on GC allocations. Thankfully they've made it a bit easier to track down things which may allocate gc memory lately with accompanying flags to the compiler, which prints a trace of where it may happen.
- yoklov 12y agoI'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?
- CyberShadow 12y ago> 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 http://www.inventivedingo.com/mayhemig
- yoklov 12y agoWell, a couple things about it make me nervous, but CTFE and a not horribly broken compilation model might make it worth trying out next weekend...
- Profan 12y agoYou can definitely survive without the GC, personally I've gone through eliminating exceptions entirely and implementing my own allocators throughout. There are a few gotchas sometimes, like array literals of certain kinds sometimes allocating when you don't expect them to, but these can usually be sorted. Something which also might bite you, but can be caught with the gc-tracking compiler flag, is the fact that delegate _closures_ use the GC, regular delegates however will not need the GC, one thing to keep in mind. There's quite a bit of info about how the GC impacts things, and how to get by without it around, so I think you'll survive without it's presence. Lately as well, efforts to annotate portions of the standard library which don't use the GC at all with a special annotation @nogc has been underway, which makes it explicit if something can allocate or not (this is transitive, so a @nogc annotated function can only call @nogc annotated functions which can't do any gc allocation in turn).
- WalterBright 12y agoA 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.
- ekianjo 12y ago> 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 https://en.wikipedia.org/wiki/ABA_Games