Comment

Comment by irrelative

> Well, CoffeeScript/JavaScript doesn't have a static type system. And to add one would be...hard.

Indeed it would be. That said, CoffeeScript is a compiler of sorts.

> And we'd like to do it in a more elegant way than constantly writing "if(argument === ...) then ... else ..."

This doesn't really seem to solve that problem. It just throws consistent errors if the types don't match. Your code would likely throw its own error if you didn't check the type manually. In my experience, native js errors are as easy or easier to track down that throwing errors yourself.

> Contracts also allow us to check invariants that might not result in a run-time exception but could lead to the code just being subtly wrong.

Ah, ok. That makes more sense. They're like python decorators, only single purpose.

parent irrelative 15 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton