Sunday, April 6, 2014

D Language: the language C++ could be

Where Is D now?

DMD logo
The history of D is quite rich by now. The language evolves for about 10 years, but the interesting thing is that the fully rethinked and redesigned D 2.0 is now in active development and still does not have its stable niches and mature practices / patterns / etc., like C++, Java, Python, and so on.

Also it worths mentioning that the development means the language itself, compilers (there are 3 for now: 
  1. dmd 2 - reference one from Digital Mars;
  2. gdc - based on gcc;
  3. ldc - llvm

), and standard library (called "phobos") often change. Also stable versions of ldc and gdc are a bit behind dmd, so it is better to use the latter in order to get access to the last features and changes of the language.

What I don't like in C++ (... after I've met D)

If you've ever tried to use C++, you can mention that the language is quite difficult itself (whatever it means). One of the evidences of that is that C++ applications can be written in dozens of coding styles, using dozens of practices and approaches. It can even seem, looking at two applications written in C++, that they are written in two different languages (consider two desktop applications, one written using bare Win32 API, and the other one using Qt).

Qt, for example, offers meta object compiler and objects tree system in order to simplify memory management and allow event-driven applications to be written in a convenient manner so that it seems you're using the very different language.

The existing of such monstrous tools for simple tasks (really, memory management mess in twenty first century?) is an indicator to me, that something is really wrong with the language.

The second thing is that no-one knows whole C++ :), (even Stroustrup o_O?). Really, you can spent years learning possibilities of the language, that was not been redesigned for decades, but dozens of new features are stably added every couple of years.

And the last thing is the absence of a comprehensive standard library (IMHO "over-templated" STL is not the best choice). Yeah, you can find hundreds of C++ json and xml parsing libraries, every framework also has those (remember Qt here :)). BUT you don't have the standard one! WTF? Everybody has!

D is Better! ... ?

Well, D does not have those disadvantages I've written about above, having the same and even more possibilities than C++. Also there's garbage collector sitting in your D application runtime. A lot of mature developers don't like GCs, but the nice thing is that you can disable or ignore it :)

Why D is better? Just try... Maybe it won't be better for you.
(c) me

SMTP Library for D

I've started learning D in practice by writing simple SMTP library that implements SMTP client low- and high- level APIs. It supports SSL/TLS encryption and PLAIN authentication for now.

Check it out at my github page. It is very far from using all tasty features of the language, but still shows how much convenient a system programming language can be still having comparable performance to C++.

To be continued ...

Have a nice D programming!