Want to Unlock Performance and Clarity? Use Strong Types

by bubblehack3ron 6/2/2024, 11:41 AMwith 3 comments

by rlupion 6/3/2024, 10:26 AM

Interesting, I haven't thought about using it in C++ before.

It's an idea that has existed for a long time in languages geared toward safety-critical systems.

E.g. Derived Types in Ada: https://fsharpforfunandprofit.com/posts/designing-with-types...

It is sometimes used in Ocaml or F# for domain-specific types: https://fsharpforfunandprofit.com/posts/discriminated-unions...

by tomtom1337on 6/2/2024, 5:57 PM

This is a very useful methodology. There's a similar blog post called "parse, don't validate" [1] which is very good.

[1] https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-va...

by lylejantzi3rdon 6/2/2024, 7:48 PM

So, every time you create a UserName, it does those checks even if it doesn't need to? That doesn't sound very performant to me.