Script Java Easily in 21 and Beyond - Inside Java Newscast #49

preview_player
Показать описание
To give Java and programming beginners a better learning path, JEP 445 proposes to allow stand-alone main methods that are non-public, non-static, and don't have an args array, so the shortest possible Java program is just `void main()`. We're also looking at the JEP draft for _Launch Multi-File Source-Code Programs_ what builds out the late section of the on-ramp by allowing the Java launcher to in-memory compile and launch multiple source files, even with dependencies.

~~~ Chapters ~~~
0:00 Intro
1:36 A Relaxed Launch Protocol
2:54 The Unnamed Class
4:42 The On-Ramp
6:44 Outro

~~~ Resources ~~~

Tags: #Java #OpenJDK #JavaScript (because "scripting Java" 😋) #InsideJava
Рекомендации по теме
Комментарии
Автор

I entirely forgot to mention in the video that this is of course a preview feature and until it is final (so at least in Java 21, probably also 22), you'll need to add `--enable-preview --source 21` when using this.

nipafx
Автор

I know I have said something like this before on quite a few feature. We had to wait 28 years for this, but glad it is coming.

MeriaDuck
Автор

I can see that Java wants to implement the same features that exist in Kotlin, it's great 👍

erdusa
Автор

Maybe a stupid question : why is the class unnamed ? Why not taking the name of the file ? After all, today, the class name must match the file name right ? so why not give the name of the file to the class ?

osenseijedi
Автор

Hello everyone, why doesn’t java deepen its capabilities in writing machine code and working with memory like c ++, the technologies are developing at a tremendous speed and how we all see languages ​​​​like c and c ++ deeper and deeper․ Yes, I know about their vulnerabilities, but imagine that java is divided into two parts, 1. safe and 2. all powerful)) and they will be identical in syntax, which will facilitate both learning and creating a new language. Yes, it will not be easy, but it will not be unrealistic either, but java will make a revolution.
Thanks in advance for the answer.

segedilyan
Автор

Video title: Script Java
My brain: JavaScript?

fredoverflow
Автор

Curious that they didn't make "void" optional.

Joe_Brig
Автор

that's an amazing addition and I appreciate it. I dont want to point the polish, but if it is possible, please do not

farooqmss
Автор

That's cool, but what happens if you call the main method in a non-static way? Does the main method act statically for launch and non-statically for runtime? Can you even make a method non-static anymore if it's called main?

Also: *Please* keep the ! for boolean operations only and don't give it multiple different meanings as a Bang operator. That would make named conditions soo messy and unintuitive. I'd much rather prefer a new and descriptive keyword like "public *_primitive_* ClassName varName = value;"

PLEASE don't go the syntactic GoLang/Kotlin road. Stay clean, consistent and C-based.

Thank you for your consideration.

TheBigLou
Автор

When people talk about what they don't like about Java, a lot of people say that it's verbose. But now we see that in the recent years, it has been tackled so well that the complaint about its verbosity is going to be outdated pretty soon.

sen
Автор

you can also replace system.out.prinln("");into print only it will make more sense


we like
class HelloWorld{
void main(){
print("hello world);
}
}

-ritikjain
Автор

I started with C n couldn't get the fuss when this "class HelloWorld public static void main" etc came out to replace the programming community's language tool.

Dabayare
Автор

Main method really isn't a big deal, may it bring luck to new people coming into the ecosystem. Other communities are pretty solidified, e.g. C# so this won't win them over or reduce their social pressure applied via bashful remarks, which they do both for this and javascript community, java has an academic background, those are it's origins, so this change may bring in those that are making a shift to CS/IT.

matijacvrk
Автор

And now, in 2023, Java gets one step closer to Processing))

НиколайВетров-щб
Автор

It's an interesting update. But... I would rethink the combination of backlighting that makes it look like there's fire coming out of your pits with metallic-green nail polish. The result is a bit.... demonic...

bentels
Автор

Cool but, I would like a version java pass from system.out.println() to println() or some other simple as possible

alphadevperso
Автор

While we wait:

jbang --java 21 --enable-preview -c 'println("JBang works today and lets you use Java 8+, multiple files and dependencies. Will work great with JEP 445 too!");'

MaxRydahlAndersen
Автор

As always, Java slowly, but tries to keep up with C# :D

Morzelius
Автор

Basically, unnamed classes are a step towards having free funcitons in Java?

ingframin
Автор

I prefer the old way rather than this new one.

victorpinasarnault