Show HN: I implemented generics in my programming language

Dev says Axe has generics; commenters cry “just fancy ifs” and shout “Specifics”

TLDR: Axe’s creator unveiled “generics” driven by compile-time type checks. Hacker News erupted, saying it’s just type-based if‑statements, not real generics; some even suggested renaming to avoid confusion with Haxe.

A Show HN launch promised “generics” in a new language called Axe—functions that change behavior based on the input type at compile time using lines like when T is float or when T is i32. The demo included type-aware utilities like list_contains and add_or_concat, all resolved by the compiler. Then the comments lit up like a code review bonfire. The loudest camp? “This is just a big type-based switch,” accusing Axe of dressing up if-statements as generics. One commenter dropped the mic with “You implemented Specifics,” turning it into an instant meme. Another schooled the thread: this is ad-hoc polymorphism (behavior varies by type), not parametric polymorphism (true generics that don’t know or care about your types). Translation for non-coders: real generics should be neutral; Axe’s version keeps a list of who’s allowed in. Critics said list_contains should just compare items with a simple “equals,” no type-specific branches needed. There was even branding drama: someone warned Axe looks too much like Haxe. Still, a few voices liked the compile-time clarity—no sneaky runtime checks—and joked about “quackable” traits and duck-typing: if it quacks, it’s a duck. Verdict: the internet brought popcorn and turned this into a semantics showdown.

Key Points

  • Axe uses type parameters with when/is clauses to specialize generic function behavior at compile time.
  • Examples show branching for i32 and float types, returning type T while adapting computation to the concrete type.
  • Generic when/is clauses can pair constraints across multiple type parameters (e.g., list type and element type).
  • The cast operator performs safe conversions only after type relationships are established by when conditions.
  • Generic functions can call other generics, with type parameters inferred automatically from callsite arguments.

Hottest takes

“This are merely instanceof switches” — p0w3n3d
“You implemented Specifics” — mrkeen
“If your function changes it’s behaviour based on the type, then it’s not generic” — Philip-J-Fry
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.