A new project to learn the Crystal Programming Language

I’ve started a new side project named Crystal Koans, it’s a simple series of exercises organized as a big unit test suite. The “koans” are heavily inspired by similar projects for other languages, but I didn’t found anything similar for Crystal. The project has been included in the awesome collection under the official Learning Resource for the language. I’ll try to maintain and evolve it in the spare time, I hope you’ll find it useful, and any form of contribution is welcome. ...

November 20, 2020 · 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’s 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’s 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’s 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’s keeping the low-level nature, it’s shorter, clearer and more effective. It’s only a dozen lines of code, but full program is available on my github; stars and contributions are welcome! ...

February 20, 2020 · Andrea Manzini

il linguaggio Lua: parte 14

segue dalla parte 13 Coroutine Come approccio alla programmazione concorrente, il linguaggio Lua non ha meccanismi interni per gestire nativamente i thread, ma si può appoggiare a ciò che offre il sistema operativo sottostante. Lua invece internamente offre il supporto alle coroutine: un programma Lua può avere diversi percorsi di esecuzione ‘parallela’ ognuno col proprio stack e variabili locali ma che condividono risorse e variabili globali con le altre coroutine. La prima differenza sostanziale col modello classico dei thread è che in un determinato istante ‘gira’ una e una sola coroutine, mentre in un sistema multiprocessore ci possono essere più thread in esecuzione in contemporanea. ...

February 15, 2019 · Andrea Manzini