Most active commenters
  • saagarjha(8)
  • pjmlp(5)
  • troymc(3)

←back to thread

Java Hello World, LLVM Edition

(www.javaadvent.com)
200 points ingve | 29 comments | | HN request time: 0.247s | source | bottom
1. troymc ◴[] No.46181738[source]
I made a poster showing how one might write a Hello World program in 39 different programming languages, and even different versions of some common languages like Java:

https://troymcconaghy.blog/2025/01/13/39-hello-world-program...

replies(4): >>46181790 #>>46181936 #>>46182649 #>>46183494 #
2. throwaway150 ◴[] No.46181790[source]
Cool poster! If you don't mind me asking, would you share what tools you use to create this poster? You've got syntax highlighting going on there too. What did you use for that?
replies(1): >>46181877 #
3. iTokio ◴[] No.46181877[source]
You just have to read his blog, it is short and he answered everything.

> he used python and xelatex

> https://github.com/ttmc/hello-world-ways

replies(1): >>46182192 #
4. pron ◴[] No.46181936[source]
Nice, but as of JDK 25 (the preview JEP 445 has become the permanent JEP 512), the canonical Hello World in Java is:

    void main() {
        IO.println("Hello World");
    }
replies(3): >>46182156 #>>46184122 #>>46188449 #
5. troymc ◴[] No.46182156[source]
Thanks, I made a note to update that someday.
6. troymc ◴[] No.46182192{3}[source]
Yep, and for syntax highlighting, I used the minted package [1]. Internally, minted uses the Pygments library [2].

[1] https://ctan.org/pkg/minted

[2] https://pygments.org/

replies(1): >>46182314 #
7. throwaway150 ◴[] No.46182314{4}[source]
Thanks!
8. pmdr ◴[] No.46182649[source]
Objective C is by far the weirdest on that list.
replies(2): >>46184102 #>>46188470 #
9. realo ◴[] No.46183494[source]
This is super cool! Now someone should make a similar poster with Hello World sent to a serial port.

Bonus points if it is a RS485 port.

Some language that seem to look good might show their true ugly face...

10. watersb ◴[] No.46184102[source]
Smalltalk, but in C
11. prmoustache ◴[] No.46184122[source]
Not a java developer but why the void? Shouldn't your main function and program return an integer?
replies(2): >>46184384 #>>46184677 #
12. tadfisher ◴[] No.46184384{3}[source]
I believe that is a C-ism, where the C runtime calls your main() and exits the process with the return value. The Java equivalent is System.exit(int status).
13. gavinray ◴[] No.46184677{3}[source]
The return type of a Java main is the JVM platform return type

Sending system signals is external to the JVM platform

14. saagarjha ◴[] No.46188449[source]
Since it seems like you work on Java, would you mind taking a look at https://bugs.java.com/bugdatabase/view_bug?bug_id=JDK-836673..., where this syntax does not work for shebangs?
15. saagarjha ◴[] No.46188470[source]
Objective-C is basically Java so I wouldn’t call it that weird.
replies(1): >>46188475 #
16. gnabgib ◴[] No.46188475{3}[source]
Objective-C is significantly (11 years) older than Java.

1984: https://en.wikipedia.org/wiki/Objective-C

1995: https://en.wikipedia.org/wiki/Java_(programming_language)

replies(1): >>46188529 #
17. saagarjha ◴[] No.46188529{4}[source]
Correct, Java was designed with a strongly influence from Objective-C.
replies(1): >>46188549 #
18. gnabgib ◴[] No.46188549{5}[source]
One might even say Java is basically Objective-C
replies(2): >>46189835 #>>46189853 #
19. saagarjha ◴[] No.46189835{6}[source]
No, Java never took anything good from the language.
replies(1): >>46189860 #
20. pjmlp ◴[] No.46189853{6}[source]
Kind of, but with C++ syntax to make it more appealing,

https://cs.gmu.edu/~sean/stuff/java-objc.html

21. pjmlp ◴[] No.46189860{7}[source]
Sun folks disagree,

https://cs.gmu.edu/~sean/stuff/java-objc.html

https://en.wikipedia.org/wiki/Distributed_Objects_Everywhere

Sure, they could have taken a bit more, like proper AOT instead of it being a feature only available in third party commercial JDKs, or some low level niceties like C#.

replies(1): >>46190156 #
22. saagarjha ◴[] No.46190156{8}[source]
I was talking about good parts of the language
replies(1): >>46190182 #
23. pjmlp ◴[] No.46190182{9}[source]
Like [] and @ all over the place, C lack of safety, and manual memory management?

Because I don't see what else good Java has left out, besides AOT in the box and unsigned types.

replies(1): >>46190627 #
24. saagarjha ◴[] No.46190627{10}[source]
Uh, the entire runtime?
replies(2): >>46191360 #>>46195890 #
25. pjmlp ◴[] No.46191360{11}[source]
I beg to differ, given the engineering effort that went into JVM across various Java vendors, versus Apple and NeXT have done.

Proven by the fact that Swift had to be invented, as there was nothing left to fix Objective-C in a proper way.

replies(1): >>46191937 #
26. saagarjha ◴[] No.46191937{12}[source]
Swift has that runtime, by the way.
replies(1): >>46193584 #
27. pjmlp ◴[] No.46193584{13}[source]
Nope, Swift interops with Objective-C runtime to ease code migration from legacy Objective-C code, and existing Apple frameworks predating Swift.

A runtime that isn't part of the cross-platform Swift project, with missing functionality being rewriten into Swift.

replies(1): >>46215989 #
28. jeberle ◴[] No.46195890{11}[source]
I would look to the UCSD p-System as a precedent to the JVM. Both are byte-code interpreted VMs. Gosling used the p-system earlier in his career, prior to joining Sun.

https://en.wikipedia.org/wiki/James_Gosling#Career_and_contr...

The Objective-C runtime is very small: just enough to do late-bound fn calls to a tree of class defs. All on top of C.

29. saagarjha ◴[] No.46215989{14}[source]
Yes, and those platforms are worse off for it.