Skip to content
DevMeme
4950 of 7590
Languages Post #5418 · source on Telegram

Java 21's Drastic Simplification of 'Hello, World!'

Description

The image presents a direct visual comparison of a basic 'Hello, World!' program written in Java 20 versus Java 21. The top half, labeled 'Java 20,' displays a dark-themed code editor window containing the traditional, verbose Java entry point: a `HelloWorld` class with a `public static void main(String[] args)` method. The bottom half, labeled 'Java 21,' shows the same program in a dramatically simplified form: just a `void main()` method containing the print statement, without the need for a class definition or the `public static` modifiers. This meme highlights JEP 445, a key feature in Java 21 that introduces unnamed classes and instance main methods. The goal is to lower the barrier to entry for new programmers by removing ceremonial boilerplate, making Java more approachable for teaching and simple scripting, much like Python or JavaScript

Comments

7
Anonymous ★ Top Pick Java 21 finally lets you write a 'Hello, World!' without first having to write a novel. Now, if you want to center a div in a GUI, you still need to implement three abstract factory patterns and consult a star chart
  1. Anonymous ★ Top Pick

    Java 21 finally lets you write a 'Hello, World!' without first having to write a novel. Now, if you want to center a div in a GUI, you still need to implement three abstract factory patterns and consult a star chart

  2. Anonymous

    Java 21 drops ‘public static void’, yet my Spring Boot container still needs 12 starters and @EnableEverything just to echo the same “Hello, World!” in 700 MB

  3. Anonymous

    After 25 years of explaining why "public static void main(String[] args)" isn't a magic incantation, Java finally admits it was just hazing the whole time

  4. Anonymous

    After two decades of explaining to beginners why they need 'public static void main(String[] args)' just to print a string, Java finally admitted that maybe - just maybe - requiring a full class declaration, access modifiers, static context, and array parameters for 'Hello World' was a *bit* much. Java 21's simplified main methods are essentially Oracle saying 'We've been gatekeeping with ceremony, and Python was right all along - but we'll never admit it publicly.'

  5. Anonymous

    Java 21 lets HelloWorld be two lines, but running it needs more --enable-preview flags than lines of code - boilerplate that migrated to the CLI

  6. Anonymous

    Java 21: Proving even enterprise JVMs can slim down after 25 years of bloat - Go devs, hold our coffee

  7. Anonymous

    Java 21 lets you write void main(), and then Maven reminds you the real ceremony now lives in the --enable-preview flags

Use J and K for navigation