Refactoring the D Koans with metaprogramming

馃挕 The problem Welcome back, it鈥檚 been quite a long time since my last ramblings on the D Programming Language! This post is born from a necessity. An old project of mine, the D Koans, was using an external library to simplify unit testing, which is more or less the core of the whole project. Unfortunately, the library started giving some deprecation warnings when compiled with recent D versions. Since the D Language already has an internal unit testing framework, I thought it would be nice to remove the single dependency and rely only on the standard library. Initially, with some global search/replace, I managed to convert all the tests to unittest blocks. ...

May 21, 2025 路 Andrea Manzini

a 'pythonic' fileinput module for the D programming language

When I write small command line utilities in Python, I often take advantage of the fileinput module that makes working with text files very convenient: the library permits to write quickly and easily a loop over standard input or a list of files, something like perl -a or awk line processing. Then the size of input data grew, and also for a language comparison, I wanted to port my utility in the D programming language, but I cannot find an equivalent module, so I decided to write one myself. ...

January 25, 2021 路 Andrea Manzini

Hijack C library functions in D

I like playing with the D programming language and I wrote this little post to show how it鈥檚 easy to create a dynamic library (shared object, .so) that can be invoked in other programs; to have a little fun we will write a D replacement for the rand() C standard library function call. For your convenience, all the code is also on github Let鈥檚 start with the demo implementation, a C program that calls 10 times the stdlib function rand() to get a random number. ...

March 10, 2020 路 Andrea Manzini

a very simple NTP client in D

I am quite a fan of the D programming language and I think it deserves more attention, even if since a few months it鈥檚 becoming more and more popular, as it gained top20 in the TIOBE Index for February 2020. As an experiment in network programming, I took this simple NTP client written in C and translated to D ; in my opinion while it鈥檚 keeping the low-level nature, it鈥檚 shorter, clearer and more effective. It鈥檚 only a dozen lines of code, but full program is available on my github; stars and contributions are welcome! ...

February 20, 2020 路 Andrea Manzini