home

Weird, but Haskell feels easy

I’ve been working on a specific idea for some time - microdiagrams DSL. The core concept is quite straightforward: instead of having one language for all diagrams, have multiple languages for various purposes. For example, this diagram is designed to help learn piano by illustrating the relationship between different keys.

This idea had multiple prototypes. I won’t get into the details why (hey, I hope to make some money out of it someday!), but I’ve entertained the same idea for quite some time. One would say that technology doesn’t matter, but I disagree. I think that for side projects (or Magnum Opus for that), one shouldn’t use boring technology.

Even if the project fails, it is important so that the project brings joy and self-development, and so implementations were done in many various technologies: Clojure, Elixir, OCaml, Go, and Prolog. Even in the basic parts this is not a naïve design, it has a lot of moving parts because hey, I can design my own perfect system right?

I dropped Elixir due to creeping complexity. Eventually, lints didn’t highlight errors, I had no idea where messages were being passed, and I was switching back and forth between dozens of (idiomatic split) files trying to fix that one misbehaving message. At some point, I was lost in my own solution, meticulously groomed with all specs and documentation strings. Clojure was nice but on the other hand some of the constructs I worked with were way too difficult for me to work on. Many ideas are trully great but often I felt like I’m bending over my back just to get that thing that should be easy working.

Prolog deserves an extra mention. Some of the layouting I want to do depends on backtracking. And so I really, really tried hard to implement a working solution there. I always drowned on this or that feature, never making a lot of progress. A Fata Morgana of sorts, promising rest and wellness but being a dry desert in the end.

OCaml was an interesting trip, because I tried to make specific constraints on events that would flow across the system. Spent three weeks trying to implement it, but all approaches felt hackish or too verbose. Probably I could get there with enough experience, but at some point, I was just irritated enough and moved on.

Then I looked at Go. Go work went fine, but it’s Go. I mean, I don’t have anything against Go, but it’s not very exciting language to work on. It also pushed me into the spiral with Ichiban Prolog and ideas of how can I integrate CGo without a lot of hassle (which started my romance with Zig). At some point, I spiralled out and forgot about the original project.

Then, some bad things happened in my life, and the project faded to the background.

As of the time writing this article, I’m looking at Haskell’s codebase. You know, that language everybody makes fun of that it makes fun of you if you try to touch it without a PhD in mathematics and at least a certificate of winning mid-school maths olympics. Out of irritation and desperation, I asked Google’s Gemini for something that’s good on DSL, has stable libraries, performant code, and then has some logic capabilities. “Have you ever considered Haskell?” - it asked, and I chuckled at the idea. Yeah, sure, because I’m not masochistic enough. I tried Haskell some time ago, but figured it’s too “fiddly” with all those extensions and stuff. It was pre-OCaml time, though. Now I know enough about Monads and have reasonable OCaml experience, so I thought- hey, why not give it a go?

As of the time of writing this article, I’m looking at the Haskell’s codebase, which has reached a point no other language has ever achieved before.

…in 3 days…

My mind is blown. It is such a pleasant experience that I find it super hard to actually detach from the work. I think “now I do this” and I do “this” in the rain of colorful error messages as I power through. Then I think “ok, now time to do that” and again I succeed.

One would say it’s thanks to types, but I’m no stranger to Rust and ilk, it’s not the same. Usually there are some annoyances, sharp edges. I think I’m losing my sight, because I can’t see them. All things I don’t like seem to be addressed. It’s not a completely smooth ride, but at least I don’t expect it to; my mind still bends around using Applicatives to chain invocations together or trying to guess whether I shouldn’t be implementing a new Monad or something, but the fact is that I move forward all the time.

Technology we use is important. It either clicks or not, it either pushes us forward or drags us back. I can bet PHP is not a hellish language I remember from over two decades ago, but I still remember how I struggled with it trying to get meet some business demands. I don’t like to struggle with the language; I like when it sits by the side and smiles with that “I got ya bro’!” look in its eyes.

For whatever reason, I feel Haskell is doing exactly that.

How long will this continue? I don’t know, but I still wonder how come I found it easiest to work in the language known as one of the hardest ones.

Przemysław Alexander Kamiński
vel xlii vel exlee

gh | li | rss

Powered by hugo and hugo-theme-nostyleplease.