A defense of OCaml

OCaml is a somewhat niche programming language. It lives in the small island of functional programming languages, but it’s often compared, not very favourably, with Haskell. This makes OCaml niche even among its peer FP languages. Yet, OCaml has a very interesting feature combination that, in my opinion, makes it stand out, even when compared to Haskell. Note that, in all this post, I am going to compare a lot OCaml with Haskell, yet it shouldn’t be read as a comparison between the two languages. I chose Haskell to stand for whetever other similar programming language there is on the small island of function programming languages, because it is, to my knowledge, the most famous and used among those. ...

June 9, 2024 · 20 min · jthulhu

The periodicity lemma: two elegant proofs

The periodicity lemma is a widely useful result about word combinatorics. Yet, the paper that if often cited as the source for its proof, Uniqueness Theorems for Periodic Functions, uses very unusual techniques in stringology. If a word \(w\) has periods \(p\) and \(q\), and is of length at least \(p+q-\gcd(p, q)\), then \(w\) has period \(\gcd(p,q)\). Before proving this stronger version of the lemma, let us state a weaker version. The point is that this alternative version has a purely combinatorics proof, that is also interesting per se. ...

November 7, 2023 · 4 min · jthulhu

Challenging TDD: can tests cover every feature?

After having spent some time in the Pharo community, I have realized how much people rely on tests, not only to find bugs, but as a core developping tool. In Pharo, the idea of TDD is really pushed as far as it can go: the typical workflow is to write unit tests, run them, which of course fails (because no other code has been written yet) complaining that a given method is not implemented. This failure is caught by the Pharo runtime, which opens their cool debugger. The important part is that the debugger allows you to write code right away, to fill up the missing method. Then, you ask the debugger to continue the execution where it was left, and the Pharo VM patches every live object to take into accounts the modifications you have done. ...

November 2, 2023 · 12 min · jthulhu

Efficient streaming regular pattern matching

Regular pattern matching is comes up very often, both in theoretical frameworks and in practice and, as such, is a problem that has been studied a lot. The RAM model in which it is studied, however, does not always take into account the practical difficulties that arise with very large amount of data, which don’t fit in memory. For this reason, it makes sense to study efficient algorithms in a more realistic computational model, the streaming model. ...

October 30, 2023 · 12 min · jthulhu