9 ms·
What Peak Hello World Looks Like
- rixrax 6y agoIt 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.
- kragen 6y agoThis 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!
- oconnor663 6y ago> 4. Keep the blank lines at the start of the program. They are important. lol
- prox 6y agoI 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.
- keithwhor 6y agoI 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_languages#Chicken https://esolangs.org/wiki/Hello_world_program_in_esoteric_la...
- speedgoose 6y agoMy 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 !
- klohto 6y agoSounds like Lady Gaga song
- speedgoose 6y agoIt's supposed to sound like raving rabbids.
- xwdv 6y agoCaps lock is uncouth here in hackernews, please tone it down to lowercase.
- speedgoose 6y agoIt's a yelling programming language. Lowercase characters are ignored.
- xwdv 6y agoPut it in a code block then.
- spartas 6y agohttp://bash.org/?835030 http://bash.org/?835030
- stallmanite 6y agoCan’t tell if this is a joke or you failed to read the comment you replied to.
- 6y ago
- speakeron 6y agoI 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 6y agoOr even better “42”
- random_visitor 6y agoJust 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.
- MayeulC 6y agoThe 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 6y agoOops, thanks for pointing it out! I've fixed it now.
- RangerScience 6y agoOh god, the convolution to recursive main switch? I am full of awe, it is so awful.
- GEBBL 6y agoThis is hilarious and I see how it could be used in a malicious context.
- nkozyra 6y agoIs there a reverse of code golf? Code basketball? Maybe that's just junior development.
- ObsoleteNerd 6y ago“Code Survivor”.. Outwit, outlast, outplay. ;)
- G4E 6y agoI 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 !
- helsinkiandrew 6y agoMention of HelloWorldFactoryFactoryFactorySingleton gives me panic attack flashbacks to the nineties
- tankenmate 6y agoWhy is he using buffered IO? and why use malloc? why not use write() and sbrk() like a real man?
- Eridrus 6y agoWe need to go deeper. This needs to be a kernel module that draws these pixels directly to the display buffer.
- im3w1l 6y agoIf 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 6y agoWe'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!
- nicetryguy 6y agoBen Eater - “Hello, world” from scratch on a 6502 — Part 1 https://www.youtube.com/watch?v=LnzuMJLZRdU https://www.youtube.com/watch?v=LnzuMJLZRdU
- macando 6y agohttps://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris... FizzBuzz Enterprise Edition is a no-nonsense implementation of FizzBuzz made by serious businessmen for serious business purposes.
- murukesh_s 6y agoThis is hilarious and eerily real world like.
- vimslayer 6y agoBe sure to check out the issues, too :)
- glxxyz 6y agoEnterprize 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.
- erichurkman 6y agoThis was a lot more fun before Github started collapsing directories of one item!
- canjobear 6y agoThat makes it more fun because you never know when the rabbit hole will end.
- nolok 6y agoCutesy 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".
- TheOtherHobbes 6y agoThis 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 6y agoOr just Chrome
- lkuty 6y agoThis is one should be used in place of the traditional printf for beginners as a way to learn C in one single shot.
- davedx 6y agoI was expecting k8s and terraform in there...
- catblast 6y agoGood 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.
- _nalply 6y agoI discovered a bug: the second example forgot the NUL byte.
- megavolcano 6y agoReminds me of the Java version, Hello World Enterprise Edition https://gist.github.com/lolzballs/2152bc0f31ee0286b722 https://gist.github.com/lolzballs/2152bc0f31ee0286b722
- yesenadam 6y agoShould 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
- lern_too_spel 6y agoGNU Hello 2.10: http://git.savannah.gnu.org/cgit/hello.git/tree/ http://git.savannah.gnu.org/cgit/hello.git/tree/
- mkl 6y agoOh, 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))
- nxpnsv 6y agoIt needs a dataframe to qualify as DS...
- math_and_stuff 6y agoUpgrade this from a linear system solve to a (perhaps Mixed Integer) Linear Program solution and then we're talking!
- anyfoo 6y agoI 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
- recursive 6y agoThere'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.
- kervantas 6y agoIt reminds me of JSFuck. http://www.jsfuck.com/ http://www.jsfuck.com/
- 7373737373 6y agoHere's mine: https://www.youtube.com/watch?v=lsaFmx5l7Hk https://www.youtube.com/watch?v=lsaFmx5l7Hk
- unnouinceput 6y agoThis 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.
- mkchoi212 6y agoMy 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 :)
- QuarterDuplex 6y agoI don't see anything with rand/srand
- nayuki 6y ago"The Evolution of a programmer": https://www.ariel.com.au/jokes/The_Evolution_of_a_Programmer.html https://www.ariel.com.au/jokes/The_Evolution_of_a_Programmer...
- Izkata 6y agoMy 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
- larsrc 6y agoGNU Hello World is 700k as a .tar.gz: https://www.gnu.org/software/hello/ https://www.gnu.org/software/hello/
- nurettin 6y agoA 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.
- kevin_thibedeau 6y agoNitpick but NUL is not the same as null.
- vaibhavthevedi 6y agoMy reaction to the code mentioned was similar to the favicon image :)