Articles on Java

Last updated: 2022/11/29

Top deep-dives on Java

It's probably time to stop recommending Clean Code

As humans, most of us are subject to authority bias, which can be described as the natural tendency to follow the leader. But the fact is, authoritative figures aren't always right. In this extensive article, Sam Hughes questions the merit of preaching ALL of the teachings of Clean Code by Robert C. Martin, by picking at some of the "questionable assertions" made.

The JPA and Hibernate first-level cache

The Java Persistence API is a Java application programming interface specification that describes the management of relational data in Java. It's basically the built-in Java way of interacting with relational databases. In this article, Vlad Mihalcea lists the possible states for a JPA entity, outlines the Hibernate first-level cache implementation, and explains the transactional-write behind cache strategy.

Why General Inheritance is Flawed and How to Finally Fix it

Uncontrolled inheritance can start to suck a lot because it leads to a convoluted web of dependency. In this explanatory article, Per Minborg discusses when Java classes and methods should be made final and other general good practices for controlling composition in your software.

Reading and writing, part 1: locations and locks

Data races are a huge pain in the ass in programming. They're hard to identify when you're both writing code and running it. It's always worth learning techniques that can help you spot the problems before they actually arise. In this exemplary article, James Coglan uses examples in JavaScript, Ruby, and Java to highlight simple scenarios in which these pesky errors can occur. Don't be fooled by the triviality of the examples though; their existence in your own code might seem unlikely, but that might just be because they're masked by complexity.

Overhead of Returning Optional Values in Java and Rust

How does one turn the idea of nothing into something physical? Well Alex, you say in your most pedagogic inner voice, isn't that what 0 is? Well dear reader, it's probably up to the individual, but null is one of the more common methods. Piotr Kołaczkowski's article however, focuses on an alternative to null, the Optional or Maybe type. Piotr specifically focuses on the performance impact of using this type, as opposed to primitives, in both Java and Rust.

The race condition that led to Flexcoin bankruptcy

Vlad Mihalcea demonstrates how small issues in Java concurrency implementation can lead to big financial problems.

Disassembling Hello World in Java

You might think yourself above a simple "Hello world" example written in Java, but do you really understand every single part of the program? In this concise article, Metin Özyıldırım picks apart the titular program, explaining the .class file format, diassembling, interpreting the bytecode, and the Java native interface and system calls.

100% CPU: My Fault?

"You broke something" isn't usually what you want to hear from a system admin. Unless maybe we're talking about a record. In this case, Joseph Mate is not talking about records; instead his article is about how and why a well-intended optimization led to a JDK8 bug that caused 100% CPU utilization.

Java Concurrency: Deadlock

Writing Environment-Agnostic Functional Acceptance Tests

Modularity is pretty important when it comes to creating prototypes or tests. You want to be able to quickly switch or change things out, depending on evolving circumstances or requirements. Jamie Tanna's article brings to light a technique using class structures for writing modular and adaptable testing suites for services in Java.

Why I rewrote my open source virtual reality server

Virtual Reality has been growing in popularity over the past couple of years and for good reason; the hardware is becoming more practical and accessible. Unfortunately, the open source space for VR is pretty limited, with big companies vying for control of the space and your data. Josip Almasi describes his privacy (and practicality) based motivations for creating an open source virtual reality server, while also outline some of the resources used and design approach.

The difficult problem of managing Java dependencies

Paulo Renato de Athaydes dives into the state of dependency management in Java, demonstrating how different tools work and why.

Hash, displace, and compress: Perfect hashing with Java

Andrei Ciobanu demonstrates implementing a perfect hash function in Java.

Virtual Threads: New Foundations for High-Scale Java Applications

Brian Goetz presents virtual threads in Java 19. Virtual threads are a lightweight implementation of Java threads that dramatically reduce the effort of writing, maintaining, and observing high-throughput concurrent applications. Brian discusses existing threads, virtual threads, why they're being added, and the limitations of async. Not going to include highlights because there are key takeaways at the start of the article.

Consolidating the user model

Project Valhalla is an experimental OpenJDK project led by Brian Goetz, with the aim of adapting the Java language and runtime to modern hardware. Now that the "primitive classes have taken shape" Brian Goetz has written an article-esque email where he once again explores one of the main objectives of Valhalla, "providing user-programmable classes which could be flat and dense in memory".

Loop Fission

Loop fission is usually done by the compiler (although you can use it in your own coding to) to break up big loops into smaller loops, which can then potentially be optimized on their own. In this article, Richard Startin presents two examples where manually fissioning his loops resulted in better performance when using Java's C2 compiler.

The one about Lisp interactivity

Michael Fogus explores the development process for a Lisp as compared to Java.
Some highlights:

  • Developing with a Lisp feels more like collaborating with the programming language, as opposed to ordering it around
  • One of the advantages of developing with a Lisp is being able to interact with your program as it's running
  • Lisps encourage continuous development cycles

Benchmarking Non-shared Locks in Java

Locks are a key component in thread programming. In this practical article, Andrey Pechkurov explores several different options for spin locks in Java; specifically focusing on their performance in terms of latency.

Retrofitting null-safety onto Java at Meta

Artem Pianykh, Ilya Zorin, and Dmitry Lyubarskiy describe the development of a new static analysis tool called Nullsafe that is used to detect NullPointerException (NPE) errors in Java code.
Some highlights:

  • The tool is designed to improve the null-safety of Java code by providing tools to express and check nullness invariants
  • The tool has been integrated into the core developer workflow and has helped to significantly reduce the overall number of NPE errors and improve developers’ productivity
  • Interoperability with legacy code and gradual deployment model were key to Nullsafe’s wide adoption in a multimillion-line codebase

Seeing through hardware counters: a journey to threefold performance increase

Vadim Filanovsky and Harshad Sane discuss how a microservice was moved to a larger AWS instance size in order to increase performance, but the results were far from the desired goal. Through further investigation, it was discovered that there was a strange pattern in the CPU and latency metrics between nodes.
Some highlights:

  • A larger instance type didn't solve the problem
  • Flame graphs can be used to compare CPU performance
  • The root cause was “false sharing,” where 2 independent variables share a cache line

Did You Know the Fastest Way of Serializing a Java Field is not Serializing it at All?

Per Minborg dives into the performance of different methods for the serialization of data in Java.

Want to see more in-depth content?

subscribe to my newsletter!

Other Articles