from Hacker News

Ask HN: How to keep Scala codebase idiomatic?

by bekantan on 7/10/21, 10:08 AM with 1 comments

Clever people often get seduced by the expressive power of the language and start writing Haskell in Scala.

Well said in Effective Scala [1]: "Above all, program in Scala. You are not writing Java, nor Haskell, nor Python; a Scala program is unlike one written in any of these. In order to use the language effectively, you must phrase your problems in its terms. There’s no use coercing a Java program into Scala, for it will be inferior in most ways to its original."

While pure FP code can be a good fit for some projects, it makes hiring much harder. IMO, it is never going to be key component of project's success, but can be a significant contributor to its failure.

Good examples of what I consider idiomatic Scala are projects from Odersky, Haoyi and Twitter.

Most of closed-source projects I've seen are either Java or Haskell projects in disguise.

What is you experience with Scala projects in this regard? Did you choose idiomatic mix of FP and OOP or some other approach?

[1] https://twitter.github.io/effectivescala/

  • by jim-jim-jim on 7/10/21, 11:44 AM

    I'm sorry, but I disagree. The codebases I work on are basically Haskell in disguise and that's how I like it. It has absolutely nothing to do with being clever; on the contrary, going all in on FP makes it much harder for us to get away with the dumb mistakes we all inevitably make from time to time. That stability is totally worth learning a few extra concepts for.

    > it makes hiring much harder

    I don't think this is a real problem. It's disappointing that so much of the industry refuses to train people up on stuff. Hire friendly and open-minded people, sit next to them, and it'll work itself out. I'm a dumb guy who was taken on with no Scala experience and our senior devs just walked me through it. If the modules are written well, you can usually get started working on small improvements without touching monad transformers or whatever.