Dark Magic in Python 3.10's Pattern Matching: Exploiting `__subclasshook__`

2025-08-22

This article explores the unexpected capabilities arising from the combination of Python 3.10's pattern matching and the `__subclasshook__` method of Abstract Base Classes (ABCs). By cleverly using `__subclasshook__`, the author demonstrates 'hijacking' pattern matching, allowing custom definition of which types match and even matching based on object attributes, not just types. While showcasing powerful functionalities like creating custom matchers, the author strongly cautions against using this technique in production code due to its unpredictable and potentially harmful nature.

Read more
Development Abstract Base Classes

The Surprisingly Profound Influence of 'Dead' Programming Languages

2025-07-16

This article explores the surprisingly significant impact of historically influential programming languages that are no longer widely used, such as COBOL, ALGOL, APL, and BASIC. By examining their backgrounds, contributions, and reasons for decline, the author reveals their lasting influence on modern languages. Examples include COBOL's record data structures, ALGOL's lexical scoping and structured programming, and APL's array processing. The article highlights the importance of studying programming language history and the often-overlooked contributions of languages that never achieved mainstream popularity.

Read more

The Misunderstood Origins of OOP: Setting the Record Straight

2025-05-10

This article debunks the common misconception that Alan Kay invented both object-oriented programming (OOP) and the concept of objects. In reality, the Simula language was a significant precursor to OOP, a fact acknowledged by the Smalltalk team. While Kay coined the term "objects," he later regretted it, emphasizing message passing as the core idea of OOP. The article further explores Smalltalk's unique contributions to OOP, particularly its design principle of treating everything as an object and its innovative message-handling mechanism. The author argues that OOP's evolution wasn't a singular event but a confluence of ideas and needs, with different developers understanding and applying OOP differently in various contexts.

Read more
Development

The Curious History of JavaScript Comments: Why `<!--` and `-->` Work

2025-03-12

This article unravels the curious history behind the use of `` as comment characters in JavaScript. Initially, to ensure compatibility with older browsers, developers would wrap their JavaScript code within HTML comments inside `` tags. Surprisingly, modern browsers still support this syntax due to historical browser compatibility burdens and the standardization committee's commitment to 'not breaking the web'. The article explains how this syntax works and why `-->` must appear at the beginning of a line.

Read more
Development

Applying the Hierarchy of Controls to Software Engineering

2025-03-08

A mechanical engineer introduced the author to the Hierarchy of Controls (HoC), a crucial concept in workplace safety. The author applies HoC to software engineering, analyzing a production database incident caused by a wrong query ten years ago. The article explores applying elimination, substitution, engineering controls, administrative controls, and personal protective equipment (PPE) to mitigate risks in software development. Each level's advantages, disadvantages, and limitations are discussed – for example, overly strict access policies might slow down problem resolution. The author emphasizes holistically considering the impact of controls on system safety, preventing the introduction of new risks.

Read more
Development