Comment on Strings do too many things

<- View Parent
Pipoca@lemmy.world ⁨4⁩ ⁨months⁩ ago

Symbols display with friendly string-y names in a number of languages. Clojure, for example, has a symbol type.

And a number of languages display friendly strings for enemy things - Scala, Haskell, and Rust spring to mind.

The problem with strings over enums with a nice debugging display is that the string type is too wide. Strings don’t tell you what values are valid, strings don’t catch typos at compile time, and they’re murder when refactoring.

The other problem the article mentions is strings over a proper struct/adt/class hierarchy is that strings don’t really have any structure to them. Concatenation strings is brittle compared to building up an AST then rendering it at the end.

source
Sort:hotnewtop