
Ask HN: What are you using D (language) for? - vram22
I had posted a similar question about Go(lang) here on HN a while ago, and there were some interesting answers. Since I&#x27;m using D some nowadays (mainly for small utilities as of now, but may do other things with it later), and liking it, I thought it would be interesting to ask the same question about D.<p>Thanks in advance to all who answer.<p>Edit: Add the &quot;Ask HN&quot; prefix to the post title.
======
Profan
Currently using it to write a small OpenGL wrapper which intends to remove the
explicit binding (and remove redundant binds under the hood), as well as make
data definitions declarative, this is part of my plan to make a XNA-like
gamedev lib for D, so I can make games in my favourite language!
([https://github.com/profan/gland/blob/feature/compute/example...](https://github.com/profan/gland/blob/feature/compute/examples/instancing/source/app.d))

It's still a bit awful and lacking most of what I want to support with it, but
even in early days, it feels promising.

Was working on a small 2D game engine earlier, but got snagged on that working
with OpenGL was so horrible generally that I figured I could utilize D's
metaprogramming abilities to well, improve the experience. (got inspired by
rust's glium)

Hopefully I'll actually complete it.

------
snitko
Not directly answering your question, but I've actually gotten interested in D
because I wanted to learn something I can code hardcore stuff in (I mostly do
web: js, dart, ruby, bitcoin in js). So I started learning D and thought I
should try myself writing a simple Terminal emulator - this idea intrigued me
because I didn't know where to start and how it all comes together. Then
someone pointed me to a terminal emulator written in D:
[https://github.com/gnunn1/terminix](https://github.com/gnunn1/terminix) \- I
decided I should probably study it and understand how various parts come
together. From the description and the looks of it, it looks great.

~~~
vram22
Yes, that sounds like a significant project to take up. Interesting. The
screenshot looks good. Also these features sound cool, though I have to think
of what uses they could be put to:

Terminals can be re-arranged using drag and drop both within and between
windows

Terminals can be detached into a new window via drag and drop

Input can be synchronized between terminals so commands typed in one terminal
are replicated to the others

The last one reminds me a bit of kibitz, a tool written using Expect (IIRC),
that I had tried out some years ago, on Unix. I think it allowed you to have a
sort of session with a user on another computer, and if you were in say vi,
they would see the same vi screen on their machines, and your changes as you
made them - something like that (like screen sharing on Skype nowadays, but
this could have been there from before Skype, Hangout, etc.) Might not be
quite correct about the description of what it did, since I only used it
briefly and some years ago.

------
p0nce
I make commercial audio plugins with D:
[http://www.auburnsounds.com/](http://www.auburnsounds.com/)

Was featured on the D Blog: [https://dlang.org/blog/2016/07/07/project-
highlight-auburn-s...](https://dlang.org/blog/2016/07/07/project-highlight-
auburn-sounds/)

~~~
vram22
Cool. Had come across your site a month back when looking up D info, maybe via
the This Week in D series. Congrats.

------
WebFreak001
Im using it for everything I do. Small and big GUI apps, some tiny games I
made use D, all my website backends are in D now and I try to use D everywhere
I can.

~~~
vram22
That's pretty cool. What GUI framework and on what OS(es)? and for web
backends, is it vibe.d or some other thing?

~~~
WebFreak001
Most of the time I use GtkD because my target platform is mainly linux but if
I also want to target windows I use DlangUI. Don't actually target OSX but the
apps happen to work on there too.

For the web backends I always use vibe.d

~~~
vram22
Great. Any comments on GtkD vs. DLangUI, in terms of ease of use, features you
need, look-and-feel on the different OSes, etc.? Planning to write a few small
GUI apps in D to try it out as a platform for that. Mine will be only on Linux
and Windows, though, since I don't have a Mac.

------
brett40324
Higgs is a JavaScript JIT compiler written in D.

[https://github.com/higgsjs/Higgs](https://github.com/higgsjs/Higgs)

~~~
vram22
Cool. That would be a complex project. Wonder what it is named after - the
boson? :)

~~~
tachyonbeam
It is named after the particle. It's the successor to another compiler named
Tachyon :D

------
dhasenan
[https://github.com/dhasenan/damask](https://github.com/dhasenan/damask) \-- a
MUD with procedurally generated content.

MUDs are the original MMOs. Zork but over the network.

D is a good fit for this because it simplifies my programming model. A MUD is
typically heavy on scripting (or at least, it is if you want it to do anything
interesting). These scripts need to be lightweight, since I might have one
script instance for every player (to handle automated combat behaviors),
several for each NPC, and even some rooms and items have scripts attached.

In order to simplify script writing, I want to be able to write my scripts in
a simple, procedural way that lets me pretend that my current script is the
only thing running. That means fibers. Not just fibers, but fibers that I have
a fair bit of control over.

What languages have fibers? Not many. C/C++ have library support, but that
means manual memory management and plenty more pain. Go's fibers are too
opaque -- I want to have a watchdog that can ensure that every mob has an
active behavior, for instance, and I want more control over scheduling. Mono
used to have working continuations, but that was a long time ago, and they
don't work anymore, as far as I can tell. Ruby and Python have fibers, but
without static typing, I write code that is less reliable, containing more
errors, that is harder to reason about.

[https://github.com/dhasenan/subtex](https://github.com/dhasenan/subtex) \--
doing to LaTeX what BBCode did to HTML.

I write. I want to create ebooks from what I write. Previously, my process
was: write in LaTeX (primarily using a double handful of macros instead of
using LaTeX builtins), use htlatex to produce HTML; use a script to inline CSS
rules to work around a calibre problem; use calibre to generate the ebook.
Four seconds total for a 75k word book, and it vomited a bunch of temporary
files everywhere. I could do better -- primarily by doing less.

Initially the benefits for using D came from Pegged, an easy-to-use parser
generator; that sped development enough to make me happy working on the tool.
However, Pegged was relatively slow -- it dropped time by only about 20%. At
first I thought it was my ebook generation code, so I changed it around to be
more allocation-friendly and faster. This was trivially easy to do in D. But
that had no effect on the execution time.

I looked into it a bit closer, and it turned out that the Pegged parser was
taking almost all the execution time. So I shrugged my shoulders and wrote my
own parser. It was shockingly easy.

One specific thing I wanted to do is figure out, when there's a parse error,
which line and column it's on. Normally that means keeping track of line and
column numbers during normal processing, which is quite annoying and gets in
the way of everything you want to do. But it turned into about three lines of
code in the end, without interfering with normal parsing. Similarly, it's
usually a bit of annoyance to keep track of where you are in the input. D's
array slicing again made it trivial -- I just maintained a slice of the input
string representing the part I hadn't parsed yet. No off-by-one errors. No
segfaults. No array bounds errors. It worked the first time.

Nothing I _couldn 't_ do in another language, but D puts it all at my
fingertips.

That ebook that took multiple seconds with LaTeX? 0.04 seconds with Subtex. I
had to double check to ensure that it actually ran the first time after I got
my parser working.

My experience with D has been mostly positive, aside from missing libraries.
But that's getting better with time.

~~~
vram22
Interesting. Thanks for the detailed answer. I'm not into MUDs or Latex
myself, but will check out your projects at least some to see if I can learn
any language idioms or usage of language features. I did write a couple of
small tools using my xtopdf toolkit (Python), to allow creation of simple PDF
ebooks from text or XML input, but it does not use a markup approach, instead,
it leverages the structure of text and XML files.

