LiamTheBox@lemmy.world to Greentext@sh.itjust.works · 1 month agoAnon tries programming in Javalemmy.worldimagemessage-square47fedilinkarrow-up110arrow-down10
arrow-up110arrow-down1imageAnon tries programming in Javalemmy.worldLiamTheBox@lemmy.world to Greentext@sh.itjust.works · 1 month agomessage-square47fedilink
minus-squarelurklurk@lemmy.worldlinkfedilinkarrow-up0·1 month ago 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
minus-squareJackbyDev@programming.devlinkfedilinkEnglisharrow-up0·1 month agoThis 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: No compilation step. No class declaration. Main method is not public static 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.
minus-squarecashew@lemmy.worldlinkfedilinkarrow-up0·edit-21 month agoMicrosoft Java is a one-liner these days. > cat program.cs Console.WriteLine("Hello, World!"); > dotnet run Hello, World!
$ 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
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:
public static
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.
Microsoft Java is a one-liner these days.
> cat program.cs Console.WriteLine("Hello, World!"); > dotnet run Hello, World!