Cloud VPS from $1.98/mo · pay with Bitcoin, Ethereum, Monero, USDT or Solana · paid in crypto
DevOps

Scala or Java for a JVM backend: what still separates them

Scala or Java for a JVM backend: what Java 25 caught up on, where Scala 3 still pays off, which LTS lines and build tools to pick, and how to size the JVM.

CloudSat teamNovember 18, 20266 min read
Abstract illustration of two intertwined spirals of light, one angular and one curved, rising from a shared coffee-cup shaped base
On this pageWhere the two languages stand in November 2026

For years the case for Scala on the JVM began with what Java lacked: concise data classes, pattern matching, a decent way to model "one of these cases". Java has since shipped most of that. The choice between the two is now less about syntax and more about programming style, ecosystem and the people who will maintain the code. Both run on the same JVM, call the same libraries and deploy the same way, so the decision is reversible module by module, but rarely cheap.

Where the two languages stand in November 2026

Line Released Status
Java 25 September 2025 Long-term support release from most vendors
Java 27 September 2026 Feature release, not LTS
Scala 3.9 September 2026 New LTS line, advised for publishing libraries, maintained for at least three years
Scala 3.3 2023 Previous LTS, maintained for one year after 3.9.0
Scala 3.10 2026 Scala Next, the version most users should pick
Scala 2.13 Maintenance Current release 2.13.18; still what Apache Spark targets

Two Scala details matter for planning. Since Scala 3.8, compiling and running Scala needs JDK 17 or newer, so the 3.9 LTS cannot target older JVMs. And artifacts built with Scala 3.9 cannot be consumed by Scala 3.3 projects, so a library that moves to the new LTS drops users still on 3.3.

What modern Java caught up on

Model a small domain in both languages and the code now looks alike. In Java 25, records, sealed interfaces and pattern matching for switch (final in Java 21) give you exhaustive case analysis:

sealed interface OrderEvent permits Placed, Shipped, Cancelled {}
record Placed(String orderId, long totalCents) implements OrderEvent {}
record Shipped(String orderId, String carrier) implements OrderEvent {}
record Cancelled(String orderId, String reason) implements OrderEvent {}

static String describe(OrderEvent e) {
    return switch (e) {
        case Placed(var id, var total) -> id + " placed, " + total + " cents";
        case Shipped(var id, var carrier) -> id + " shipped with " + carrier;
        case Cancelled(var id, var reason) -> id + " cancelled: " + reason;
    };
}

The Scala 3 version is shorter, but not by the margin it once was:

enum OrderEvent:
  case Placed(orderId: String, totalCents: Long)
  case Shipped(orderId: String, carrier: String)
  case Cancelled(orderId: String, reason: String)

import OrderEvent.*

def describe(e: OrderEvent): String = e match
  case Placed(id, total)     => s"$id placed, $total cents"
  case Shipped(id, carrier)  => s"$id shipped with $carrier"
  case Cancelled(id, reason) => s"$id cancelled: $reason"

Concurrency moved too. Virtual threads, final in Java 21, let ordinary blocking code handle large numbers of concurrent requests without callbacks or reactive types, and Java 24 removed the pinning that synchronized blocks used to cause. Java 25 finalized scoped values and flexible constructor bodies, and made compact object headers, which shrink each object's header from 96 to 64 bits, a supported option. Structured concurrency is still a preview feature in Java 27.

Where Scala 3 still pays off

The remaining gap is in the type system and in what libraries build on it:

  • Type classes and contextual abstractions. given and using let you attach behavior such as JSON encoding or ordering to types you do not own, resolved at compile time.
  • Richer types. Union and intersection types, opaque types for zero-cost wrappers such as UserId, and higher-kinded types for code that abstracts over containers.
  • Effect systems. Cats Effect and ZIO, both Apache-2.0, give you lightweight fibers, cancellation, resource safety and structured concurrency as libraries, available today rather than in preview.
  • Data and actor ecosystems. Apache Spark's native API is Scala; Spark 4.3.0, released in October 2026, is built for Scala 2.13, so Spark code is written in Scala 2.13 rather than Scala 3. Apache Pekko, the Apache-licensed fork of Akka 2.6.x made before Akka moved to the Business Source License, serves Java and Scala alike.

If your team wants pure functional programming with checked effects, Scala is the natural home on the JVM. If it wants plain objects, blocking I/O and the largest choice of frameworks and tutorials, Java 25 now covers that without apology.

Toolchains

Tool Typical use Notes
Maven Java services XML, conventional, supports Scala through a plugin
Gradle Java and Kotlin services Scripted builds, has a Scala plugin
sbt Scala projects sbt 2 builds are written in Scala 3; 2.1.0 shipped in November 2026, and 1.x is still maintained
Mill Scala projects A simpler, faster alternative to sbt, now in its 1.x series
Scala CLI Scripts, small apps, teaching The default scala command since Scala 3.5

Mixed teams often keep Maven or Gradle for Java modules and use sbt or Mill only where Scala dominates. Scala calls Java libraries directly; the reverse works for plain classes, while Scala-specific features such as givens and default arguments are awkward from Java.

People decide more than features

The language that fits your team beats the one that wins a feature table. Questions worth answering honestly:

  • Who maintains this in three years? Every JVM developer reads Java. A Scala codebase also asks for its own idioms, and Scala teams differ widely in style, from "better Java" to pure functional code with an effect system. Pick one style and write it down.
  • What do the libraries you need assume? Spark pulls you toward Scala 2.13. Most Java frameworks, such as Spring Boot or Quarkus, are designed around Java first.
  • How long do builds take? Scala's compiler does more work and builds are slower; budget CI capacity accordingly.

Running either one on a VPS

The deployment is identical: a JDK, a jar or a native image, and a service manager. Three JVM defaults deserve attention on a small server:

  • Heap size. Without flags, the JVM caps the heap at 25% of the memory it sees. On a dedicated server that wastes most of the RAM; set -XX:MaxRAMPercentage (or -Xmx), leaving room for metaspace, thread stacks and direct buffers, which live outside the heap.
  • Garbage collector. On a machine with a single CPU or less than 1792 MB of memory, Java 25 selects the Serial collector instead of G1. Java 27 makes G1 the default everywhere. Name the collector explicitly if you want the same behavior on every plan size.
  • Object headers. On Java 25, -XX:+UseCompactObjectHeaders enables compact headers; Java 27 turns them on by default.
# /etc/systemd/system/orders.service
[Unit]
Description=orders service
After=network-online.target
Wants=network-online.target

[Service]
User=orders
ExecStart=/usr/bin/java -XX:MaxRAMPercentage=60 -XX:+UseG1GC -XX:+UseCompactObjectHeaders -jar /opt/orders/orders.jar
SuccessExitStatus=143
Restart=on-failure

[Install]
WantedBy=multi-user.target

SuccessExitStatus=143 tells systemd that a JVM stopped by SIGTERM (exit code 128 + 15) shut down cleanly. On CloudSat, a Cloud VPS with 2 GB at $5.98/mo leaves room for a small service's heap and the operating system, while CI machines that run sbt or Gradle builds are more comfortable with 4 GB.

FAQ

Is Scala still actively developed?

Yes. Scala 3.9 opened a new long-term support line in September 2026, Scala 3.10 is the current Scala Next release, and sbt 2.1.0 shipped in November 2026. The question for your team is less whether Scala will be maintained and more whether you can hire and train for it.

Can Scala and Java live in the same codebase?

Yes. sbt, Maven and Gradle can compile both in one project, and Scala uses Java libraries without wrappers. Keep the boundary simple: expose plain classes and interfaces from Scala modules that Java code must call.

Which JDK should a new Scala 3 project use?

A current LTS JDK, Java 21 or Java 25, unless a dependency forces otherwise. Scala 3.8 and later require JDK 17 as a minimum, and staying on LTS releases keeps the platform under updates while you upgrade Scala on its own schedule.

Run it on CloudSat. Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. See plans or deploy a server.