Hide
Scraps
RSS
Showing all entries tagged with: Programming

Optional value handling in Nim

6th August 2018

I recently had a look at a functional language named Toccata which amongst other things does away with booleans. While this migth seem utterly insane it's not an entirely new concept and proponents of such ideas will warn you of the perils of boolean blindness. This refers to the fact that booleans themselves carry no information apart from their value. But as others have pointed out this is true of all values and the linked article instead refers…


Handling files in Nim

4th May 2018

In a post over on Reddit someone noted that Nim doesn't really have any article or tutorial about file reading. Trying to prove them wrong led me to a half-answer over on Rosetta Code and a forum post from 2014 asking about examples on file handling. Since this is a rather simple topic I decided to write down some of the most common ways to handle files in Nim, partially in an attempt to make the…


Nim types (originally a Reddit reply)

9th January 2018

While perusing the Nim subreddit I stumbled across a post asking for an explanation of how types work in Nim, especially how Nim allocates different types on the heap and the stack. Since the answer grew pretty long I decided to post it here as well for perpetuity. What follows is a copy of my response with some additional markdown.

First order of business heap vs. stack

Whenever you call a function it creates a stack…


Cross-platform GUIs and Nim macros

23rd March 2017

A while ago I read John Novaks great rant on how hard and annoying it can be to do something as simple as extending a cross-platform application with the simplest of GUIs. Or as he puts it:

You must not under any circumstance try to open a window (on the computer, I mean), attempt to change the colour of a single pixel in it, or—god forbid!—fantasise about using native (or any kind of, for the matter)…


Presentation on Functional programming

18th March 2017

Recently I held a presentation on functional programming at the University of Tromsø. The presentation was meant as an introduction to the concepts of the paradigm and some of the ideas behind it. It also contains a short section on how the data structures that facilitate the immutable state collections without copying everything. The entire presentation was done in one hour. As I habitually didn't write any notes for what I was going to say…