Please check the TechStack.md file for details.
An investigation and comparison between Kotlin and Java on an engineering level. Since beauty is in the eye of the beholder, this repository is not meant to evaluate Java or Kotlin on an aesthetic level.
This project started as an idea to explore differences in performance between different projects. It has grown now into a full fledge comparison between Java and Kotlin and ONLY for engineering purposes.
I won't dive into style IT discussions in this project. And of course the elegant
card is not the focal point here.
If you understand these terms, then I think you'll find this project interesting.
The way we are going to compare performance, response times and memory usage is going to be by processing a small novel I'm developing in the GoodStory file. We will apply algorithms to it, make objects, and explore the limits of our own machines.
Further, you may find that I'm using for
, while
and a do..while
in both Java
and Kotlin
implementations. This
is purposely done in some cases. I may find that in some cases there is no point in using the already implemented
algorithm for some situations. Especially if they can be
implemented in exactly the same way in Java
or Kotlin
without the use of a DSL.
Lombok
usage will be avoided as much as possible and so please do not be surprised if you get to see any manual
implementation of the builder pattern.
It caught my attention recently that in many blogs and videos, people are stressing out that coroutines and virtual threads are not about performance. That is of course directly true. What they are about is making a better use of a resource that has been there for ages. Sometimes called Continuation, sometimes called coroutines, but this is a concept that has been here for a long time. This repository is, regardless, about performance, because if we use our resources better, then that will ultimately result in better performance as a whole. So this repo is not about comparing the individual performance of one coroutine to one virtual thread. They work as a whole, both switch context, both can be suspended and both have different states. So I am measuring, or better yet, attempting to measure performance on a local machine and try to see if there is any significant difference there. These tests are also allowing to exhaust resources and therefore forcing each implementation to manage itself. It's here where the performance study comes in.
This repo is the official support repo to my article on medium:
- 1.0.0 - 315e7260b1214c8be1bc48a4af5446c8ad68bd9f - JDK19 runs with Jesperancinha GitHub Action for LoomJDK
- 1.0.1 - 64fcf38b3448f692353dffcc3a7150bdd1b2b645 - JDK19 is now installed as available
- 1.0.2 - 64fcf38b3448f692353dffcc3a7150bdd1b2b645 - Adds kotlin-loom with a Coroutine Dispatcher using a Loom Virtual Thread (original idea from apatrida. Check kotlin-loom-good-story for more details)
Java Project Loom is itself a JDK and in order to use it, you need first to install it
Be sure to run . ./sdk19.sh
before running any of the commands, but only if you don't have JDK19 installed. This
script installs JDK19 using SDK-MAN.
We cannot 100% compare Kotlin and Java in a direct way, but we will compare them using their best performant version.
JDK 19 is now available to install in different ways and it has been released. This means that this project is being updated as standard.
Please keep checking the evolution of file Log.md if you want to keep up to date with the results of the comparisons. It gets updated per commit. You can also check the detailed file for Java and the detailed file for Kotlin.
You can run the whole test in one go by running:
make clean build-run
For heavier tests please run:
make clean build-run-loccal
5. Coffee Sessions ☕️
- Coroutines are not about multi-threading at all
- Structured concurrency by Roman Elizarov
- libdill: Structured Concurrency for C
- Java Virtual Threads by Gaetano Piazzolla
- Carrier Kernel Thread Pinning of Virtual Threads (Project Loom)
- GitHub's "Our response to the war in Ukraine" 🇺🇦
- Why Continuations are Coming to Java
- Coroutines overview
- JetBrains’ Statement on Ukraine 🇺🇦
- Scala (programming language)
- History of Scala
- Project Loom (Java 19)
- Java (programming language) ☕
- Project Loom: Fibers and Continuations for the Java Virtual Machine
- Coming to Java 19: Virtual threads and platform threads
- STAR method interview ✨
- Amazon Leadership Examples on Youtube
- System Design Messenger on Youtube
- Behavioral Interview Prep
- System - Design - Primer
- Grokking the System Design Interview
- Grokking the Coding Interview: Patterns for Coding Questions
- Big O Notation and Time/Space Complexity
- Analysis of Algorithms | Big-O analysis
- BTech smart class - Introduction to algorithms
- Splay tree
- Big-O Quiz
- Sieve of Eratosthenes
- Binary search tree
- The height of an AVL tree containing n nodes
- AVL Tree
- Data Structure and Algorithms - AVL Trees
- AVL Tree Insertion, Rotation, and Balance Factor Explained
- What is an AVL tree? 🌳
- AVL Tree program in Java
- How to insert Strings into an AVL Tree
- Big O Factorial Time Complexity
- BIG O NOTATION PRIMER
- What would cause an algorithm to have O(log log n) complexity?
- What does O(log n) mean exactly?
- Big O Notation, Part Two: Space Complexity
- ALGORITHMS IN KOTLIN, BIG-O-NOTATION, PART 1/7
- Big O Cheat Sheet
- Time complexity vs. space complexity
- Complexity and Big-O Notation
- Going inside Java’s Project Loom and virtual threads
- Kotlin Coroutines dispatchers
- VisualVM
- Picocli
- Issues with Spring, how Micronaut solves it, and latter’s support for GraalVM
- Kotlin Coroutines
- Java Project Loom
- GitHub Action for GraalVM
- Project Loom: Understand the new Java concurrency model
- Going inside Java’s Project Loom and virtual threads
- The Complete Guide to Big O Notation & Complexity Analysis for Algorithms: Part 1 of 2
- P99 CONF: High-Performance Networking Using eBPF, XDP, and io_uring
- Mcdowell, G. (23rd April 2020). Cracking the Coding Interview 189 Programming Questions and Solutions. (6th Edition). CareerCup
- Cormen, T. Leiserson, C. Rivest, R. Stein, C. (2009). Introduction to Algorithms. (Third Edition). MIT Press