Hacker News new | past | comments | ask | show | jobs | submit login
What Peak Hello World Looks Like (h313.info)
169 points by wh313 on May 17, 2020 | hide | past | favorite | 75 comments



This task was a staple of early years of the IOCCC:

https://www.ioccc.org/1992/lush.c

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

https://www.ioccc.org/1986/applin/applin.c

https://www.ioccc.org/1986/holloway/holloway.c

https://www.ioccc.org/1985/applin/applin.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/

You may not like it, but...

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


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.


> 4. Keep the blank lines at the start of the program. They are important.

lol


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))


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


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


It needs a dataframe to qualify as DS...


Well, it fits a curve to some data, so I think it just counts.


But this could be just regular science. To be sure we need a dataframe...


Upgrade this from a linear system solve to a (perhaps Mixed Integer) Linear Program solution and then we're talking!


https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris...

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


I have this: 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.


This is awesome!


Cutesy reminder that regular fizzbuzz still filters out almost half of the candidates I receive for junior dev positions.

Some because they don't understand the requirements, some because they don't know how to use loops, some people they don't know how to use conditions, and yes some because they make overly complicated mess for no reason, or to try to be "super smart".


>because they make overly complicated mess

https://thedailywtf.com/articles/The-Fizz-Buzz-from-Outer-Sp...


Hah, I remember having no clue what was going on the first time I read that, but it clicked just now. The fizzbuzz problem as described in that paragraph could almost be interpreted as 3 equations. The math was for something along the lines of this problem:

  x = fizz / 3
  x = buzz / 5
  x = (fizz * buzz) / 15
In this system of 3 equations, what is "x"?

Not sure what's going on with the 1-100 though.


Enterprize FizzBuzz has been one of my favourite things for a while. It perfectly captures the attitude where I used to work, where people felt that by adding later upon layer of obfuscation they were doing engineering.


This was a lot more fun before Github started collapsing directories of one item!


That makes it more fun because you never know when the rabbit hole will end.


This is hilarious and eerily real world like.


Be sure to check out the issues, too :)


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


Or even better “42”


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.


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 !


There's also the very dead fckfck which just changed commands to cursewords.

https://web.archive.org/web/20040803070636/http://www.chilli...


Sounds like Lady Gaga song


It's supposed to sound like raving rabbids.


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


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


Put it in a code block then.



Can’t tell if this is a joke or you failed to read the comment you replied to.


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.


Or just Chrome


Reminds me of the Java version, Hello World Enterprise Edition

https://gist.github.com/lolzballs/2152bc0f31ee0286b722


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.


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.


Is there a reverse of code golf? Code basketball?

Maybe that's just junior development.


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


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


My personal favorite is Piet, where all programs are images: https://www.dangermouse.net/esoteric/piet/samples.html




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 :)


GNU Hello World is 700k as a .tar.gz: https://www.gnu.org/software/hello/


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

https://www.youtube.com/watch?v=LnzuMJLZRdU


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 !


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.


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.


Mention of HelloWorldFactoryFactoryFactorySingleton gives me panic attack flashbacks to the nineties


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


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.



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.


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


It reminds me of JSFuck. http://www.jsfuck.com/


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


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


If you are in text-mode it's very easy to display text https://wiki.osdev.org/Printing_To_Screen


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!


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


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


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


I don't see anything with rand/srand


I was expecting k8s and terraform in there...


Nitpick but NUL is not the same as null.


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...


Was that the inspiration for this? https://isotropic.org/papers/chicken.pdf


Both of those look like they were reading off of this: https://i.imgur.com/9MQv6z8.gif

I miss PLIF.


This is the most chicken shit code I've ever seen - and I used to make a living doing VB6+COM


mushroom mushroom


I think VerboseFuck wins


chicken chicken Buffalo buffalo buffalo buffalo chicken chicken


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




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: