{
  "$type": "site.standard.document",
  "canonicalUrl": "https://unnecessary.tech/posts/golang",
  "path": "/posts/golang",
  "publishedAt": "2019-07-01T15:00:51.000Z",
  "site": "at://did:plc:jx54v4rmscfwzit7fmgz24ba/site.standard.publication/3mnrsqmzz3w2e",
  "tags": [
    "thoughts",
    "programming"
  ],
  "textContent": "When I was younger I would focus on a program for all day and into the\nevening. I would go to sleep thinking about a program, and I would wake up and\njump right back into that program. During that time I kept a lot of the state\nof my program in my head, and I could write some very clever code. I moved\nthrough from primarily using C and thinking a lot about memory allocation to\nJava where I thought a lot about how my classes interacted, and eventually\nprogrammed primarily in python where I was able to rapidly create terse\nprograms, however recently I have been experiencing a few issues in my\nprogramming productivity.\n\nI am getting older and I have a lot of meetings, and that means that I often\nam reading the programs I wrote to figure out where I was going. Reading your\nprograms can sometimes be a humbling experience, and I saw the deficiencies\nof some of my practices. I do not comment enough; I am inconsistent in how I\nchoose variable names; And, I sometimes write things that are hard to follow.\nThis reminded me of a famous Brian Kernighan quote:\n\n> Everyone knows that debugging is twice as hard as writing a program in the\n> first place. So if you're as clever as you can be when you write it, how will\n> you ever debug it? (Kernighan and Plauger, 1978)\n\nAnother thing I noticed is that a lot of the mistakes I made could quickly be\ncaught by type checking. I started using mypy on some\nnew projects, but I also decided to start investigating the Go programming\nlanguage which has become fairly popular. Go is designed\nto be a simple readable language which compiles to native code, includes\ngarbage collection, and handles concurrency well. It is relatively lean in\nterms of language features by choice as initially all three of the language\ncreators had to agree on every addition to the language. This makes it easy to\nlearn, and means there will be hopefully few dark corners likely to confuse\nless experienced developers as they review other people's code. \n\nI have always enjoyed simplicity, and I like programming in Go. I find that I\nam less error prone as a result of the checking that automatically happens\nevery time I save my program (I have configured vim to do this). There are\nthree main features I want to highlight as those I particularly enjoy:\n\n1. Duck typing - A receiver automatically implements an interface if it has\n    all the methods of that interface. This will be familiar for anyone coming\n    from a python background.\n2. Garbage collection - Managing memory is difficult and error prone. Best\n    not to think about it unless you have to.\n3. Gofmt - Formatting code is best left to a program, and Go has that\n    program! This makes it a lot easier to collaborate using Go.\n\nI think Go is well worth the time to learn, and an enjoyable language to use.",
  "title": "The Go Language"
}