June 25th, 2024

JEP 401: Value Classes and Objects (Preview)

JEP 401 introduces value classes and objects in Java, focusing on optimizing memory efficiency by distinguishing objects solely by their field values, not identity. This feature enhances performance for simple domain values.

Read original articleLink Icon
JEP 401: Value Classes and Objects (Preview)

JEP 401 aims to introduce value classes and objects to the Java Platform, allowing developers to opt into a programming model where objects are distinguished solely by their field values, not their identity. This feature aims to enhance memory efficiency and garbage collection by optimizing simple values representation. It does not introduce a struct feature or change the treatment of primitive types. The motivation behind this enhancement is to address the performance issues related to object identity, especially for simple domain values like colors or currency. By opting out of object identity, developers can benefit from a programming model that combines the abstraction of classes with the performance benefits of primitives. Value classes are a preview language feature that can be enabled to create objects without identity, improving memory usage and data locality. The JEP also includes migrating popular classes like Integer to this new programming model, emphasizing the importance of distinguishing objects based on their values rather than their identity.

Related

Moving to Java 17 or how I learned to stop worrying and love NoSuchMethodError

Moving to Java 17 or how I learned to stop worrying and love NoSuchMethodError

Icon Solutions upgraded to Java 17 in IPF 2024.1 for Spring 6 and Spring Boot 3 compatibility. Challenges included plugin and dependency adjustments, emphasizing centralized management and code cleanliness post-upgrade for smoother transitions.

Elixir Gotchas

Elixir Gotchas

The article highlights common pitfalls in Elixir programming, including confusion between charlists and strings, differences in pattern matching, struct behavior, accessing struct fields, handling keyword lists, and unique data type comparisons.

Optimizing the Roc parser/compiler with data-oriented design

Optimizing the Roc parser/compiler with data-oriented design

The blog post explores optimizing a parser/compiler with data-oriented design (DoD), comparing Array of Structs and Struct of Arrays for improved performance through memory efficiency and cache utilization. Restructuring data in the Roc compiler showcases enhanced efficiency and performance gains.

Deriving Dependently-Typed OOP from First Principles

Deriving Dependently-Typed OOP from First Principles

The paper delves into the expression problem in programming, comparing extensibility in functional and object-oriented paradigms. It introduces dependently-typed object-oriented programming, emphasizing duality and showcasing transformations. Additional appendices are included for OOPSLA 2024.

Self and Self: Whys and Wherefores (2009) [video]

Self and Self: Whys and Wherefores (2009) [video]

The YouTube video discusses career and idea management, prioritization, Simula creation, structured programming, leadership in development, values in design, and efficient garbage collection. It mentions optimizing a Small Talk system in graduate studies.

Link Icon 4 comments
By @HideousKojima - 4 months
This makes Java better in some fundamental ways, but I'm failing to see what advantages it has over C# outside of the JVM being supported just about everywhere (which is admittedly a pretty big deal in itself).
By @yarg - 4 months
Is this a preview feature in mainline, or are they still working on a branch?

I couldn't tell from the page.

By @tialaramex - 4 months
> All Java developers would benefit if == ignored object identity and focused on the "essence" of the object

And yet, doing so is explicitly a non-goal of this work, is that because it needs a migration plan nobody can stomach? Before trying Rust I would have doubted that this just doing the Right Thing was important, but now I would co-sign that in a moment. I bet I've avoided a dozen bugs per year by having the == operator do what I meant not something that was easier to implement.