finds.dev← search

// the find

databricks/scala-style-guide

★ 2,802 · updated Apr 2024

Databricks Scala Coding Style Guide

Databricks' internal Scala style guide, open-sourced and battle-tested on Spark and Delta Lake. It's a pragmatic, opinionated document aimed at teams writing Scala that needs to be readable by many engineers over years, not just the original author. Not an academic style reference — it reflects the scars of a real large-scale Scala codebase.

The concurrency section is unusually good: it clearly distinguishes ConcurrentHashMap vs synchronized collections vs atomic variables, explains when each applies, and catches the subtle 'don't let iterators escape the protected area' bug that bites most people once. The rationale for banning call-by-name parameters is concrete — callers can't tell if an expression will execute zero, one, or multiple times, which matters when it has side effects. The Java interoperability section is something most style guides skip entirely but is essential for Spark-style libraries. The pattern matching advice to match on type rather than destructuring fields is a real maintainability win that most teams learn the hard way.

Last meaningful update was 2022 (the monadic chaining section); the concurrency advice pre-dates ZIO, Cats Effect, and fs2 becoming mainstream — teams doing async Scala will find this section inadequate or even counterproductive. The performance section recommends while loops over map/foreach and Java collections over Scala ones, which made sense for Spark's hot paths in 2015 but reads as premature pessimism for general Scala code today where the JIT handles most of it. No tooling section at all — no mention of scalafmt or scalafix, so 'follow this guide' still requires manual enforcement. The repo is essentially a single Markdown file with no mechanism to version or track which rules apply to Scala 2 vs Scala 3.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →