share
Stack OverflowConvoluted hello world program
[+5] [7] Razor Storm
[2010-08-06 00:52:51]
[ language-agnostic hello-world ]
[ http://stackoverflow.com/questions/3420264/convoluted-hello-world-program ] [DELETED]

What's the most convoluted hello world program you can think of without any bogus lines? That means every single statement has to contribute to the overall program so you can't simply bloat it with useless declarations and the such.

Any language is ok, but using the esoteric nature of a language by itself does not count as convolution!

(1) This should be community wiki. - Borealid
(5) See gnu.org/software/hello - deinst
I'm torn on this one. It seems like an absolutely useless question but, since it is a specific programming problem as per the FAQ, I find myself unable to close. My first though is to just code in x86 using BIOS int10/ah=9. - paxdiablo
This should not have been closed -- what's being asked is entirely clear and understandable. It may be pointless, but no more so than most "code golf" questions (for one example). Unfortunately, most of the answers seem to have missed the part about an esoteric language, by itself, not counting -- the brainfuck program, for one example. - Jerry Coffin
(1) @paxdiablo: But how would that be anything but depending on the esoteric nature of the language? - Jerry Coffin
python.pastebin.com/KKcHBxPm - André Laszlo
People are not being creative here. Done right, you could include most of the C compiler as source code. - Joshua
(3) For the record, I closed this as "Subjective & Argumentative", since there simply isn't a definite answer. There's an absolute minimal way to do a Hello World in any given language, but there are infinite non-minimal ways to do it. Hence there's no real answer to this question, it can only spawn an infinite number of terrible code samples. Besides, this has been asked before and got closed just as quickly. - deceze
@deceze: while degree of obfuscation might be subjective, it doesn't strike me as particularly argumentative. - Jerry Coffin
(3) @Jerry It's impossible to objectively answer this question fits pretty well though. There's no "most convoluted" way to do anything, it's always possible to do it in an even more convoluted way. - deceze
@deceze A formal proof of your previous comment is a must here. Given P[n] the "most convoluted", construct a program that executes P[n] and call it P[n+1] :D - Verde
@belisarius, but that's operating under the assumption that P { Z which is faulty. At the very least convolution is constrained by virtual memory. :) - Razor Storm
@Razor Then this could be a question with a definite answer if you added some constraints. "Write a Hello World that uses as much memory as possible without crashing on an x86 with a hard limit of 1 GB of memory, assuming no operating system overhead, and no artificial inflation of memory usage." I am not interested in the answer though. ;-P - deceze
@Razor Ok, so construct a Bootstrap Loader for P[n] >D - Verde
This is basically a duplicate: stackoverflow.com/questions/483997/… - gnovice
[+5] [2010-08-06 01:07:46] Ryan Tenney [ACCEPTED]

Hello World in the Brainf**k language, hands down:

++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.

I absolutely agree that this is crazy convoluted. I understand the dude building a compiler that is less than 200 Bytes, but who in their right mind would EVER actually program using this. That's insane. - Chase Florell
It's an interesting exercise to say the least! - Ryan Tenney
This probably doesn't count. You're not really convoluting it, just using a convoluted language. Now if you were to translate this into C or assembler ... :P - Swizec Teller
(3) Translated into C - Ryan Tenney
@rock people actually submit SO [code-golf] solution in BrainF_ck... - dmckee
1
[+3] [2010-08-06 02:48:55] Jerry Coffin
#include<stdio.h>

char *c[] = { "OLD", "WALLOW", "HERE", " SWORE" };
char **cp[] = { c+3, c+2, c+1, c };
char ***cpp = cp;

main()
{
    printf("%.2s", **++cpp);
    printf("%.3s ", **++cpp+2);
    printf("%.3s", cpp[1][3]+2);
    printf("%s", *cpp[1]+1);
    printf("%c\n", *(*cpp[-2])+1);
    return 0;
}

This should be fairly portable beyond the fact that it requires something at least vaguely ASCII-like -- ASCII, ISO 8859-*, Unicode should all be fine, but with EBCDIC, I'm pretty sure you won't get the final exclamation point.


2
[+3] [2010-08-06 09:11:22] André Laszlo

:P

try:
    import httplib
except ImportError:
    import http.client as httplib
c = httplib.HTTPConnection("stackoverflow.com")
c.request("GET", "/questions/3420264/")
r = c.getresponse()
t = r.read()
import re
m = re.search("most convoluted (.*?) program", t)
import sys
sys.stdout.write(m.group(1))

3
[+2] [2010-08-06 01:01:22] ja72

Look into the IOCCC contest winners here [1] and search for the word hello. Lots of entries.

IOCCC = The International Obfuscated C Code Contest

[1] http://www0.us.ioccc.org/all/summary.txt

4
[+2] [2010-08-06 01:37:56] rdivilbiss
<script language="vbscript" runat="server">
Dim idx
Dim output
Dim regEx
Dim matches
Dim match
Dim tmp

idx = ""
output = ""
regEx = ""
matches = ""
match = ""
tmp = ""

Dim arr(10)
arr(0) = 72
arr(1) = 101
arr(2) = 108
arr(3) = 108
arr(4) = 111
arr(5) = 32
arr(6) = 87
arr(7) = 111
arr(8) = 114
arr(9) = 108
arr(10) = 100

Function getArrayValue(idx)
    If idx < 11 Then
        getArrayValue = arr(idx)
    End If  
End Function

Function getCharacterToWrite(idx)
    If (idx>0) AND (idx<12) Then
        getCharacterToWrite = Mid(output,idx,1)
    End If  
End Function


For idx = 0 To 10
    output = output & Chr(getArrayValue(idx))
Next

Set regEx = New RegExp
regEx.IgnoreCase = False
regEx.Global = True
regEx.pattern = "[a-zA-Z\ ]"

Set matches = regEx.Execute(output)
For Each match In matches
    tmp = tmp & match.value
Next

If tmp = output Then
    For idx = 1 to 11
        Response.Write(getCharacterToWrite(idx))
    Next
    Response.Write vbCRLF
End If
</script>

(1) looks like someone was having some fun - Chase Florell
5
[+1] [2010-08-06 01:02:59] Tahbaza

Build a character array; maybe even forcing match to a numeric sequence corresponding to the letters of the alphabet (8 5 12 12...) to build HELLO WORLD. You can even convolute the output methodology by writing to a buffer in memory and then writing the buffer to the output stream.


6
[+1] [2010-08-06 01:06:45] Swizec Teller

Take a hello world program written in ... let's say brainfuck, but any stack-based language will do.

Translate said program into pure C. And no, I seriously do not feel like writing that by hand right now, but the idea is to use a stack instead of normal variables and to have the whole alphabet stored at the bottom of said stack as well. Then using the combination of those to write out "Hello world".


ha! never heard of that language before. - makerofthings7
7