Hacker News new | ask | show | jobs
by frowaway001 4185 days ago
You can just disallow the compilation of anything where null appears, as well as plenty of other style issues.

The language gives you plenty of tools to enforce the appropriate coding style for a given project.

1 comments

Interesting! Didn't know that. But note two things:

1- In the more general case, you cannot enforce a rule to disallows clumsy/inelegant code. You cannot force proper use of the language.

2- In the Option/null case, this is an education problem. My boss is an old-school programmer with lots of experience (and I've seen him successfully solve and/or prevent real problems at work that bit every other team, so by no means I want to sound disrespectful of his experience), but he simply doesn't understand why Option is needed. He claims "defensive programming should be enough" (i.e. checking for null at every turn). He claims "academia is not good for anything", and I guess he sort of believes Scala is an academic language full of fancy but not really useful constructs. He is not completely sold on functional programming, pattern matching, etc. So I cannot simply have the language complain about nulls, because I must justify the enforcement of this rule to my boss, and he isn't convinced. (Note: this isn't limited to Option values; think of almost every feature/coding style from Scala that might sound unfamiliar to Java programmers, and it's the same problem with my boss).