I am on a quest to restore the joy I had in programming, and computing more generally. Being funemployed, I have been writing a lot of just-for-fun code lately. For my latest toy project, I am writing a simple regex matcher. The goal is to start with the didactic implementation, then graduate to a more robust one.
Stated preference #
Programming language choice always comes up when kicking off a new personal project, and my thought process is always the same:
- How is the tooling?
- Will I need to install hundreds of dependencies?
- Will the language and the runtime let me focus on the intrinsic complexity of the problem? Or is there accidental complexity that steals attention from it?
- It's been a while since I've written code. Will I have to/want to tweak my Emacs for two days instead of doing the actual thing?
Almost every time, answering those questions leads me to start the project in Go. Almost every time, I get side-tracked infinitely and drop the project. I thought the latter was just me being weak-willed, but I am now convinced it's because Go is not a good choice for me.
Papercuts #
The criteria above do seem solid to me, and I think Go is a great choice given those criteria. But then the following start to irk me:
- how do I install
gopls
andgoimports
again? 1 - how do I test this? Wow, I have to type so much just to get a single unit test... how should I refactor this? Oh no, that was too soon, let me undo that
- so much repetition in the code! How should I refactor this? Oh no, that was too soon, let me undo that
- I don't know what it is, but I can never learn anything from reading the docs
- let's just hope nothing goes wrong at runtime, because I haven't the first clue as to how that works
The code I was writing for fun because it was supposed to be elegant is now littered with the likes of if err != nil { return nil, err }
and unnecessary assignments. When I come back to it to make a change, I have to read 300 lines to make sense of a simple thing. And the tests don't serve as documentation.
Revealed preference #
At one point in my regex matcher, when I was annoyed at having to write another 20-line for
loop inside my function, I rm -rf
'd it 2 and started over in Rust. The joy! Algebraic data types! Expressiveness! Multiple forms of iteration! Abstractions!
I have finally reflected on the experience and found what's missing in my declared preferences above: expressiveness. I expect expressiveness of a language.
Conclusion #
Maybe I'm still learning, and this is the hard part of learning a language. After all, I haven't written Go code in anger in significant amounts. But life's too short. For the last few weeks, this is what I've favored instead:
- For fun tasks: Ruby, as long as it only has to work on my machine
- For pragmatic tasks: Rust or Python
- For computation-heavy tasks: Rust or Scala
- For web tasks: probably TypeScript + Node. Or the BCHS stack. Or, better yet, nothing at all
And this has been working great! Programming is more fun, insights are more pretty, cleverness is valued again. I'm like the flying dude from that xkcd. 3
I continue to "like" Go, and think it's a great idea, as long as it's written and read by others.
-
this is 100% my fault, but those two always disappear from my
PATH
by the time I pick up the next project ↩︎ -
pronounved: "rimraffed" ↩︎
-
let's see how long until I fall into this other xkcd... ↩︎