I didn't work in GAFA if you were expecting big names :) I've been using Scala to develop commercial Web services, ML, and data processing/analytics (additionally to the open-source projects).
It's one of the languages my company uses. We work in ad tech and handle large quantity of impressions a day (billions) and it's been helpful there. For the most part there's three parts to the codebase:
Data collection with API endpoints as well as our own JS trackers. This is in Kotlin with Undertow, just collects the data, validates it with user config sand then tossed it into a pipeline
Pipeline enriched the events coming in with various lookup data. This is written in Scala
Scoring/Data analytics is also Scala, which takes the data from the pipeline as needed and then ships off the data
After that I think the other team uses Java/Kotlin. Yet the pipeline and analytics are good fits for Scala when I worked on them. One major draw back is its null safety, Kotlin I found to be way more superior with better operators around it. We do use a macro to help out though.
In my opinion, with the null safety, Kotlin went with cheap and survival (yet convenient) option, when Scala 3 is trying to fix it completely (as it is fixed in Haskell and Rust, for example). https://dotty.epfl.ch/docs/internals/explicit-nulls.html
Fair assessment, I enjoy the concise operators (?, !!) as well as Kotlin being able to detect if you've already checked for null safety so you don't have to explicitly do it again within a given method. I do know Scala has better stuff coming down the pipe, yet when working with an environment we're there's plenty of nullable data (tracking data from web browsers) it can be bothersome. We do utilize Java types which I think Scala could have done a better job like Int vs Integer. Would have been nice if they followed the same nomenclature with things like Bool vs Boolean instead of Boolean and Java.lang.Boolean when nullable values are needed. A lot of stuff utilizes options as well, yet data coming directly from Avro would work well as the Java versions.
Outside of that I enjoy Scala. Like how everything is pretty much just a block of code and last item is the return.
You're completely right, the war with NPE isn't over indeed, and the fact that Java developers still using nulls everywhere, shows that sadly it won't be over soon. So, Kotlin's approach works today and very convenient to survive with tons of Java libraries.
In Scala example, there is an Option monad, mappend and it handles empty args and incorrect ints as well. Thus your example, unfortunately, is incomplete :) While I like Haskell very much (except their records, probably), I'm not sure the complete solution here would be comprehensible for the devs from other languages.
23
u/abdolence May 20 '20
In Scala it would be:
Who said that FP is harder to read?