Monday, December 22, 2014

European Road Trip - xmas 2014

It's been a little over 2 years since our last road trip. This This time it's a little shorter but also spread over a longer time making the whole experience a little less intense.


We set off from Leeds on Friday night and stayed in a hotel on route to the channel tunnel then again in Luxembourg on Saturday evening, leaving a 5 hour drive to Munich on Sunday. We'll stay here for a couple of days before going south to Innsbruck for Christmas.

Monday, December 01, 2014

How To: Get started with D

As much as I like working with Java, it's nice to use a language that can be compiled to native code. Occasionally I dabble with C or C++ but the ecosystem is about as old as the languages. I want to work with a language that doesn't just have clear syntax but decent tools to handle builds and project dependencies as well as making it easy to compile on multiple platforms (Windows, Mac and Linux is a must).

D meets these needs (partly due to DUB). It's been around for over a decade but it's the second version (first released in 2007) that is currently in use.

The D compiler can be downloaded from dlang.org and DUB can also be downloaded from the sub-domain code.dlang.org. Once they are both installed and available on your PATH open up a command prompt and use DUB to initialise a project.


DUB will create your project structure and a simple manifest file 'dub.json' which will be familiar to anyone that uses NPM or Gradle.


For this simple example I've added 'vibe-d' to the project dependencies. Then in the source file I've replaced the contents of the 'app.d' file with the simple example given on the Vibe-d website.


To compile the project simply run the 'dub' command in the root of the project. DUB will then download the vibe-d library, compile and link the project, the run the compiled executable.


That's it! We have a simple server running that can be opened in the browser.


Obviously this example is pretty trivial but I've been playing with D in my spare time for some months now (working on a GTK app) and have found the transition from Java to D to be relatively painless. So go give it a try.