this post was submitted on 13 Nov 2024
835 points (96.1% liked)

Greentext

4430 readers
1003 users here now

This is a place to share greentexts and witness the confounding life of Anon. If you're new to the Greentext community, think of it as a sort of zoo with Anon as the main attraction.

Be warned:

If you find yourself getting angry (or god forbid, agreeing) with something Anon has said, you might be doing it wrong.

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] lurklurk@lemmy.world 28 points 1 week ago (25 children)

Hello World

30 minutes of boilerplate

writing imports

$ cat <<EOF > Hello.java
public class Hello {
  public static void main(String args[]) {
    System.out.println("Hello world!");
  }
}
EOF
$ java Hello.java
Hello world!

ok

[–] JackbyDev@programming.dev 7 points 6 days ago (9 children)

This is getting a little better nowadays.

> cat Hello.java
void main() {
    System.out.println("Hello, World!");
}
> java --enable-preview Hello.java
Hello, World!

Things to notice:

  1. No compilation step.
  2. No class declaration.
  3. Main method is not public static
  4. No String[] args.

This still uses preview features though. However, like you demonstrated already, compilation is no longer a required step for simplistic programs like this.

[–] cashew@lemmy.world 3 points 6 days ago* (last edited 6 days ago) (1 children)

Microsoft Java is a one-liner these days.

> cat program.cs
Console.WriteLine("Hello, World!");
> dotnet run
Hello, World!
load more comments (7 replies)
load more comments (22 replies)