Is Old Kafka written in Scala and new Kafka written in Java?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Apache Kafka, a distributed streaming platform, has become a critical component for managing large-scale data pipelines. Kafka is designed for fault-tolerance, high throughput, and scalability in distributing large volumes of real-time data. A common question posed by many is regarding the programming languages used in building Kafka: was old Kafka written in Scala, and is new Kafka written in Java?
Historical Context and Language Migration
Originally, Kafka was developed by LinkedIn and later donated to the Apache Software Foundation. The initial versions of Kafka were primarily written in Scala. This choice was strategic at the time due to Scala's functional programming features and its seamless interoperability with Java, which is critical given that Kafka interfaces with many other systems that run on the JVM (Java Virtual Machine).
However, over time, the Kafka project gradually shifted toward Java for several major reasons:
- Broader Developer Base: Java has a larger pool of developers compared to Scala, easing the contribution process for a broader community.
- Simpler codebase management: Java's verbosity, while often criticized, can lead to more straightforward code which is easier for new developers to understand and maintain.
- Performance considerations: Although Scala provides concise and expressive code, the Kafka team found that Java's performance was more predictable and easier to manage, especially at scale.
Transition from Scala to Java
The transition did not happen overnight but was a gradual migration over several versions. Key components and modules were rewritten in Java, with the older Scala code being either completely phased out or minimized to certain areas less integral to Kafka’s core functionalities.
Technical Implications
From a technical standpoint, this shift had several implications:
- API Changes: As Kafka’s core modules were rewritten in Java, some APIs evolved, not necessarily in functionality but in the way they were expressed or configured in Java. This required developers to adapt and, in some cases, refactor their existing Kafka-based applications.
- Performance Tuning: Java and Scala might manage memory slightly differently due to different compiler optimizations and runtime handling. Tuning Kafka performance after the rewrite involved reassessing these differences.
- Tooling and Integration: Java has a rich set of development and debugging tools, which made it easier to develop and maintain Kafka’s burgeoning feature set.
Current Status and Community Contributions
As of now, Kafka is predominantly Java-based. Its source code, samples, and API clients majorly leverage Java, although clients in other languages exist, including maintained Scala versions for compatibility. The Apache Kafka community actively supports Java for its ongoing development.
Examples
Here are brief snippets showing the transition in the coding style and norms from Scala to Java in Kafka:
Scala (old) - Example Producer Code:
Java (new) - Example Producer Code:
Summary Table
| Feature | Old Kafka (Scala) | New Kafka (Java) |
| Language | Scala | Java |
| Performance | Good (optimized for JVM) | Improved Stability |
| Codebase Complexity | High due to functional features | Lower, more verbose |
| Community Contribution | Smaller due to Scala use | Increased due to Java use |
Conclusion
The evolution of Kafka from Scala to Java is a testament to the platform’s adaptability and the community’s responsiveness to the needs of a growing and diversifying user base. This shift has enabled Kafka to maintain its position as a leading platform for streaming large-scale data efficiently and reliably, demonstrating that sometimes, the tools used in building solutions are as dynamic as the solutions themselves.
Related reading
- Is rabbitmq bidirectional?
- Is RabbitMQ capable of pushing messages from a queue to a consumer?
- Is the --group option deprecated from kafka-console-consumer tool? if so, how can I set the consumer group using kafka-console-consumer.
- Is the Confluent Platform based on Kafka free? open source?
- Is Random class thread safe?
- Is shifting bits faster than multiplying and dividing in Java? .NET?
- Is there a code sample for multiple producers in spring kafka?
- is there a deb repository for Kafka

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.