OpenJDK proposal would make Java easier to learn

OpenJDK proposal would make Java easier to learn

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

Credit: Robert Shunev

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.


Show Comments