The Bike Shed

432: The Semantics and Meaning of Nil


Listen Later

The term ‘nil’ refers to the absence of value, but we often imbue it with much more meaning than just that. Today, hosts Joël and Stephanie discuss the various ways we tend to project extra semantics onto nil and the implications of this before unpacking potential alternatives and trade-offs.

Joël and Stephanie highlight some of the key ways programmers project additional meaning onto nil (and why), like when it’s used to create a guest session, and how this can lead to bugs, confusion, and poor user experiences. They discuss solutions to this problem, like introducing objects for improved readability, before taking a closer look at the implications of excessive guard clauses in code.

Our hosts also explore the three-state Boolean problem, illustrating the pitfalls of using nullable Booleans, and why you should use default values in your database. Joël then shares insights from the Elm community and how it encourages rigorous checks and structured data modeling to manage nil values effectively.

They advocate for using nil only to represent truly optional data, cautioning against overloading nil with additional meanings that can compromise code clarity and reliability. Joël also shares a fun example of modeling a card deck, explaining why you might be tempted to add extra semantics onto nil, and why the joker always inevitably ends up causing chaos!


Key Points From This Episode
  • The project Joël is working on and why he’s concerned about bugs and readability.
  • Potential solutions for a confusing constant definition in a nested module.
  • A client work update from Stephanie: cleaning up code and removing dead dependencies.
  • How she used Figjam to discover dependencies and navigate her work.
  • Today’s topic: how programmers project extra semantics onto nil.
  • What makes nil really tricky to use, like forcing you to go down a default path.
  • How nil sweeps the cases you don’t want to think too hard about under the rug.
  • Extra semantics that accompany nil (that you might not know about) like a guest session.
  • Examples of how these semantics mean different things in different contexts.
  • How these can lead to bugs, hard-to-find knowledge, confusion, and poor user experiences.
  • Introducing objects to replace extra nil semantics, improve readability, and other solutions.
  • Some of the reasons why programmers tend to project extra semantics onto nil.
  • How to notice that nil has additional meanings, and when to model it differently.
  • The implications of excessive guard clauses in code.
  • An overview of the three-state Boolean problem with nullable Booleans.
  • Connecting with the Elm community: how it can help you conduct more rigorous checks.
  • Some of the good reasons to have nil as a value in your database.
  • The benefits of using nil only to represent truly optional data.
  • Links Mentioned in Today’s Episode
    • Figjam
    • Miro
    • 'Working Iteratively' blog post
    • Mermaid.js
    • Draw.io
    • Check your return values (web)
    • Check your return values (API)
    • Primitive obsession
    • 'Avoid the Three-state Boolean Problem'
    • Elm Community
    • 'The Shape of Data': Modeling a deck of cards
    • The Bike Shed
    • Joël Quenneville on LinkedIn
    • Support The Bike Shed

      ...more
      View all episodesView all episodes
      Download on the App Store

      The Bike ShedBy thoughtbot

      • 4.9
      • 4.9
      • 4.9
      • 4.9
      • 4.9

      4.9

      121 ratings


      More shows like The Bike Shed

      View all
      Tentative by thoughtbot

      Tentative

      9 Listeners

      Software Engineering Radio by se-radio@computer.org

      Software Engineering Radio

      273 Listeners

      The Changelog: Software Development, Open Source by Changelog Media

      The Changelog: Software Development, Open Source

      291 Listeners

      Giant Robots Smashing Into Other Giant Robots by thoughtbot

      Giant Robots Smashing Into Other Giant Robots

      88 Listeners

      Build Phase by thoughtbot

      Build Phase

      44 Listeners

      Software Engineering Daily by Software Engineering Daily

      Software Engineering Daily

      625 Listeners

      Soft Skills Engineering by Jamison Dance and Dave Smith

      Soft Skills Engineering

      284 Listeners

      Syntax - Tasty Web Development Treats by Wes Bos & Scott Tolinski - Full Stack JavaScript Web Developers

      Syntax - Tasty Web Development Treats

      986 Listeners

      REWORK by 37signals

      REWORK

      210 Listeners

      Crossroads by thoughtbot

      Crossroads

      2 Listeners

      CoRecursive: Coding Stories by Adam Gordon Bell - Software Developer

      CoRecursive: Coding Stories

      188 Listeners

      Remote Ruby by Chris Oliver, Andrew Mason

      Remote Ruby

      35 Listeners

      Practical AI by Practical AI LLC

      Practical AI

      209 Listeners

      Reboot by thoughtbot

      Reboot

      12 Listeners

      Code with Jason by Jason Swett

      Code with Jason

      14 Listeners

      The Stack Overflow Podcast by The Stack Overflow Podcast

      The Stack Overflow Podcast

      62 Listeners

      Signals and Threads by Jane Street

      Signals and Threads

      72 Listeners

      Code and the Coding Coders who Code it by Drew Bragg

      Code and the Coding Coders who Code it

      6 Listeners

      IndieRails by Jess Brown & Jeremy Smith

      IndieRails

      6 Listeners

      The Pragmatic Engineer by Gergely Orosz

      The Pragmatic Engineer

      64 Listeners