Peter's DevLog https://peterme.net/ I'm a computer scientist from Norway with interests in tinkering, open source, and game development. This log is intended as a way to both share my projects and keep myself from forgetting them. en-uk Wed, 26 Feb 2025 20:38:53 GMT Couch CMS Labelled exceptions for smoother error handling https://peterme.net/labelled-exceptions-for-smoother-error-handling.html <p>Error handling, a contentious and oft-discussed topic. Each language has some way of dealing with errors, be it error codes, result types, exceptions, something entirely different, or a mix. How to properly deal with things going wrong in our programs has been important pretty much ever since we started writing&hellip;</p> Wed, 01 Nov 2023 11:34:30 GMT Teaching old C code new tricks with Nim https://peterme.net/teaching-old-c-code-new-tricks-with-nim.html <p>Recently I was met with an interesting problem when wrapping a C library in Nim. The library in question was <a href="https://github.com/LuaDist/mapm">MAPM</a>, an older but quite complete library for dealing with arbitrary precision maths. Unfortunately the library doesn&rsquo;t have much in the way of error handling. If something goes wrong&hellip;</p> Fri, 08 Sep 2023 13:49:28 GMT Setting up a Nim server for dummies https://peterme.net/setting-up-a-nim-server-for-dummies.html <p>Nim is a great candidate for server development, but if you want to run your own server and are new to the world of server management or Linux there can be a daunting amount of information to consume in order to do it right. In this article I&rsquo;ll give a&hellip;</p> Thu, 08 Jun 2023 08:54:26 GMT Wrapping C libraries in Nim https://peterme.net/wrapping-c-libraries-in-nim.html <p>As we discovered in my last article, Nim will by default generate C code and then call on a C compiler to actually produce a binary. This might seem like an odd choice, especially in the age of LLVM. However it&rsquo;s actually not uncommon for languages to compile or transpile&hellip;</p> Sun, 16 Apr 2023 20:22:49 GMT Dynamic libraries in Nim https://peterme.net/dynamic-libraries-in-nim.html <p>This is a question which has been asked in various places over the years, and recently on the forum in multiple separate threads. Seeing how I&rsquo;ve built commercial software with Nim dynamic libraries, I thought I&rsquo;d chime in with my knowledge. But since there are multiple threads out there and&hellip;</p> Sun, 19 Feb 2023 22:12:54 GMT Is Nim a transpiler? https://peterme.net/is-nim-a-transpiler.html <p>This is a question that has come up time and time again in the IRC channel, when talking to people in person, and in the comment section pretty much every time Nim has an article on Hackernews or one of the bigger programming subreddits. It&rsquo;s also a question that has&hellip;</p> Tue, 19 Oct 2021 12:16:34 GMT Asynchronous programming in Nim https://peterme.net/asynchronous-programming-in-nim.html <p>In the <a href="https://peterme.net/multitasking-in-nim.html">previous article</a> we got a small primer on various kinds of multi-tasking, in this article we&#39;ll have a look at possibly the simplest form of this. Namely asynchronous execution. As discussed in the last article asynchronous execution is a way for our programs to tell the hardware&hellip;</p> Fri, 03 Sep 2021 07:53:49 GMT Multitasking in Nim https://peterme.net/multitasking-in-nim.html <p>This is a series of articles about a topic in the Nim ecosystem that has so far been written fairly little about. Namely threading, asynchronous operation, and communication.</p> <p>To begin we first need to have a good grasp of the concepts we&#39;re going to discuss. There is quite a bit of&hellip;</p> Fri, 03 Sep 2021 07:47:09 GMT Fixing a broken Firefox session https://peterme.net/fixing-a-broken-firefox-session.html <p>In order to stifle my tab-hoarding habits I have recently set my Firefox install to not recover sessions when I restart the browser. This means that every time I turn my computer off for the day it will delete all the random documenation pages and weird links people have sent&hellip;</p> Tue, 27 Apr 2021 09:08:02 GMT Video content - Advent of Code 2020 https://peterme.net/video-content-advent-of-code-2020.html <p>For <a href="https://conf.nim-lang.org/">NimConf2020</a>, our first virtual Nim conference, I realised how poor my microphone setup was. I have previously toyed with the idea of recording videos for various projects, or just presentations in the same style as the one I did for NimConf. For the conference I borrowed a better&hellip;</p> Tue, 15 Dec 2020 08:45:35 GMT