Video summary

Writing a Programming Language - 01/01/2026

Main summary

Key takeaways

Technology

Technological focus / what the stream implements

  • The speaker revisits earlier work on error handling by catching errors as booleans, using a “question mark” operator to convert exceptions into true/false-like sentinel outcomes.
  • They identify a correctness issue when using that boolean-catch operator inside expressions that also rely on boolean short-circuiting.

Key problem explained (why short-circuiting is needed)

  • Example behavior described:

    • If accessing a missing property generates an exception, the “catch-as-boolean” operator turns that into false.
    • In an expression like:

    text value is present AND value != 0

    the right-hand side may still be evaluated even when the left side indicates the value is missing.

  • Consequence:

    • When the RHS runs despite the LHS being false, types may become incompatible (e.g., null vs int), causing failures or undesired evaluation.
  • Conclusion:

    • The language previously did not short-circuit boolean and / or expressions.
    • The speaker implements short-circuiting specifically to avoid evaluating the RHS when the LHS already determines the result.

Implementation details (language/compiler changes)

  • Operator evaluation model:

    • Most operators currently evaluate both LHS and RHS before applying the operator.
    • However, and / or require special handling.
  • New internal handling concept:

    • They implement a routine/branch conceptually like:

      • apply_boolean_operation (or a dedicated boolean-operation handler)
    • This is triggered when the operator is and or or.

  • Short-circuit semantics:

    • For and

      1. Evaluate LHS to a boolean.
      2. If LHS is false, return false immediately without evaluating RHS.
      3. If LHS is true, evaluate RHS and return it as the result.
    • For or

      1. Evaluate LHS to a boolean.
      2. If LHS is true, return true immediately without evaluating RHS.
      3. If LHS is false, evaluate RHS and return it as the result.
  • Type handling changes:

    • They adjust evaluation so the LHS is obtained as a bool value.
    • They add/adjust derived equality/typing support as needed.
    • They resolve compiler errors (e.g., issues like “type bool cannot be dereferenced”), indicating fixes were needed in how boolean values are extracted/represented.
  • Test/codebase work:

    • Fixes failing tests caused by the lack of short-circuiting.
    • Removes/updates some test assertions and compiler-exit handling logic to align with the new control flow.
    • Adds documentation/feature text: “add support for short circuiting boolean operations”.

Product/language features added

  • Short-circuiting boolean operators for the language’s binary and / or.
  • Improved correctness with error-to-boolean conversion, preventing RHS evaluation in cases where RHS evaluation would otherwise raise exceptions or produce incompatible types.

Review / guide / tutorial aspect

  • The work is presented as a development tutorial/implementation walkthrough:
    • debugging steps,
    • compiler errors,
    • locating operator handling in the codebase,
    • modifying the language runtime/compiler behavior to match expected semantics.

Main speakers / sources

  • Single speaker: the creator/implementer of the programming language being built (no external sources mentioned).

Original video