RSSAmplifier

Blog

belief driven design

Recent content on belief driven design

belief-driven-design.comRSS feed ↗107 posts

Latest posts

What synchronized Actually Does

Asked for a one-line mental model of what synchronized does, most have a simple answer: making sure only one thread at a time can access the synchronized block or method.

The Secret Life of a Java String

String is the most-used type in any Java codebase, without much competition. And yet, most developers don’t know much about what actually happens under the hood.

GC-Free Indexing and Compaction (Part 3)

After Part I gave us raw I/O performance and Part II gave us safety and durability, there are still two fundamental flaws currently present: Reads are slow: Every lookup requires scanning the entire segment. This means an O(n) operation, and that’s unacceptable. Disk usage is unbounded: Updates and deletes leave garbage bytes on the disk behind forever. So eventually, we run out of space. In…

Designing a Crash-Resilient Binary Format (Part 2)

In the previous article, we built a fast append-only log using Java’s Panama FFM API. It was clean , efficient , and… fundamentally broken .

Building a Storage Engine in Modern Java with Panama (Part 1)

Java has often been dismissed for latency-sensitive systems programming in the past. Not because it’s slow, but because it’s unpredictable.

UUIDv7 in Java

UUIDs are the dark matter of modern software. You rarely look at them directly, but they hold the distributed universe together. They are the easiest way to create a unique identifier, which is why they quietly power so many systems.

How Fast Are Streams Really?

Java Streams have significantly impacted how we process data since their release in 2014. The fluent and declarative API offers undeniable advantages in readability, conciseness, and safety, especially for complex transformations or large datasets. But what about the bread-and-butter tasks?

Shell Navigation 101

Navigating the shell is an indispensable skill. While GUIs might be more intuitive in some ways than the command line, they lack the speed and raw power a shell offers. Therefore, efficient shell navigation that goes beyond just cd goes a long way.

Taking Out the Trash in Java

Memory management is a critical aspect of any programming language. It ensures that applications efficiently use the available resources without leaking memory or crashing.

Why Everyone Talks About Zig

There’s a new contender in the ever-evolving landscape of programming languages everyone seems to talk about: Zig .

What Happens After We Hit Compile in Java?

When writing Java code, our primary focus is the classes, methods, and best coding practices. However, once we hit “compile,” the source code undergoes quite a transformation before execution.

Templating with Thymeleaf: Custom Dialects and More (Part 3)

In the previous articles, we explored the fundamentals of Thymeleaf and focused on reusability with fragments and the Layout Dialect. Now, in this final installment, we’ll dive into the more advanced features, like creating a custom dialect, processors, and more.

Templating with Thymeleaf: Fragments and Reusability (Part 2)

It’s time to dive into one on Thymeleaf’s most powerful aspects: layout management and reusability. These concepts are essential for creating maintainable and efficient templates.

Templating with Thymeleaf: The Basics (Part 1)

Thymeleaf is a modern Java template engine for both web and standalone applications. Although widely used in the Spring ecosystem, it can be integrated into any JVM environment. If you need a dynamic, flexible, and extensible templating engine, Thymeleaf might be just what you need.

Vom Bytecode-Henne-Ei-Problem zur neuen Java Class-File API

Date and Location: 2024-10-15 at betterCode(Java) 2024 ( Details ) Slides: Download Abstract Bytecode-Manipulation hat eine lange Tradition im Java-Ökosystem. Die Gründe dafür sind vielfältig: von Leistungsoptimierungen über Codemanipulation bis hin zur dynamischen Implementierung zur Laufzeit. Traditionell werden für das Low-Level-Handling Tools wie ASM, CGLib, Javassist und andere verwendet.…

The Bytecode Chicken-Egg Problem

Bytecode is the (mostly) invisible superpower of the Java Virtual Machine (JVM). Even though it’s an essential part of the Java ecosystem puzzle, it’s also a niche topic and behind-the-scenes feature that many of us do only have surface knowledge of. However, there’s a chicken-egg problem lurking within Bytecode libraries which the OpenJDK team intends to fix with JEP 484 .

Vom Bytecode-Henne-Ei-Problem zur neuen Java Class-File API

Date and Location: 2024-08-28 at JUG Karlsruhe ( Details ) Slides: https://bytecode-chicken-egg.netlify.app/ Recording: https://www.youtube.com/watch?v=3hrW-vGB204 Abstract Bytecode-Manipulation hat eine lange Tradition im Java-Ökosystem. Die Gründe dafür sind vielfältig: von Leistungsoptimierungen über Codemanipulation bis hin zur dynamischen Implementierung zur Laufzeit. Traditionell werden für…

Using Indexed and Associative Arrays in Bash

Shell scripting is vital for automating repetitive tasks and simplifying complex commands into a more straightforward format. Understanding the details of shell scripting enables us to write more robust, portable, and efficient scripts.

Understanding Java Generics: Key Features and Common Pitfalls

Generics are an indispensable feature in the world of Java programming, shaping how we write and interact with code. Despite their ubiquity and importance, many developers only scratch the surface of what Generics can do.

Reclaim Your Gmail Inbox with Google Scripts

Inbox Zero aims to declutter your mind and remove any anxiety over unread or missed emails lingering in your inbox. Instead of answering each email as soon as it arrives or letting it “rot” in the inbox, a tickler file relegates them until they become a priority and must be reviewed. So, let’s create our own tickler file with the help of Google Apps Scripts .

Exploring Java's Units of Measurement API (JSR 385)

Dealing with unit conversion is always a pain point. At first, it seems simple enough until you hit the first edge-case. Just like with Date and Time (JSR 310), there’s a well-specified solution available, although not directly in the JDK: the Units of Measurement API (JSR 385).

Looking at Java 22: Multi-File Source-Code Programs

Software development is a dynamic process, especially in the early stages of a project or when experimenting with new ideas. During these phases, files and overall structures can change frequently. Java, traditionally known for its strict organizational requirements, has made impressive strides to accommodate this fluidity and become more beginner-friendly.

Shell Traps and Posix Signals

Shell traps catch POSIX signals (and more) to allow asynchronous inter-process communication to inform any process or particular thread of various events and do some work. But do you know about all the different signals and ways to use the trap command?

Looking at Java 22: Stream Gatherers

The Stream API provides a rich and versatile set of intermediate operations, even though certain ops are still missing or are hard to implement with the given ones. Whereas terminal ops are quite customizable by writing our own Collector , an equivalent wasn’t available until now as a preview: Stream Gatherers .

Looking at Java 22: Foreign Function & Memory API

The Foreign Function & Memory API , part of Project Pananama , improves Java’s interoperability with code and data outside the JVM. Calling native libraries and working with native memory becomes safer and more straightforward than using the fragile and often dangerous JNI.

Looking at Java 22: Class-File API

Class files and the underlying Bytecode serve as the universal language within the Java ecosystem. Parsing, generating, and transforming class files are essential tasks enabling many of the tools and libraries we use daily.

Working with Numbers in Java

There’s more than one way to work with numbers in Java. We have access to 7 numeric primitive types and their boxed counterparts, high-precision object types, multiple concurrency-akin types and helpers, and more.

Looking at Java 22: Unnamed Variables & Patterns

In this article, I want to talk about a non-preview feature belonging to Project Amber , JEP 456. With Java 9, the _ (underscore) became a reserved keyword and no longer a valid identifier. Now, with the release of Java 22, the new keyword finally gets a specific meaning: something not having a name.

Grabbing Screen Text with a Shell Script

Recently, I stumbled upon an OCR tool for Linux. However, I didn’t like the idea of needing a GUI app, so I wrote a shell script connecting the right CLI tools instead. This article dissects “ grab-text ”, a simple POSIX-compatible shell script I wrote for grabbing text from your screen.

Looking at Java 22: Statements before super

The first (preview) feature of Java 22 I want to talk about is one I’m quite excited about! JEP 447 introduces a significant change by relaxing the strict rules for constructors. It finally allows (certain) statements to be executed before calling the super(...) call.

Looking at Java 22: Intro

Java 22 is just around the corner (GA 2024-03-19), so it’s time to look at (most of the) included goodies, much like we did with the previous version . This time around, the new version includes 12 JEPs in total, with 7 being previews and a single incubator one.

Better Code Snippets in JavaDoc

Effective documentation is an essential staple of every software project. Still, way too often, we neglect it at the moment. If we’re lucky, our future selves will take care of it. But let’s be honest here for a moment… it won’t happen! Consequently, any improvement that makes writing documentation more straightforward and easily accessible is an important and welcomed…

Java Enums 101

Introduced in 2004 alongside Java 5, Enums are a distinct type identified by their own keyword. They encapsulate a predefined, fixed set of named constants. This simple characteristic already provides ample value in our day-to-day code. However, their application extends beyond merely consolidating constants within a single type.

Test Swift Packages with a Test Host

Swift packages are a neat and simple way to bundle up and share code. They remove the overall complexity by not requiring an Xcode project but instead relying on a filesystem-based project layout. That’s all fine and well until your code needs an Entitlement for it to be tested.

Looking at Java 21: Structured Concurrency

Project Loom, with its aim to deliver “easy-to-use, high-throughput, lightweight concurrency”, will most likely change how we approach concurrency in the future. Today, we will look at the “glue” that can hold it all together: Structured Concurrency .

Looking at Java 21: The Little Things

Besides the “big” features that often aggregate under well-known project names, like “Amber”, “Loom”, or “Panama”, there are many little things in every release that are easy to miss. These API and tool improvements might not be as visible as other features, as they’re not represented by a JEP. That doesn’t mean we don’t need to…

Looking at Java 21: Virtual Threads

One of the most significant features of Java 21 is Virtual Threads ( JEP 444 ). These lightweight threads reduce the effort needed for writing, maintaining, and observing high-throughput concurrent applications.

Shell Redirection 101

Shell redirection can be confusing. I’ve always wondered what 2>&1 means and why it’s needed, but as many others, I just copy/pasted things from the internet into my terminal and hoped for the best. What could possibly go wrong?

Revisiting Java for Shell Scripting

Around 6 years ago, I wrote about using Java for shell scripts . It was a hacky and fragile way to convert some Java code into a shebanged file containing the content of a Jar file. However, Java evolved quite a bit since that article, so it’s time to look at it again.

Xcode String Catalogs 101

Localization, or l10n , is an important step for any app to reach a broader market and be more inclusive. With Xcode 15, the IDE gained a versatile and easy-to-use way of handling localization: String catalogs .

Looking at Java 21: Generational ZGC

A new garbage collector was introduced in Java 11, a low latency/high scalability GC called ZGC . And now, with Java 21, it has evolved into a generational GChugo .

Looking at Java 21: Record Patterns

Pattern matching is a declarative and composable approach for more powerful and expressive code. Java 16 added pattern matching for the instanceof operator, and we looked at pattern matching for switch before. Let’s look at another new kind of pattern matching: Record Patterns .

Looking at Java 21: Feature Deprecations

Even though Java is one of the most backward-compatible languages and environments I’ve ever worked with, there’s always the possibility of feature deprecations and even removals.

Xcode Breakpoints 101

Knowing how to debug a problem is essential in any project. But there’s way more to it than just stopping at a certain point with a breakpoint. From running custom code, over symbolic breakpoints, to sharing breakpoints via Git, Xcode has something for everyone.

Looking at Java 21: Switch Pattern Matching

The switch control structure has quite an evolution lately since its inception. First, there were switch expressions ( JEP 325 , 354 , 361 ). And now, we get pattern matching for switch statements and expressions!

Looking at Java 21: Scoped Values

Today we look at Scoped Values , another interesting preview feature that’s incubating since Java 20 ( JEP 429 ). It’s a new way to store and share immutable data with a bounded lifetime within a thread and its child threads.

Looking at Java 21: Sequenced Collections

Dealing with Collections is improving with Java 21, as three new interfaces get retro-fitted right into the existing type hierarchies. These Sequenced Collections give us a uniform API to access the first and last elements, and process Collections in reverse.

Looking at Java 21: Simpler Main Methods and Unnamed Classes

Java’s known (and often criticized) for its vast amount of required boilerplate and ceremony for perceived mundane tasks, at least compared to other languages. JEP 445 is explicitly targeted to make the first introduction to Java a breeze, though.

Looking at Java 21: String Templates

Java’s String type is a ubiquitous type that’s used in every program out there. Over the years, it received many improvements. And now, another exciting improvement is coming that makes String safer and easier to use: String templates.

Looking at Java 21: Intro

Java 21 has recently entered “rampdown phase one”, and is planned for general availability in September! This new LTS release comes with many new features, that’s why I want to take the next few weeks to take a deeper look at the ones that excite me the most!