Episode

Writing a shell in Go

Podcast
Go Time: Golang, Software Engineering
Published
Nov 6, 2024
Duration seconds
3922
Processing state
processed
Canonical source
https://changelog.com/gotime/336
Audio
https://op3.dev/e/https://cdn.changelog.com/uploads/gotime/336/go-time-336.mp3
JSON
/v1/public/podcasts/go-time-golang-software-engineering/episodes/writing-a-shell-in-go
Markdown
/podcast/go-time-golang-software-engineering/writing-a-shell-in-go.md

Actions

  • POST https://stenobird.com/v1/public/podcasts/go-time-golang-software-engineering/episodes/writing-a-shell-in-go/transcription-requests
    Idempotently request low-priority transcript generation for this episode.
  • GET https://stenobird.com/podcast/go-time-golang-software-engineering/writing-a-shell-in-go.md
    Read the agent-friendly Markdown representation of this episode resource.

Summary

An exploration of the technical design and implementation of Elvish, a programmable shell written in Go. The discussion covers the trade-offs between traditional shell commands and a language-centric approach to command execution.

Topics

  • Go programming
  • Shell development
  • Elvish shell
  • Systems programming
  • Software architecture
  • Linux kernel
  • Automation
  • Programming language design

Highlights

  • Main idea: Elvish treats the shell more like a programming language than a simple command executor, using namespaces to separate built-ins from system utilities
  • Practical takeaway: Using programmable loops and built-in functions can improve the portability of scripts across different operating systems
  • Failure mode: Relying on LLMs for destructive file operations carries high risk, even if the code is syntactically correct
  • Technical insight: High test coverage is a critical safety net when using AI-generated code to ensure existing behaviors remain intact
  • Design philosophy: Moving away from complex flags (like mkdir -p) toward native language constructs like for-loops simplifies the shell's core logic

Chapters

  1. 1:00 The Reality of Cloud Abstractions: A discussion on why understanding the underlying Linux kernel features and VM management is more useful than treating the cloud as a black box.
  2. 6:10 Developing Elvish: The journey of moving from Zsh and Fish to developing a custom shell and eventually using it as a daily driver.
  3. 11:05 The Shell as a Runtime: Comparing the shell environment to a browser, where functionality is delegated to various integrated applications and tools.
  4. 21:00 Go for Systems Programming: Reflecting on Go's evolution from a systems language to its current niche in modern infrastructure and tooling.
  5. 30:50 Built-in File Management: Exploring Elvish's integrated file manager and UI features inspired by tools like Ranger.
  6. 40:10 Functional Programming in Go: The challenges of implementing function bindings and handling the differences between Go's standard library and Elvish's runtime.
  7. 54:55 Testing and LLMs: The intersection of high code coverage and the use of Large Language Models for generating tests and refactoring code.