For nearly 12 years I have been using C/C++ on a daily basis. It wasn’t until a few days ago that I stumbled upon D.
I put together this post to remind myself how to set up and prepare a working, enjoyable D development experience.
As usual, the easiest solution for installing software on the Mac is not the app store but installing Homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
The D compiler
Getting the D compiler installed is actually very simple:
brew install dmd
The D package manager
Contrary to your experience with C/C++, D comes with a package/project manager by default. Dub is its name.
brew install dub
… and development tools
Just like Go, D is a helpful language and so it comes with tools to support development, namely
- DCD: the D Completion Daemon is an auto-complete program for the D programming language
- dfmt: Dfmt is a formatter for D source code
- dscanner: Swiss-army knife for D source code, basically a code analyzer for D.
To install all of these
brew install dcd dfmt dscanner
… and bonus points for Visual Studio
Since I have been using Visual Studio Code, I wanted to figure out if there is an extension that would support D development and there is:
The D language extension basically gives you everything you might desire for getting started.
Features of the D language extension
- Syntax Colorization
- Autocompletion using DCD
- Formatting using dfmt
- Linting using Dscanner
- Code upgrade using dfix
- Profiling using D Profile Viewer
- Integration with Dub using VSCode commands and tasks