A, B, C, C++ … Maybe its the turn for D now

dlogo

Today, when I was randomly reading hacker news, I noticed an article that “Facebook is using D in production starting today“. Will, it seemed funny first, the idea that their coming up with a new programming languages in alphabet order. However, the fact that D has to have some sort of magic that a gigantic company such as Facebook that has just started using it, though, it might have enormous costs.

So this actually, persuaded me to google it a little. Hence, the rest of my blog post is going to be a brief introductory about D.

Motivation

Today I committed the first 5112 lines of D code to Facebook’s

repository. The project is in heavy daily use at Facebook. Compared to

the original version (written in C++) we’ve measured massive wins in all

of source code size, build speed, and running speed.(Andrei Alexandrescu)

 

So the fact that Facebook is a big company and the short paragraph above posted by Andrei on Dlang ( Official D website) was a bit of enough motivation for me but If you need more, you may want to consider the fact that D is almost as efficient as C and C++ while providing OOP and Garbage Collection and so many features that Java does over C.

What does it have?

Briefly, D almost has main features that C++ doesn’t and Java does. Personally, I’ve been programming Java for past 5 or 6 years and I’ve been enjoying features that it provides such as the famous GC. However, I believe D’s features and efficiency temps me to put it on top of the languages that I’m going to learn.

You may see the complete list of D’s features here. However, the ones that mainly got my attention are:

  • D is a complete Object Oriented programming language which doesn’t support multi inheritance as Java doesn’t. But, similar to java, D has Interfaces.
  • D deploys Hans-Boehm to provide Garbage Collection to the programmers
  • You hate that with Java you never get to directly control the hardware? Well in D thats possible.
  • If you’re into writing big generic codes and you love the way Java handles it? well, D provides something so similar.
  • Type safety
  • Contract programmin, which I found it pretty amusing since I don’t know what it exactly is (probably the subject for my next post).
  • Supports functional programming

So is D Platform Independent too?

Well, no. Thats probably the main reason that Java is still used :D. Yeap, I’m joking, Java is still a more developed language that D and the fact that is widely used is so important because there has been so many frameworks and libraries developed using Java that almost makes it invincible . There are also a lot of other features such as Reflection that you may not be able to find in D.

D is  “C++ done right”

How efficient ?

In D’s official website it is indicated that:

  • D compiles naturally to efficient native code.
  • D is designed such that most “obvious” code is fast and safe. On occasion a function might need to escape the confines of type safety for ultimate speed and control. For such rare cases D offers native pointers, type casts, access to any C function without any intervening translation, and even inline assembly code. See example.
  • The @safe, @trusted, and @system modular attributes allow the programmer to best decide the safety-efficiency tradeoffs of an application, and have the compiler check for consistency. Read more.

However, any computer scientist or software engineer needs to see numbers to accept something. I don’t buy some thing that is written in some products website unless a third party proves it. Therefore, I invite you to take a look at Lars post “How fast is D compared to C++” at Stack Overflow which totally demonstrates its performance.

  • D (const ref arguments, dmd compiler, correct optimization): 9.6s
  • D (in arguments, dmd compiler, correct optimization): 6.1s
  • D (in arguments, gdmd compiler, correct optimization): 3.9s
  • C++: 3.8s

So this shows that if programs in D are compiled optimized with maximum features it may be as efficient as C++.

So does anyone really use D?

Personally, I thought D is more like a experimental programming language since I had never heard of, But, a glance at answers to Dan Rigby’s question at Stack Overflow demonstrates that there are people in various fields taking advantages of what D provides that I didn’t know about. But, in one sentence, Anyone who wants quite great performance and rather not do anything manually like they have to do it in C++ and don’t worship C and C++ as the mother of all modern languages may decide to  use D.

  • D is used for server side programming. It provides CPP’s performance while providing many features that many find C++ a pain in the ass for not providing.
  • Bioinformatics
  • Mail servers
  • Hardware or software automatic testing
  • Network infrastructure
  • Game programming
  • and etc.

So is there any excuse not to take a look at D?

Simply, NO?

2 comments On A, B, C, C++ … Maybe its the turn for D now

Leave a reply:

Your email address will not be published.

Site Footer