
What Peak Hello World Looks Like - wh313
https://h313.info/blog/cpp/2020/05/17/this-is-what-peak-hello-world-looks-like.html
======
kragen
This task was a staple of early years of the IOCCC:

[https://www.ioccc.org/1992/lush.c](https://www.ioccc.org/1992/lush.c)

[https://www.ioccc.org/1989/jar.1.c](https://www.ioccc.org/1989/jar.1.c) (cf.
[https://www.ioccc.org/1989/jar.1.hint](https://www.ioccc.org/1989/jar.1.hint))

[https://www.ioccc.org/1986/applin/applin.c](https://www.ioccc.org/1986/applin/applin.c)

[https://www.ioccc.org/1986/holloway/holloway.c](https://www.ioccc.org/1986/holloway/holloway.c)

[https://www.ioccc.org/1985/applin/applin.c](https://www.ioccc.org/1985/applin/applin.c)

[https://www.ioccc.org/1984/anonymous/anonymous.c](https://www.ioccc.org/1984/anonymous/anonymous.c)

And this version, though too large to enter into the IOCCC, is not only valid
C, but is additionally valid as COBOL, Pascal, Fortran, PostScript, a shell
script, an MS-DOS .COM file, and Perl 5:
[https://ideology.com.au/polyglot/](https://ideology.com.au/polyglot/)

You may not like it, but...

P.S. if you liked this comment, you'll love
[https://news.ycombinator.com/item?id=23183383](https://news.ycombinator.com/item?id=23183383)!

~~~
prox
I lol’ed with

> This program is (supposedly) the smallest C program able to print "Hello
> world.". The compilation itself produces the desired printout and the
> program need not be actually run.

------
mkl
Oh, I think we can do better. C and bitwise operations are so 1980! Modern
Hello Worlds should use modern languages, functional programming, and data
science! Like so:

    
    
      import numpy as np
      
      x = np.array([0.03908342, 0.95362155, 0.95450865, 0.22260951, 0.35975305,
                    0.22841515, 0.3964834, 0.01782918, 0.05798498, 0.62697582,
                    0.69175475, 0.343705])
      y = np.array([0.28685259, 0.40239044, 0.43027888, 0.43027888, 0.44223108,
                    0.12749004, 0.47410359, 0.44223108, 0.45418327, 0.43027888,
                    0.39840637, 0.1314741])
      b = [lambda x, x0=x0: np.sqrt(.1+(x-x0)**2) for x0 in x]+[lambda x: 1., lambda x: x]
      a = np.array([[bb(xx) for bb in b] for xx in x]+[[1.]*12+[0., 0.], list(x)+[0., 0.]])
      c = np.linalg.solve(a, list(y)+[0., 0.])
      print(''.join(chr(int(c.dot(np.array([bb(xx) for bb in b]))*251.+.1)) for xx in x))

~~~
anyfoo
I see lists, '+' signs, even an 'sqrt' in there. This is _insane_. Why would
you ever use anything other than single-argumented lambdas in a python
program?
[http://www.cip.ifi.lmu.de/~oster/fac.html](http://www.cip.ifi.lmu.de/~oster/fac.html)

~~~
gsliepen
Ah yes Church Numerals... who needs ints when you can have those in C++?
[https://codegolf.stackexchange.com/a/190796/46301](https://codegolf.stackexchange.com/a/190796/46301)

------
macando
[https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris...](https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition)

FizzBuzz Enterprise Edition is a no-nonsense implementation of FizzBuzz made
by serious businessmen for serious business purposes.

~~~
LanceH
I have this:
[https://github.com/LanceH/fizzbuzz](https://github.com/LanceH/fizzbuzz) in my
back pocket just in case it is asked in an interview. I have the seed
memorized to put in last while they're wondering what in hell I'm doing.

If the interviewer can't handle my sense of humor, then I'm not working there.

~~~
brianpursley
This is awesome!

------
speakeron
I don't think any of these are particularly convoluted; they're in
straightforward procedural code with a line for each letter. Most programmers
could adapt the code to produce another string without too much effort.

What I'd consider convoluted is something like the Goodstein sequence[1] which
would grow to monstrous proportions using far more memory than could be stored
even if every particle in the universe represented one bit and far more time
than beyond when the last black hole has evaporated, yet collapsed down
(eventually) to "Hello World". (I've no idea how to do this.)

[1]
[https://en.wikipedia.org/wiki/Goodstein%27s_theorem](https://en.wikipedia.org/wiki/Goodstein%27s_theorem)

~~~
quickthrower2
Or even better “42”

------
rixrax
It occurred to me that this is maybe just marginally more unreadable than a
Hello world for Android or iOS or other desktops after all the boilerplate
code and resources has been added. And it still is easier to compile.

------
speedgoose
My attempt from many years ago in GWAAAAAAAH. A brainfuck like programming
language, for crazy rabbits where most characters are ignored and only for
style.

DAAAAAAAAAAhhhhhh ?

Rooooaaahahhahah!!

GAAAAAAAGAAAAAAAAAAGAAAGAWWWWOM!

GAAH!! GAH AAAAAAAH!

Haaaaaooa

BrrooaAAAH GAAH

WWAAAAAAAAAAAAAAAH!!!!!!!

GeeaaahH! AAAH

OOOOOOH

BlOOOOOOOOpppH

GAH! GobidoaaahH !

~~~
xwdv
Caps lock is uncouth here in hackernews, please tone it down to lowercase.

~~~
speedgoose
It's a yelling programming language. Lowercase characters are ignored.

~~~
xwdv
Put it in a code block then.

------
TheOtherHobbes
This seems kind of lightweight. There should surely be a web implementation
that uses Docker, k8s, React, Typescript, Node, MongoDB, AWS, and GitHub, and
still only works correctly in a specific version of IE8.

~~~
diffrinse
Or just Chrome

------
megavolcano
Reminds me of the Java version, Hello World Enterprise Edition

[https://gist.github.com/lolzballs/2152bc0f31ee0286b722](https://gist.github.com/lolzballs/2152bc0f31ee0286b722)

------
catblast
Good for a beginner effort, but its not really all that convoluted or
obfuscated. The problem is that 90% of the obfuscation is in the removal of
whitespace. Pretty print the final thing, and it isn't so bad (the 2nd to last
listing is pretty easy to follow). Things like 0-1 or 13*1 + 3, etc add some
noise but are not particularly hard to parse or understand, the ternary is
ugly but it's sequential so nothing up the sleeve there, the memcpy are just a
noisy one character assignment. The author should review the IOCCC submissions
posted earlier. Like holloway.c.

------
unnouinceput
This could be "improved" to make it get a sound "Hello World" instead of a
visual one. I mean it's still "Hello World" and I feel sound gets too little
credit versus graphics.

------
nkozyra
Is there a reverse of code golf? Code basketball?

Maybe that's just junior development.

~~~
ObsoleteNerd
“Code Survivor”.. Outwit, outlast, outplay. ;)

------
yesenadam
Should output "hello, world!\n" (Kernighan, _A Tutorial Introduction to the
Language B_ , 1972) or "hello, world\n" (Kernighan, _Programming in C: A
Tutorial_ 1974 and Kernighan/Ritchie, _The C Programming Language_ 1978).

[https://en.wikipedia.org/wiki/%22Hello,_World!%22_program](https://en.wikipedia.org/wiki/%22Hello,_World!%22_program)

------
Izkata
My personal favorite is Piet, where all programs are images:
[https://www.dangermouse.net/esoteric/piet/samples.html](https://www.dangermouse.net/esoteric/piet/samples.html)

------
nayuki
"The Evolution of a programmer":
[https://www.ariel.com.au/jokes/The_Evolution_of_a_Programmer...](https://www.ariel.com.au/jokes/The_Evolution_of_a_Programmer.html)

------
lern_too_spel
GNU Hello 2.10:
[http://git.savannah.gnu.org/cgit/hello.git/tree/](http://git.savannah.gnu.org/cgit/hello.git/tree/)

------
mkchoi212
My eye balls hurt after looking at the final version of hell world. But a job
very well done I must say. Could go even more insane with inline assembly but
I’ll wait for part two for that :)

------
larsrc
GNU Hello World is 700k as a .tar.gz:
[https://www.gnu.org/software/hello/](https://www.gnu.org/software/hello/)

------
nicetryguy
Ben Eater - “Hello, world” from scratch on a 6502 — Part 1

[https://www.youtube.com/watch?v=LnzuMJLZRdU](https://www.youtube.com/watch?v=LnzuMJLZRdU)

------
G4E
I like how there is the comment "you can't forget \0" for r[12] in the first
example... but he forget it in the second haha. You should use calloc in that
case !

------
nurettin
A simple standard C++ hello world introduces: functions, ctors, dtors,
headers, header guards (you are including headers right away), namespaces
(std, anonymous), operator overloading (<<), function overloading, pointer to
function (endl), templates, traits, locales, streams (basic_ostream),
lifetimes (cout), move operations, inheritance, static initialization (in
locales) and a bunch of other things I surely missed.

------
recursive
There's no limit to how many arrays you can xor together to get "Hello,
World!". They're all essential in the sense that removing any of them causes
the result to fail. I am interested in awkward and arbitrary code optimization
problems like code golf. But you can just take this one to infinity in a
number of different ways.

------
helsinkiandrew
Mention of HelloWorldFactoryFactoryFactorySingleton gives me panic attack
flashbacks to the nineties

------
RangerScience
Oh god, the convolution to recursive main switch? I am full of awe, it is so
awful.

------
random_visitor
Just my opinion but seeing how compiler behaves with each of them would have
been much more interesting, for now it's just a hacky-ish way of getting the
ascii codes.

------
7373737373
Here's mine:
[https://www.youtube.com/watch?v=lsaFmx5l7Hk](https://www.youtube.com/watch?v=lsaFmx5l7Hk)

------
MayeulC
The third code block has two `main` functions. This confused me a bit, but the
first one is likely a mistaken copy-paste from the final version.

~~~
wh313
Oops, thanks for pointing it out! I've fixed it now.

------
kervantas
It reminds me of JSFuck. [http://www.jsfuck.com/](http://www.jsfuck.com/)

------
tankenmate
Why is he using buffered IO? and why use malloc? why not use write() and
sbrk() like a real man?

~~~
Eridrus
We need to go deeper. This needs to be a kernel module that draws these pixels
directly to the display buffer.

~~~
im3w1l
If you are in text-mode it's very easy to display text
[https://wiki.osdev.org/Printing_To_Screen](https://wiki.osdev.org/Printing_To_Screen)

~~~
Eridrus
We're not trying to make this easy :) We need some computer vision code to
search the display buffer itself to find out where the terminal is and
figuring out where to draw the pixels!

------
vaibhavthevedi
My reaction to the code mentioned was similar to the favicon image :)

------
GEBBL
This is hilarious and I see how it could be used in a malicious context.

------
_nalply
I discovered a bug: the second example forgot the NUL byte.

------
QuarterDuplex
I don't see anything with rand/srand

------
davedx
I was expecting k8s and terraform in there...

------
kevin_thibedeau
Nitpick but NUL is not the same as null.

------
keithwhor
I believe peak Hello World is actually written in Chicken [0].

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken

> chicken chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken

> chicken chicken chicken chicken chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken chicken chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken chicken chicken chicken chicken

> chicken chicken chicken chicken

> chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken chicken chicken chicken chicken chicken

> chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken

> chicken chicken chicken chicken chicken chicken

> chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken chicken chicken

> chicken chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken chicken chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken chicken

> chicken chicken chicken chicken chicken chicken

> chicken chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken chicken chicken chicken chicken chicken chicken

> chicken chicken

> chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken

> chicken chicken chicken chicken chicken chicken

> chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken

> chicken chicken chicken chicken chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken

> chicken chicken chicken chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken

> chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken

> chicken chicken chicken chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken chicken

> chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken

> chicken chicken chicken chicken chicken chicken chicken chicken chicken
> chicken chicken

> chicken chicken chicken chicken chicken chicken

[0]
[https://esolangs.org/wiki/Hello_world_program_in_esoteric_la...](https://esolangs.org/wiki/Hello_world_program_in_esoteric_languages#Chicken)

~~~
nexuist
Was that the inspiration for this?
[https://isotropic.org/papers/chicken.pdf](https://isotropic.org/papers/chicken.pdf)

~~~
bostik
Both of those look like they were reading off of this:
[https://i.imgur.com/9MQv6z8.gif](https://i.imgur.com/9MQv6z8.gif)

I miss PLIF.

------
lkuty
This is one should be used in place of the traditional printf for beginners as
a way to learn C in one single shot.

