Some impressions/notes from a new D programmer

mark mark at qtrac.eu
Wed Feb 12 10:39:06 UTC 2020


I've been learning D for a few weeks now.

I'm an experienced programmer in other languages (esp. Python, 
but also Rust and C++).

Here're some *early* impressions and notes.

D Tour

I found the D Tour, esp. "D's Basics" to be very helpful. Each 
part is short and in most cases understandable. Being able to run 
and edit the code is a real help for learning.

D Playground

The D playground https://run.dlang.io/ is very useful for trying 
out snippets and generally learning, so I use it a lot. (I still 
haven't worked out how to save a URL to my code though.)

Library Reference Documentation

The Library Reference documentation seems to be a mixed bag. 
Often I've found a good overview at the start, but then few or no 
examples in the docs for classes and methods (see e.g., 
https://dlang.org/phobos/std_zip.html#.ZipArchive).

I don't find the presentation of the member properties and 
methods very easy to read, but the worst aspect is the lack of 
examples.

Standard Library

The library itself "feels" a bit incomplete, which is surprising 
given how long D's been around. To give just two examples:

The lack of set and B-tree types is disappointing (esp. 
considering that the much younger Rust has them). I'm using 
rbtree for sets but that imposes a requirement that my items 
support < (rather than the == or hash I'd expect for a set).

The fact that the return value of std.file.getAttributes() means 
completely different things on POSIX and Windows. That's fair 
enough, but there ought to be a platform-neutral equivalent for 
those writing cross-platform applications that returned, say, a 
struct or tuple with the common subset of attributes normalised. 
(And if there is such a function, why isn't it cross-referenced.) 
There seems to be a curious mixture of functions which are POSIX- 
or Windows-specific and those which are platform neutral.

The D Language

The D language seems to be a "kitchen sink" (i.e., has 
everything) like C++, Rust, (and nowadays, Python). This makes it 
big and a *lot* to learn. However, I managed to create a little 
library that used template types (with some help from this 
forum), and I _understand_ the templates. This is a huge 
improvement over C++ or Rust. And to my surprise, so far my D 
programs have about the same line counts as the Python versions.

Also, I've found building much easier than C++. However, dub 
doesn't seem to be competitive with Rust's cargo. Getting fast 
statically built (no dependency) executables is really nice.

GUI Programming

I've tried a number of D GUI libraries, and all bar one have been 
problematic.

To my surprise GtkD was easy to install on both Linux and Windows 
and getting "hello world" to build and run was fairly easy. The 
documentation doesn't seem that easy to use, but I'll start with 
Ron Tarrant's https://gtkdcoding.com/ and see how I get on from 
there.

D Books

I find Ali Çehreli's book (http://ddili.org/ders/d.en/index.html) 
more suited to complete beginners, but I am skim reading it and 
finding it useful here and there.

The main books I'm reading are Mike Parker's Learning D and Adam 
Ruppe's D Cookbook, both of which I think are pretty good. 
(However, I hope both will produce more up-to-date and improved 
second editions with a better publisher.)

Learn D Forum

People on this forum have always provided polite and helpful 
answers. This is a very important intangible benefit of the 
language.

Conclusion

My hope was that D would offer a sweet spot between Python's ease 
and speed of development and Rust's performance. And so far this 
looks like being the case.


More information about the Digitalmars-d-learn mailing list