at some frustrating aspects of Java • Context to decisions made with respect to design philosophy • Compare choices with C# What is this talk about? https://www.reddit.com/r/ProgrammerHumor/comments/ddc4b0/microso ft _java/
concurrency, portable byte code Cedar GC, modularity, type safety and integrated development environment! https://xeroxnostalgia.com/2020/05/24/parc-celebrates-50-years/
from Cedar and SmallTalk • Java innovations: stop the world collection, heap segmentation, safe points and write barriers • All picked up by C# • Strong compile-time and runtime checking • Borrowed from Cedar and Mesa • Sandbox model • Bytecode veri fi er
Machine (JVM) Speci fi cation • Each OS has own implementation • Similar approach adopted by C# • Microso ft Intermediate Language and Common Language Runtime (CLR)
ffi cient for interpretation • Just in Time (JIT) compiler • JIT compiler converts bytecode into native machine code at runtime • Not in Java 1.0 • But the design made room for it in future versions • C# 1.0 did ship with JIT compiler • …when it was released 6 years a ft er Java 1.0
• Allowed a high degree of interactivity for the end user • Threading model based on Cedar and Mesa • Classes loaded dynamically at runtime via the ClassLoader • C# uses reflection, assemblies, and optional dynamic typing instead
Robust and Secure 3. Architecture-Neutral and Portable 4. High Performance 5. Interpreted, Threaded, and Dynamic https://www.oracle.com/java/technologies/language-environment.html
{ this.value = value; } public void printValue() { Console.WriteLine($"Value: {value}"); } public void printType() { Console.WriteLine($"Type of T is: {typeof(T)}"); } }
intBox = new Box<int>(42); var stringBox = new Box<string>("Hello"); intBox.printType(); stringBox.printType(); intBox.printValue(); stringBox.printValue(); } }
people were going to use, I’d rather keep the hole with a label on it than do something I know is wrong.” James Gosling Faces of Open Source / Peter Adams
nish the language even though it had missing features… there was only about a three month window in which the whole Java phenomenon could have happened. We barely made it… [but] Bill was absolutely right about what Java needs long term.”
have to have conversations with people about how to do this, how to do that. If you do the wrong thing, people get very upset. Once upon a time it was just me, and if I wanted to make a major change to the language, it’d take 10 minutes.” James Gosling Faces of Open Source / Peter Adams
how, type information would be rei fi ed at runtime was a highly questionable proposition.” Brian Goetz, Java Language Architect at Oracle Photo courtesy of Devoxx Belgium 2023: https://www.flickr.com/photos/bejug/53236104163/in/album-72177720311726414
the given amount of java code in the world, and the given importance of backwards compatibility, by the given community, generics with type erasure was the choice
to run side by side • Had to recompile or manually cast to expected type • Adding generics to the CLR was a decision that only Microso ft had to make What about C#?
can ignore exceptions, but you have to wilfully do it. You can't accidentally say, "I don't care." You have to explicitly say, "I don't care.” James Gosling
erent places you handle exceptions and pop up error dialogs… That's just terrible. The exception handling should be centralised, and you should just protect yourself as the exceptions propagate out to the handler.” Anders Hejlsberg Photo: DBegley, CC BY 2.0, via Wikimedia Commons
memory fetch close to that of arithmetic operations • “Everything is an object” became • “Everything the user can de fi ne is an object” • 8 primitives The 1990s
of appalling” Brian Goetz at JVM Language Summit 2024 Photo courtesy of Devoxx Belgium 2023: https://www.flickr.com/photos/bejug/53236104163/in/album-72177720311726414
(Preview, Java 26?): Value Classes and Objects • Objects that lack identity, and consequentially optimised encodings • JEP 402: Enhanced Primitive Boxing • Allows primitives to be treated more like objects • JEP dra ft : Null-Restricted Value Class Types • Improves the performance of fi elds and arrays with null- restricted value class types • JDK-8303099: Null-Restricted and Nullable Types • Language support for null-aware types and runtime enforcement of null restrictions *plus many more JEPs with preparatory and supporting work
ware sucks • It’s annoying quirky • It’s evolving - albeit slowly • Healthy and mature ecosystem • It’s a product of decisions past • It’s still everywhere Does Java (Still) Actually Suck?