Mutation typing - a not-yet workable idea

I think mutation testing is a pretty fine idea. The idea of mutation testing is to deliberately add a bug into the program and then check that the test suite catches that bug. We add the bug into the program by mutating a part of it, since if you change code that you believe is all correct, then presumably it cannot still be correct. Of course mutating the program can be mechanised and hence we can test many many mutant programs. Mutation testing does not test your program code, but how effective your test-suite is. Mutation testing is used to improve your test-suite. ...

February 18, 2021

Foldl and foldr

This is a pretty entry level post on functional programming. It concerns the folding patterns in functional programming. I’ll be using Elm as an example language, but the ideas are broadly similar in other functional languages. So I’m talking about the fold functions List.foldl and List.foldr. I’ll talk about a strict/eager language, though one of the interesting things about folds is that in strict languages the foldl is the ‘good’ one, whilst in lazy languages the foldr function is the ‘good’ one. I’m going to try to explain why the foldl is the good one in strict languages, I’ll leave why ‘foldr’ is the good one for lazy languages for another day. ...

February 11, 2021

Immutability bugs

I am a paid up member of the immutability appreciation society. I believe programming in an immutable language reduces bugs, as well as potentially helps the compiler optimise your code (though perhaps at the cost of not being able to do similar optimisations yourself). I also rather suspect that immutability has a role to play in concurrent code, but that’s somewhat irrelevant for today. However, although I feel that immutability reduces bugs, I do not think of it as a strict subset. A strict subset would imply both that, some bugs introduced using a mutable language are simply not possible, or at least less likely when using an immutable language and also there are no bugs introduced using an immutable language that would be impossible or less likely when using a mutable language. It’s the second part I disagree with. I think most immutable programmers know this, but it’s worth reminding ourselves of this. It’s very easy to get comfortable in our land of the fewer bugs. ...

January 23, 2021