logo

drewdevault.com

[mirror] blog and personal website of Drew DeVault git clone https://hacktivis.me/git/mirror/drewdevault.com.git

Go-1.11.md (4730B)


  1. ---
  2. date: 2018-10-08
  3. layout: post
  4. title: Go 1.11 got me to stop ignoring Go
  5. tags: ["go"]
  6. ---
  7. I took a few looks at Go over the years, starting who knows when. My first
  8. serious attempt to sit down and learn some damn Go was in 2014, when I set a new
  9. personal best at almost 200 lines of code before I got sick of it. I kept
  10. returning to Go because I could see how much potential it had, but every time I
  11. was turned off for the same reason: `GOPATH`.
  12. You see, `GOPATH` crossed a line. Go is opinionated, which is fine, but with
  13. `GOPATH` its opinions extended beyond my Go work and into the rest of my system.
  14. As a naive new Go user, I was prepared to accept their opinions on faith - but
  15. only within their domain. I already have opinions about how to use my computer.
  16. I knew Go was cool, but it could be the second coming of Christ, and so long as
  17. it was annoying to use and didn't integrate with my workflow, I (rightfully)
  18. wouldn't care.
  19. Thankfully Go 1.11 solves this problem, and solves it delightfully well. I can
  20. now keep Go's influence contained to the Go projects I work with, and in that
  21. environment I'm much more forgiving of anything it wants to do. And when
  22. considered in the vacuum of Go, what it wants to do is really compelling. Go
  23. modules are *great*, and probably the single best module system I've used in any
  24. programming language. Go 1.11 took my biggest complaint and turned it into one
  25. of my biggest compliments. Now that the One Big Problem is gone, I've really
  26. started to appreciate Go. Let me tell you about it.
  27. The most important feature of Go is its simplicity. The language is small and
  28. it grows a small number of features in each release, which rarely touch the
  29. language itself. Some people see this as stagnation, but I see it as stability
  30. and I know that very little Go code in the wild, no matter how old, is going to
  31. be unidiomatic or fail to compile. Even setting aside stability, the
  32. conservative design of the language makes Go code in the wild remarkably
  33. consistent. Almost all third-party Go libraries are high quality stuff. Gofmt
  34. helps with this as well[^1]. The limitations of the language and the way the
  35. stdlib gently nudges you into good patterns make it easy to write good Go code.
  36. Most of the "bad" Go libraries I've found are trying to work around Go's
  37. limitations instead of embracing them.
  38. [^1]: I have *minor* gripes with gofmt, but the benefits make up for it beautifully. On the other hand, I have *major* gripes with PEP-8, and if you ever see me using it I want you to shoot me in the face.
  39. There's more. The concurrency model is superb. It should come as no surprise
  40. that a language built by the alumni of Plan 9 would earn high marks in this
  41. regard, and consequently you can scale your Go program up to be as concurrent as
  42. you want without even thinking about it. The standard library is also excellent -
  43. designed consistently and designed well, and I can count on one hand (or even
  44. one finger) the number of stdlib modules I've encountered that feel crusty. The
  45. type system is great, too. It's the perfect balance of complexity and simplicity
  46. that often effortlessly grants these traits to the abstractions you make with
  47. it.
  48. I'm not even slightly bothered by the lack of generics - years as a C programmer
  49. taught me not to need them, and I think most of the cases where they're useful
  50. are to serve designs which are too complicated to use anyway. I do have some
  51. complaints, though. The concurrency model is great, but a bit too magical and
  52. implicit. Error handling is annoying, especially because finding the origin of
  53. the error is unforgivably difficult, but I don't know how to improve it. The log
  54. module leaves a lot to be desired and can't be changed because of legacy
  55. support. `interface{}` is annoying when you have to deal with it, like when
  56. dealing with JSON you can't unmarshall into a struct.
  57. My hope for the future of Go is that it will continue to embrace simplicity in
  58. the face of cries for complexity. I consider Go modules a runaway success
  59. compared to dep, and I hope to see this story repeated[^2] before hastily adding
  60. generics, better error handling, etc. Go doesn't need to compete with anyone
  61. like Rust, and trying to will probably ruin what makes Go great. My one request
  62. of the Go team: don't make changes in Go 2.0 which make the APIs of existing
  63. libraries unidiomatic.
  64. [^2]: Though hopefully with less drama.
  65. Though I am growing very fond of it, by no means am I turning into a Go zealot.
  66. I still use C, Python, and more all the time and have no intention of stopping.
  67. A programming language which tries to fill all niches is a failed programming
  68. language. But, to those who were once like me: Go is good now! In fact, it's
  69. great! Try it!