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

I'm learning Scala at my new job (previously worked in Ruby, Python, and long ago, Java and enjoy learning about functional programming). It's a fine language with a lot of great things about it...that get tossed the second you touch Java. It's wonderful to not have null. Except that you do anyway! My biggest complaint is that it is so multi-paradigm that different systems in our codebase have completely different styles.



> It's wonderful to not have null. Except that you do anyway!

If you hit a NPE in Scala, you're doing something objectively wrong. You should be wrapping any calls to Java libraries that may return null with Option().


I agree that null should generally be banned from Scala code, but your statement is a little too strong. I use Spark / Scala for big data applications and Option() is slower than null. From the Databricks Scala style guide: "For performance sensitive code, prefer null over Option, in order to avoid virtual method calls and boxing."


You should try Haskell. It's like doing Scala, but without the Java.


You might also want to check out Kotlin. It's basically what everyone wished Java 8 had been, but wasn't because a) backwards compatibility, and b) difference of opinion (looking at you Optional). We have a set of coding conventions we use for our Java code that includes things like using Optional.empty() instead of null and declaring all method parameters (and as many locals and properties as we can get away with) as final. We've found that using Kotlin allows us to write equivalent code in a far more succinct fashion because all those conventions we follow are the default state in Kotlin, and it's deviating from those conventions that requires extra syntax in Kotlin.




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

Search: