Paul Krill
Editor at Large

OpenJDK proposal would make Java easier to learn

news
Apr 12, 20232 mins

Flexible main methods and anonymous main classes would help students write basic programs much more concisely and reduce the ceremony of writing simple programs.

shutterstock 1175637019 learning to ride a bike training wheels
Credit: Waridsara_HappyChildren / Shutterstock

Java would become easier for students to learn under a proposal to introduce flexible main methods and anonymous main classes to the language. This is a preview language feature, disabled by default, that can be tried in JDK 21.

Java Enhancement Proposal (JEP) 445 in the OpenJDK open source Java community would evolve Java so that students could write their first programs without having to understand language features designed for large programs. Students could write streamlined declarations for single-class programs and then seamlessly expand programs to use more advanced features as their skills grow, the proposal states.

Goals of the plan include offering a smooth on-ramp to Java for educators to gradually introduce programming concepts, helping students write basic programs, and reducing the ceremony of writing simple programs such as scripts and command-line utilities. The plan would not introduce a separate beginner’s dialect of Java or a separate beginner’s toolchain.

Details of the plan include enhancing the protocol by which Java programs are launched to be flexible, in particular to allow the String[] parameter of main methods to be omitted and allow main methods to be neither public nor static; the Hello World program would be simplified. Anonymous main classes would be introduced to make the class declaration implicit.

The proposal notes that Java, while a multi-paradigm language designed for large and complex applications, was not intended to be a first programming language. Motivating the proposal are intentions to reduce ceremony, help new programmers, and offer a smooth on-ramp to Java that allows educators to introduce programming concepts in a gradual manner.

The current version of standard Java, Java Development Kit 20, was introduced last month. The next version, JDK 21, is due in September. JEP 445 shows how to try the preview features in JDK 21, which involves compiling the program with the javac compiler or using the source code launcher.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author