What features of D are you using now which you thought you'd never goint to use?

H. S. Teoh hsteoh at quickfur.ath.cx
Sat Jun 22 09:40:44 PDT 2013


On Sat, Jun 22, 2013 at 06:17:41PM +0200, Andrej Mitrovic wrote:
> I remember just a few years ago I was avoiding learning to use
> templates, thinking they're super-complicated and that I'd **never**
> actually need them. I used to read about them in the pages of the
> language reference, but nothing actually *clicked* while reading those
> pages.

Funny, templates were one of the main reasons I came to D. C++ templates
were (and still are) just so ugly and painful to work with.


> I also remember reading about the `is()` keyword which was the
> most intriguing but complex thing on the whole website that I just
> couldn't wrap my head around.

Yeah that one made my eyes glaze over. I still have trouble wrapping my
brain around the strange syntax of is(), and why its diverse uses have
been shoehorned into deceptively similar syntax.


[...]
> I wonder if newbies still get a little scared when they reach the
> template section on dlang, and if we can improve this somehow. There
> *are* tutorials out there, but dlang.org is probably where the user
> gets his first impression of the language, and it has to be an
> inviting one.

I like the way Andrei presented templates in TDPL: he just started using
them without saying what they are, other than that the function takes
"compile-time parameters". By the time you get to the chapter on
templates, you've already been using them for a while, so it's not very
scary anymore.


> Anyway, what features are you using now that you thought you'd never
> use when you started out using D?

1) Unittests. :) "Who needs unittests", I told myself, "when I'm
obviously smart enough to write code once and have it work the first
time?" But they just kept staring at me going "hey we're right here, use
us!" until I was shamed into actually writing a few of them. And then I
discovered that I *wasn't* the genius programmer I thought I was, and
that my code was actually full of bugs, typos, and all sorts of other
problems that only show up in corner cases that, of course, I'd failed
to test by hand the first time round.

2) Ddoc comments. I'm still not fully sold on ddoc, but I've actually
started using it for my personal code libraries, and it's actually quite
nice. I don't have to install DOxygen and add a whole bunch of
language-external stuff to my projects to actually use ddoc -- another
big advantage conferred by having them built into the compiler. The
default ddoc macros leave a lot to be desired, but I cooked up a simple
set of customized macros to make the output more palatable, and ddoc is
actually pleasant to work with now:

<shameless plug>
https://github.com/quickfur/Viola-ddoc-macros
</shameless plug>


T

-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth? -- Michael Beibl


More information about the Digitalmars-d mailing list