24 days of Rust - structured logging

I hope you're using any sort of logging in your applications. Even if that means printing stuff to stdout and relying on shell output redirection, it's still better than no logging at all. However, most programming languages have great libraries for logging. Be it Java, Python, Elixir - there are logging utilities everywhere. But more often than not, what is logged is some sort of prose that a programmer thought was applicable at a time.

I once wrote this line of Python code:

logger.error('Oh no, something terrible happened: %s', details)

Even though I've configured my logging levels, formatters and other stuff that's very useful, in the end I still had to grep terrible to find what actually happened, and later parse the details with a nasty regexp. Not very convenient. Structured logging is a concept that puts events over messages; we're now logging events with associated key-value data, not plain string messages.

Continue reading »
Written on Dec. 3, 2016

24 days of Rust - rayon

Let me start this article with a confession: I suck at writing parallel code. I have only a vague idea about mutexes, locks and other low level primitives for handling data between threads. And since I work mostly with Python, I tend to use multiprocessing (if I bother to parallelize at all) rather than threads.

However, one of the selling points of Rust is its approach to concurrent/parallel programming. Mozilla recently released a video encouraging people to write parallel code that is safe and approachable. Then I heard about rayon - a library for data parallelism that is very approachable and lightweight.

Continue reading »
Written on Dec. 2, 2016

24 days of Rust - hound

My engineering diploma involved some digital signal processing (DSP), in particular sound generation and recognition. Throughout my studies I went through a ton of audio files, usually using C++ to process them. I've written a custom .wav file loader, of course missed a few edge cases and it crashed upon receiving new training data from my supervisor...

A few months later I discovered that Python suports WAV in the standard library. Since then I try not to reinvent the wheel when it comes to processing .wav files. Luckily there's a great library for doing that in Rust - hound.

Continue reading »
Written on Dec. 1, 2016