I like Go, but only when I don't have to write it 2024-10-06 · [1]gclv.es ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 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 [2]the didactic implementation, then graduate to [3]a more robust one. Stated preference [4]# 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 [5]# 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: 1. how do I install gopls and goimports again? ^[6]1 2. 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 3. so much repetition in the code! How should I refactor this? Oh no, that was too soon, let me undo that 4. I don't know what it is, but I can never learn anything from reading the docs 5. 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 [7]# 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 ^[8]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 [9]# Maybe I'm still learning, and this is [10]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 [11]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 [12]that xkcd . ^[13]3 I continue to "like" Go, and think it's a great idea, as long as it's written and read [14]by others. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1. this is 100% my fault, but those two always disappear from my PATH by the time I pick up the next project [15]↩︎ 2. pronounved: "rimraffed" [16]↩︎ 3. let's see how long until I fall into [17]this other xkcd... [18]↩︎ Thoughts? Comments? [19]Shoot me an email! ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ published with [20]prose.sh References: [1] https://gsg.prose.sh/ [2] https://www.cs.princeton.edu/courses/archive/spr09/cos333/beautiful.html [3] https://swtch.com/~rsc/regexp/regexp1.html [4] https://gsg.prose.sh/i-like-go#stated-preference [5] https://gsg.prose.sh/i-like-go#papercuts [6] https://gsg.prose.sh/i-like-go#fn:1 [7] https://gsg.prose.sh/i-like-go#revealed-preference [8] https://gsg.prose.sh/i-like-go#fn:2 [9] https://gsg.prose.sh/i-like-go#conclusion [10] https://www.hillelwayne.com/post/learning-a-language/ [11] https://learnbchs.org/ [12] https://xkcd.com/353/ [13] https://gsg.prose.sh/i-like-go#fn:3 [14] https://theonion.com/report-98-percent-of-u-s-commuters-favor-public-trans-1819565837/ [15] https://gsg.prose.sh/i-like-go#fnref:1 [16] https://gsg.prose.sh/i-like-go#fnref:2 [17] https://xkcd.com/1987/ [18] https://gsg.prose.sh/i-like-go#fnref:3 [19] mailto:~gg/public-inbox@lists.sr.ht [20] https://prose.sh/