gsg-prose-sh-xsmtam.txt (5380B)
1 I like Go, but only when I don't have to write it 2 3 2024-10-06 · [1]gclv.es 4 5 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6 7 I am on a quest to restore the joy I had in programming, and computing more 8 generally. Being funemployed, I have been writing a lot of just-for-fun code 9 lately. For my latest toy project, I am writing a simple regex matcher. The 10 goal is to start with [2]the didactic implementation, then graduate to [3]a 11 more robust one. 12 13 Stated preference [4]# 14 15 Programming language choice always comes up when kicking off a new personal 16 project, and my thought process is always the same: 17 18 • How is the tooling? 19 • Will I need to install hundreds of dependencies? 20 • Will the language and the runtime let me focus on the intrinsic complexity 21 of the problem? Or is there accidental complexity that steals attention 22 from it? 23 • It's been a while since I've written code. Will I have to/want to tweak my 24 Emacs for two days instead of doing the actual thing? 25 26 Almost every time, answering those questions leads me to start the project in 27 Go. Almost every time, I get side-tracked infinitely and drop the project. I 28 thought the latter was just me being weak-willed, but I am now convinced it's 29 because Go is not a good choice for me. 30 31 Papercuts [5]# 32 33 The criteria above do seem solid to me, and I think Go is a great choice given 34 those criteria. But then the following start to irk me: 35 36 1. how do I install gopls and goimports again? ^[6]1 37 2. how do I test this? Wow, I have to type so much just to get a single unit 38 test... how should I refactor this? Oh no, that was too soon, let me undo 39 that 40 3. so much repetition in the code! How should I refactor this? Oh no, that was 41 too soon, let me undo that 42 4. I don't know what it is, but I can never learn anything from reading the 43 docs 44 5. let's just hope nothing goes wrong at runtime, because I haven't the first 45 clue as to how that works 46 47 The code I was writing for fun because it was supposed to be elegant is now 48 littered with the likes of if err != nil { return nil, err } and unnecessary 49 assignments. When I come back to it to make a change, I have to read 300 lines 50 to make sense of a simple thing. And the tests don't serve as documentation. 51 52 Revealed preference [7]# 53 54 At one point in my regex matcher, when I was annoyed at having to write another 55 20-line for loop inside my function, I rm -rf'd it ^[8]2 and started over in 56 Rust. The joy! Algebraic data types! Expressiveness! Multiple forms of 57 iteration! Abstractions! 58 59 I have finally reflected on the experience and found what's missing in my 60 declared preferences above: expressiveness. I expect expressiveness of a 61 language. 62 63 Conclusion [9]# 64 65 Maybe I'm still learning, and this is [10]the hard part of learning a language. 66 After all, I haven't written Go code in anger in significant amounts. But 67 life's too short. For the last few weeks, this is what I've favored instead: 68 69 • For fun tasks: Ruby, as long as it only has to work on my machine 70 • For pragmatic tasks: Rust or Python 71 • For computation-heavy tasks: Rust or Scala 72 • For web tasks: probably TypeScript + Node. Or [11]the BCHS stack. Or, 73 better yet, nothing at all 74 75 And this has been working great! Programming is more fun, insights are more 76 pretty, cleverness is valued again. I'm like the flying dude from [12]that xkcd 77 . ^[13]3 78 79 I continue to "like" Go, and think it's a great idea, as long as it's written 80 and read [14]by others. 81 82 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 83 84 1. this is 100% my fault, but those two always disappear from my PATH by the 85 time I pick up the next project [15]↩︎ 86 87 2. pronounved: "rimraffed" [16]↩︎ 88 89 3. let's see how long until I fall into [17]this other xkcd... [18]↩︎ 90 91 Thoughts? Comments? [19]Shoot me an email! 92 93 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 94 published with [20]prose.sh 95 96 References: 97 98 [1] https://gsg.prose.sh/ 99 [2] https://www.cs.princeton.edu/courses/archive/spr09/cos333/beautiful.html 100 [3] https://swtch.com/~rsc/regexp/regexp1.html 101 [4] https://gsg.prose.sh/i-like-go#stated-preference 102 [5] https://gsg.prose.sh/i-like-go#papercuts 103 [6] https://gsg.prose.sh/i-like-go#fn:1 104 [7] https://gsg.prose.sh/i-like-go#revealed-preference 105 [8] https://gsg.prose.sh/i-like-go#fn:2 106 [9] https://gsg.prose.sh/i-like-go#conclusion 107 [10] https://www.hillelwayne.com/post/learning-a-language/ 108 [11] https://learnbchs.org/ 109 [12] https://xkcd.com/353/ 110 [13] https://gsg.prose.sh/i-like-go#fn:3 111 [14] https://theonion.com/report-98-percent-of-u-s-commuters-favor-public-trans-1819565837/ 112 [15] https://gsg.prose.sh/i-like-go#fnref:1 113 [16] https://gsg.prose.sh/i-like-go#fnref:2 114 [17] https://xkcd.com/1987/ 115 [18] https://gsg.prose.sh/i-like-go#fnref:3 116 [19] mailto:~gg/[email protected] 117 [20] https://prose.sh/