Hacker News new | ask | show | jobs
by actsasbuffoon 3800 days ago
Nils are a problem in languages like C and Java, but more powerful type systems completely eradicate the issue. You might enjoy taking a look at Crystal. It has Ruby-like syntax and a type system that makes nil-checks completely unnecessary.
1 comments

Nils are only a problem when you're dealing with unclean data. The only way to eradicate the issue is to only deal with clean data. Otherwise you have to code the system to be able to handle it, whether through the type system or in another way. A type system helps, but so does discipline. I'll trade the productivity gains of dynamic typing over a babysitter any day.

A type system is just OOP with added math. The benefits don't outweigh the hassle. I've tried Crystal. Did not like. It was the language that taught me that there's more to Ruby than nice syntax.