In this spooky episode, the hosts discuss John Gregory's seven deadly sins of Go, including the importance of contextual comments, the concept of pride as a sin, building a flexible JSON schema parsing library, the use of channels for concurrency, balancing mindset and error handling, avoiding over engineering, unpopular opinions in horror films, and the opinion on Go as a language for software engineering and design.
Properly documenting code and adding relevant context is essential for future maintainability and understanding.
Writing opinionated libraries that do not provide flexibility or options can limit the reusability and accessibility of the code.
Overuse of frameworks and dependencies can introduce unnecessary complexity, increase maintenance burden, and potentially introduce security vulnerabilities.
Deep dives
Sloth: Lazy coding and lack of context in Go
Sloth in Go refers to lazy coding practices, such as inadequate commenting or writing comments that do not provide sufficient context. It also includes the failure to add context to errors, which can make it difficult to understand the cause of a problem. Properly documenting code and adding relevant context is essential for future maintainability and understanding.
Pride: Assuming what's best in Go
Pride in Go involves assuming that you know what's best for others when writing libraries or frameworks. It is the tendency to make decisions and assumptions about how people will use the code without considering their individual needs. Writing opinionated libraries that do not provide flexibility or options can limit the reusability and accessibility of the code.
Lust: Overindulgence in frameworks and dependencies
Lust in Go refers to the overindulgence in using frameworks and dependencies without careful consideration. It is the tendency to reach for the latest framework or pull in numerous dependencies without assessing if they are truly necessary. Overuse of frameworks and dependencies can introduce unnecessary complexity, increase maintenance burden, and potentially introduce security vulnerabilities.
Wrath: Misuse of panic and error handling in Go
Wrath in Go involves the misuse of panic and error handling mechanisms. It is the improper use of panic, such as using it to handle routine errors or to recover from issues that should be handled with proper error handling. It also encompasses the misuse of error handling by ignoring or not properly handling errors, which can lead to unexpected behavior and make debugging more challenging.
Avoiding Preemptive Over-Engineering
Preemptive over-engineering is seen as a deadly sin in software development. It involves investing time and effort into building complex and elaborate systems to handle future features or requirements that may never materialize. The podcast emphasizes the importance of focusing on the present requirements and designing software that meets current needs without getting too caught up in hypothetical future scenarios. While some degree of future-proofing is necessary, it is essential to strike a balance and not over-complicate the code base by catering to every possible unknown unknown.
The Relevance of Commit Messages
The podcast challenges the notion that commit messages hold significant value and are extensively relied upon in software development. The consensus is that commit messages are rarely read or used when investigating code. Instead, the focus is on documentation, issue trackers, and other sources of information. Commit messages are perceived as a last resort when seeking specific details about a code change. The discussion highlights the need to prioritize other means of documenting and communicating code changes, while acknowledging that committing meaningful and well-structured messages can have its merits in certain situations.
John Gregory’s GopherCon talk “7 Deadly Gopher Sins” is the ostensible basis of this spooky Go Time episode, but with Mat Ryer at the helm… the only thing to expect is the unexpected. And failed jokes. Expect lots of failed jokes.
Changelog++ members support our work, get closer to the metal, and make the ads disappear. Join today!
Sponsors:
Fastly – Our bandwidth partner. Fastly powers fast, secure, and scalable digital experiences. Move beyond your content delivery network to their powerful edge cloud platform. Learn more at fastly.com
Fly.io – The home of Changelog.com — Deploy your apps and databases close to your users. In minutes you can run your Ruby, Go, Node, Deno, Python, or Elixir app (and databases!) all over the world. No ops required. Learn more at fly.io/changelog and check out the speedrun in their docs.
Typesense – Lightning fast, globally distributed Search-as-a-Service that runs in memory. You literally can’t get any faster!