I started learning C++ when I was 17 (in 2007). Back then, I thought that learning C++ was the way to become a game programmer — my teenage-hood (is this even a word?) dream . Although I have learned that it can be accomplished with other languages as well, knowing C++ is still, in my opinion, an important skill for a Computer Scientist to posses.
Nowadays I can say that I am fairly proficient with the language. I have made some small 2D games using C++ and I’m also using C++ for a client-server game I’m currently making — Shape Wars.However, compared to more modern languages, C++ seems a bit outdated.
One day I discovered a “new” and interesting language, called D. After browsing its official site, I decided that this is the language I want to program in, as an alternative to C++.
D is a language with C-like syntax and static typing. It pragmatically combines efficiency,control, and modeling power, with safety and programmer productivity.
So what is good about D?
- No header files! Modules to the rescue
- Compiles blazingly fast
- Unicode aware string types
- Functional style programming (or not if you don’t like it)
- Garbage collector
- A package manager
- Is fast (± 10% the speed of C++)
- Can interface with libraries written in C
- Limited interfacing with C++
- Compiles to native code or…
- …can be used as a scripting language
- Many, many more…
Like everything, there are also downsites:
- Garbage collector. D’s GC is nowhere near as good as .NET’s or JVM’s
- The language/runtime changes regularly and code breaks (the situation is better than the past though)
- There are not a lot of libraries
If you have noticed, I have included garbage collector as both an advantage and a disadvantage. For some applications a GC is not a problem, while for others (real-time applications, e.g games) can be a disaster.
Thankfully, an annotation (@nogc) has been recently added which you can use to make sure your program does not allocate memory using the GC. However, many things in the language allocate using the GC – exceptions and strings come to mind, so it cannot be completely avoided for now. There is ongoing effort to make the GC completely optional.
So are you ready to learn something new? If yes, let’s dive into the world of D!
If not, thanks for reading anyway 🙂
If you don’t understand everything written above, there’s no need to worry. We’ll come to those subjects (and more) in the upcoming tutorials.