joshar.notes

Types as code

If you have ever read a typescript error you may have thought "well this was a mistake". Typescript is the most maintstream language with an advanced type system however the types tend to get unwieldy real fast

this tweet did rounds a while back

ceiling is being raised. cursor's copilot helped us write "superhuman code" for a critical feature. We can read this code, but VERY few engineers out there could write it from scratch.

Took lots of convincing too. "come on, this must be possible, try harder". and obviously- done in parts

(can't add a screenshot since that is a bearblog pro feature)

After a certain point the types are just a separate language you are working with.

What if types were just code?

Most developers are able to achieve reasonably complex things with imperative code. However, they won't be able to do that the same with types. For example ask a person to check whether a str starts with 'C' and they might need to Google the syntax for that type, but writing that in imperative code is just str.startsWith('C') or something of that variant in most languages