Java for Scala Developers
A practical guide for Scala developers learning modern Java 21+. Compare Java Records, Pattern Matching, Virtual Threads with Scala case classes, match expressions, and more.
Latest Posts
-
Tricky Java Patterns That Everyone Uses But Few Understand
Have you ever copy-pasted code from StackOverflow that “just works” but wondered why it’s written that way? Java has several patterns that developers use daily without fully understanding their implications. Some are performance optimizations that seem counter-intuitive, others are subtle...
-
Comparing JVM Test Frameworks: JUnit 5, ScalaTest, and Kotest
Testing is a critical part of software development on the JVM. This comprehensive guide compares the three most popular test frameworks across Java, Scala, and Kotlin: JUnit 5, ScalaTest, and Kotest. We’ll explore their features, syntax styles, and cross-language compatibility...
-
String Templates (Preview) - Safe String Interpolation
This is Part 8 of our Java 21 Interview Preparation series. We’ll explore Java 21’s String Templates preview feature, build a SQL query builder that safely interpolates parameters, and compare with Scala 3 and Kotlin approaches.
-
Local Variable Type Inference with var
This is part of our Java 21 Interview Preparation series. We’ll explore local variable type inference using Java’s var keyword (Java 10+), comparing it with Scala 3’s and Kotlin’s approach to type inference.
-
Foreign Function and Memory API in Java 21
Java 21 introduces the Foreign Function and Memory (FFM) API as a stable feature, providing a modern alternative to JNI for native code integration. In this post, we’ll explore how to use the FFM API to integrate with native C...
-
Null-Safe Programming with Optional
This is Part 4 of our Java 21 Interview Preparation series. We’ll explore the Optional API and null-safe programming patterns, comparing Java 21’s approach with Scala 3’s Option and Kotlin’s built-in null-safety.
-
Virtual Threads and Structured Concurrency in Java 21
Project Loom brings revolutionary changes to Java concurrency with virtual threads and structured concurrency. In this post, we’ll migrate a thread-pool-based web scraper to virtual threads, demonstrating the dramatic simplification and scalability improvements.
-
Stream API Advanced Operations
This is Part 4 of our Java 21 Interview Preparation series. We’ll explore advanced Stream operations and collectors, comparing Java 21, Scala 3, and Kotlin approaches.
-
Functional Interfaces and Lambda Expressions
Functional programming is a core paradigm in modern software development. This post explores how Java, Scala, and Kotlin handle functional interfaces, lambda expressions, and function composition, with a practical example: building a configurable retry mechanism.
-
Collection Factory Methods and Stream Basics
This is Part 3 of our Java 21 Interview Preparation series. We’ll explore modern collection factory methods (Java 9+) and Stream API fundamentals, comparing them with Scala 3 and Kotlin approaches.
-
CompletableFuture and Asynchronous Programming
Asynchronous programming is essential for building responsive, high-performance applications. This post explores how Java, Scala, and Kotlin handle async operations, with a focus on aggregating data from multiple APIs concurrently.
-
String Manipulation with Modern APIs
This is Part 2 of our Java 21 Interview Preparation series. We’ll explore modern String API enhancements introduced in Java 11-17, comparing them with Scala 3 and Kotlin approaches.
-
Sealed Classes and Exhaustive Pattern Matching
Sealed classes are a powerful feature for type-safe domain modeling. Java 17 introduced sealed classes and interfaces, bringing Java closer to Scala’s sealed traits and Kotlin’s sealed classes. In this post, we’ll explore how to model a payment system using...
-
Immutable Data with Java Records
This is the first post in our Java 21 Interview Preparation series. We’ll explore Java Records, one of the most significant additions for Scala developers coming to Java.
-
Java 21 Interview Preparation Plan
This post outlines a comprehensive plan for preparing for a Java Senior Developer interview, especially for developers who haven’t worked with Java since JDK 1.8. The problems are divided into three groups: Basic, Medium, and Advanced, with a focus on...
-
Pattern Matching in Java 21
Pattern matching is one of Scala’s killer features. Java has been steadily adding pattern matching capabilities, and Java 21 brings significant improvements. Let’s explore!
-
Java Records vs Scala Case Classes
One of the most beloved features of Scala is the case class. Java 16+ introduced Records, which provide similar functionality. Let’s compare them!
-
Welcome to Java for Scala Developers
Welcome to the Java for Scala Developers blog! This is a practical guide for Scala developers who want to learn or refresh their Java knowledge.
Post Timeline
Tricky Java Patterns That Everyone Uses But Few Understand
Have you ever copy-pasted code from StackOverflow that “just works” but wondered why it’s written that way? Java has several...
Comparing JVM Test Frameworks: JUnit 5, ScalaTest, and Kotest
Testing is a critical part of software development on the JVM. This comprehensive guide compares the three most popular test...
String Templates (Preview) - Safe String Interpolation
This is Part 8 of our Java 21 Interview Preparation series. We’ll explore Java 21’s String Templates preview feature, build...
Local Variable Type Inference with var
This is part of our Java 21 Interview Preparation series. We’ll explore local variable type inference using Java’s var keyword...
Foreign Function and Memory API in Java 21
Java 21 introduces the Foreign Function and Memory (FFM) API as a stable feature, providing a modern alternative to JNI...
Null-Safe Programming with Optional
This is Part 4 of our Java 21 Interview Preparation series. We’ll explore the Optional API and null-safe programming patterns,...
Virtual Threads and Structured Concurrency in Java 21
Project Loom brings revolutionary changes to Java concurrency with virtual threads and structured concurrency. In this post, we’ll migrate a...
Stream API Advanced Operations
This is Part 4 of our Java 21 Interview Preparation series. We’ll explore advanced Stream operations and collectors, comparing Java...
Functional Interfaces and Lambda Expressions
Functional programming is a core paradigm in modern software development. This post explores how Java, Scala, and Kotlin handle functional...
Collection Factory Methods and Stream Basics
This is Part 3 of our Java 21 Interview Preparation series. We’ll explore modern collection factory methods (Java 9+) and...
CompletableFuture and Asynchronous Programming
Asynchronous programming is essential for building responsive, high-performance applications. This post explores how Java, Scala, and Kotlin handle async operations,...
String Manipulation with Modern APIs
This is Part 2 of our Java 21 Interview Preparation series. We’ll explore modern String API enhancements introduced in Java...
Sealed Classes and Exhaustive Pattern Matching
Sealed classes are a powerful feature for type-safe domain modeling. Java 17 introduced sealed classes and interfaces, bringing Java closer...
Immutable Data with Java Records
This is the first post in our Java 21 Interview Preparation series. We’ll explore Java Records, one of the most...
Java 21 Interview Preparation Plan
This post outlines a comprehensive plan for preparing for a Java Senior Developer interview, especially for developers who haven’t worked...
Pattern Matching in Java 21
Pattern matching is one of Scala’s killer features. Java has been steadily adding pattern matching capabilities, and Java 21 brings...
Java Records vs Scala Case Classes
One of the most beloved features of Scala is the case class. Java 16+ introduced Records, which provide similar functionality....
Welcome to Java for Scala Developers
Welcome to the Java for Scala Developers blog! This is a practical guide for Scala developers who want to learn...
Welcome to the practical guide for Scala developers who want to learn (or re-learn) Java!
This blog covers modern Java features, comparing them with their Scala equivalents, and providing practical examples to help you transition between the two languages.
Modules
This repository contains examples in multiple languages:
- Java 21 - Modern Java with preview features
- Scala 2 - Scala 2.13 examples
- Scala 3 - Scala 3 examples
- Kotlin - Kotlin examples for comparison