Hacker News new | past | comments | ask | show | jobs | submit login

Just create a type in any language and you can do it there too



Well, yes and no. You could in Java create a class called Score with get() and set() methods, set() taking another class called a Point as its input, and throw an exception if the value of Point is outside the range, but the overhead of that would be huge both at development and at runtime. With expressive types in the language, there's minimal extra effort in development (in many cases much less since now the compiler can do things that otherwise you'd need unit tests for) and none at all at runtime.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: