Take the 2-minute tour ×
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

Your goal is to write "Hello, World!" (minus the quotes). This is a , so most up votes wins. Code length will be used to break ties.
Anything goes, as long as it is within the following rules:

  • All characters must be either letters or numbers, so you may only use characters in the string "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".
  • All code you use must be in one file, with the exception of imported modules/classes/whatever they're called in your favourite language.
  • Only the standard libraries/frameworks for your language of choice are allowed (for example, Python's Math module is allowed, but Numpy, Scipy, and Pygame are not). I will allow TkInter as it is the de facto standard for GUIs in Python.
  • No input is permitted, be it reading from stdin, reading a file, displying an image, or reading from the web.

+10 brownie points if you figure out how to do it in Java without bending the rules.


On your marks, get set, code!

EDIT: braces ({}), brackets ([]), and parentheses (()) are allowed as this would be pretty much impossible for most languages without them. I'm also removing the character limit rule. Hopefully this will make it more interesting.

EDIT^2: white space is also allowed. My brain isn't working properly, sorry. >.<

share|improve this question
1  
Up to you, I'm just making sure. What about whitespace? –  Geobits Mar 5 at 14:04
1  
Oh, right white space. My brain is clearly not functioning properly today. That should be allowed. One second, let me fix the rules. –  Tungsten Mar 5 at 14:15
7  
So, no operators? And, most importantly, no ;? How can I write anything in C? –  Oberon Mar 5 at 14:22
1  
esolangs.org Hello, World! –  Geobits Mar 5 at 22:41
3  
+1 for figuring out how to exclude J in a natural way: 72 101 108 108 111 44 32 87 111 114 108 100 33{a. requires the period at the end to work, and a path through u: similarly requires a colon. Without . and : we are nothing. –  algorithmshark Mar 5 at 23:32

53 Answers 53

Perl

Some say perl is a language full of ascii noise and random symbols like $... That is not true :P

s zzHelloq worldmz and s zqzchr 44ze and s zmzchr 33ze and print
share|improve this answer
27  
+1 I don't know what the hell is going on here, but it works! –  squeamish ossifrage Mar 5 at 19:23
63  
@squeamishossifrage That could be the perl motto –  mniip Mar 5 at 19:54
5  
If you could, would you add a small explanation? –  ace Mar 5 at 22:21
9  
I'm by no means an expert, but in perl a replacement is usually indicated by s/PATTERN/REPLACEMENT/FLAGS, but you can actually use most anything you want instead of the slashes. The code here uses "z" instead of slashes and turns (nothing) into "Helloq Worldm" then replaces "q" for chr 44 (using the \e flag to evaluate REPLACEMENT aka "chr 44" as an expression) which is ",". It then replaces "m" with chr 33, a "!", and prints it. –  Amory Mar 6 at 0:20
2  
@ace in a quote-like operator, e.g q//, any delimiter can be used, q!! q** q\\ q;;. A few exceptions are that to close ( you use ), q() q[] q{} q<>, and that to use an alphanumeric as a delimiter, it should be spaced from the operator to disallow ambiguity, eg q qq, q 66. The same tricks apply to other quote-like operators. –  mniip Mar 6 at 9:57

C

int main(void) {
  if (putchar(72))
    if (putchar(101))
      if (putchar(putchar(108)))
        if (putchar(111))
          if (putchar(44))
            if (putchar(32))
              if (putchar(87))
                if (putchar(111))
                  if (putchar(114))
                    if (putchar(108))
                      if (putchar(100))
                        if (putchar(33)) 
                        {
                        }
}
share|improve this answer
4  
Awesome! It CAN be done in C. And I thought I'd won this... –  steveverrill Mar 5 at 21:42
2  
@ace Only if you have cases defined. You can easily rewrite this as switch(putchar(72)){}switch(putchar(101)){}, etc. –  Comintern Mar 5 at 23:56
16  
+1 for putchar(putchar(108)) –  Ilmari Karonen Mar 6 at 7:54
2  
Just missing an "if(putchar(44))" for the comma. –  Desty Mar 6 at 13:07
1  
Well spotted, not sure how I missed the comma in the question. Fixed. –  mattnewport Mar 6 at 15:41

(edit - BBC basic moved to separate answer as suggested. Most of the votes on this are definitely for the LOGO answer.)

LOGO

Interpreter at http://www.calormen.com/jslogo/#

TO h        pd  fd 100 rt  90  pu  fd 50  rt 90  pd  fd 100  rt 180 fd 50  lt 90  fd 50  rt 90  pu END 
TO e        pu  fd 25  rt  90  pd  fd 25  rt 90  arc 270 25  lt 90  fd 25  lt 90  pu END  
TO l        pd  fd 100 pu  END  
TO o        rt  45 fd  35  pd  arc 360 25  lt  45  pu END 
TO comma    pd  rt 90  arc 90  15  lt  90  pu END 
TO w         l  rt 180 l   pd  lt  135 fd  35  rt  90  fd 35  lt 135  l  END  
TO r        pd  fd 25  rt  90  pu  fd  25  rt 180  arc 180 25 rt 90 END 
TO d         o  rt 135 fd  35  lt  135  l  END      
TO exclaim arc 360 5   fd  10  l  END 

clearscreen  
setpencolor 4 pu 
setxy 0 150      h 
setxy 100 150    e  
setxy 200 150    l 
setxy 250 150    l 
setxy 300 150    o 
setxy 350 150    comma  
setpencolor 1 
setxy 0 0        w 
setxy 100 0      o 
setxy 200 0      r  
setxy 300 0      l 
setxy 350 0      d 
setxy 450 0      exclaim 
fd 100

Output (the green triangle is the turtle cursor)

enter image description here

share|improve this answer
2  
You should split this answer into two. –  Quincunx Mar 5 at 19:11
5  
+1 for pure genius of using LOGO! –  WallyWest Mar 6 at 0:46
    
@WallyWest I hardly know the language, but it was the tool for the job. You can print text too (it's called a label on your drawing) but you need a quotation mark for that (I think only the opening quote is required and the closing quote is optional.) –  steveverrill Mar 6 at 1:01
1  
+1 for drawing it instead of printing words. –  Tungsten Mar 7 at 17:58
    
@steveverril The second quote would be a syntax error, actually. –  tomsmeding May 21 at 15:01

Applescript

No brackets [], braces {} or parentheses () at all in this one:

set s to ASCII character 72
set s to s as list
set end of s to ASCII character 101
set end of s to ASCII character 108
set end of s to end of s
set end of s to ASCII character 111
set end of s to ASCII character 44
set end of s to space
set end of s to ASCII character 87
set end of s to item 5 of s
set end of s to ASCII character 114
set end of s to third item of s
set end of s to ASCII character 100
set end of s to ASCII character 33
display dialog s as text

Output is: enter image description here

share|improve this answer
6  
Unbelievable! (Having to write the word "character" in full, I mean!) Now I understand what they mean about Apples being expensive. Only joking, +1 for something different :-) –  steveverrill Mar 5 at 23:52
5  
AppleScript is ridiculously verbose, but the result is it really is one of the most comprehensible programming languages for a layperson. –  Jonathan Van Matre Mar 6 at 4:40
3  
@JonathanVanMatre Hard to write, easy to read –  DigitalTrauma Mar 6 at 4:53
2  
even C is easier to read... –  Sarge Borsch Mar 10 at 11:41
1  
@NicolasBarbulesco Well strictly written it's impossible in Java. You can't change the type of a variable at runtime. However, I would prefer List<String> s = new ArrayList<String>(); s.add(oldS); ANY DAY. I know exactly what that does when I read it. It makes a list, and puts something in it. –  Cruncher May 15 at 13:28

Bash

This sort of works, if you squint your eyes:

echo NN i NN i i i iNN NNi i i i i i i NN i NN i i i i i i i NNi i i NN NN
echo NN i NNi i i i NN NN i i i i i i iNN i NN i i i i i i i NN i i iNN NN
echo NN i NN iNNNNi NN NN iNNNNi i i i NN i NN iNNNNi NN NN iNN iNNN NN NN
echo NNNNNNN NN iNN NN NN NN iNN i i i NN i NN NN iNN NNN iN NN NN iNNN N
echo NN i NN NNNNNN NN NN NNi NN i i i NN N NN NNi NN NN i i NN NNi iNN N
echo NN i NN NN i i NN NN NN iNN i i i NNN NNN NN iNN NN i i NN NN i NN
echo NN i NN iNNNi iNN NN iNNNNi N i i NN i NN iNNNNi NN i i NN iNNNN N NN
echo i i i i i i i i i i i i i i N
share|improve this answer
1  
this works in windows bat/cmd file too –  Lưu Vĩnh Phúc Mar 10 at 5:45
    
banner Hello World or figlet Hello World –  professorfish Jun 15 at 19:46
    
@professorfish The tricky part of this challenge is getting the , and !. Otherwise, I'd just use plain old echo. –  DigitalTrauma Jun 16 at 16:49
    
@DigitalTrauma oh, sorry, didn't see that... a bit slow –  professorfish Jun 16 at 18:23

COBOL

   ID DIVISION 
   DATA DIVISION 
   01  HELLOWORLDBINARY 
       05  HE                       COMP    PIC 9999 
       05  LL                       COMP    PIC 9999 
       05  OCOMMA                   COMP    PIC 9999 
       05  SPACEW                   COMP    PIC 9999 
       05  ORTEXT                   COMP    PIC 9999 
       05  LD                       COMP    PIC 9999 
       05  EXCLAMATION              COMP    PIC 9999 
   01  FILLER REDEFINES HELLOWORLDBINARY 
       05  HELLOWORLDTEXT                   PIC XXXXXXXXXXXXX
       05  FILLER                           PIC X 
   PROCEDURE DIVISION 
       MOVE 51333                   TO HE 
       MOVE 37779                   TO LL 
       MOVE 38507                   TO OCOMMA 
       MOVE 16614                   TO SPACEW 
       MOVE 38553                   TO ORTEXT 
       MOVE 37764                   TO LD 
       MOVE 23104                   TO EXCLAMATION 
       DISPLAY HELLOWORLDTEXT 
       GOBACK 

Required some changes to become truly alphanumeric source only.

PROGRAM-ID can be dropped. You get a generated program name (see messages).

WORKING-STORAGE can be dropped. Again the compiler moans.

Since both of these lines previously had missing full-stops/periods, which are no longer relevant now that the descriptions are entirely missing, the number of error messages is the same as before, and still does not affect the generated code for the program.

In changing COMP-5 to COMP, the VALUE clauses are no longer allowed, as COMP 9999 is only four decimal digits whereas COMP-5 is a two-byte binary with all bit-values available.

The values in the MOVEs are the decimal values which give the binary values which give the pairs of characters.

Even though the COMP fields have four digits, and do not allow VALUE clauses with more than four digits, you can use more digits in the MOVE of a literal value without truncation at that point... don't ask me why. Compiler option DIAGTRUNC (which I have turned off) will produce Warning diagnostics for these.

Compiler option TRUNC(BIN) could be used to treat COMP as COMP-5, but the MOVEs are another way to do it.

Since it is COBOL, the output must be in UPPER CASE (a lie, but just for fun).

HELLO WORLD!

OK, relented, now produces:

Hello, World!

Which, being an odd-number of characters, required some further changes, since we can't have odd-number-byte binary fields with this compiler. Look at that line of 13 Xs! It would normally be written as X(13), but can be as I've shown...

And ORTEXT is needed (or not OR, anyway) as a name because OR is a reserved word to the compiler (it means OR, of course).

These are EBCDIC values, not ASCII, since it is running on an EBCDIC-aware, and Big Endian, box.

Oh, COBOL requires lots of full-stops/periods. I left them out (they're banned) so got lots of compile messages. Just told the compiler to generate the code anyway (none of the messages relate to the object code).

Even without DIAGTRUNC, the messages are now up to 17...

  1  IGYDS1003-E   A "PROGRAM-ID" paragraph was not found. 
  Program-name "CBLNAM01" was assumed. 

  2  IGYDS1082-E   A period was required.  A period was assumed 
  before "DATA". 

  3  IGYDS1082-E   A period was required.  A period was assumed 
  before "01". 

                   Same message on line:     11 

  3  IGYDS1040-E   A data item was found in the "DATA DIVISION" 
                   before a section header was encountered. 
                   "WORKING-STORAGE SECTION" was assumed. 

  4  IGYDS1082-E   A period was required.  A period was assumed 
  before "05". 

                   Same message on line:      5      6      7      8
                   9     10     12     13 

 14  IGYDS1082-E   A period was required.  A period was assumed 
 before "PROCEDURE". 

 15  IGYPS2145-E   A period was required.  A period was assumed 
 before "MOVE". 

 23  IGYSC1082-E   A period was required.  A period was assumed 
 before "END OF PROGRAM". 
share|improve this answer
1  
I don't think - is allowed –  mniip Mar 5 at 19:00
1  
Good point. Fixing. Habits. –  Bill Woodger Mar 5 at 19:06
    
@mniip Mmmm.... a little more tricky... I'll have to fix up the WORKING-STORAGE later. I have to leave now... –  Bill Woodger Mar 5 at 19:09
    
@mniip Fixed now. Thanks. –  Bill Woodger Mar 5 at 22:07
1  
I laughed at "Since it is COBOL, the output must be in UPPER CASE". Nice work! –  Jonathan Van Matre Mar 13 at 16:56

Polyglot: HQ9+, H9+, HQ9++, CHIQRSX9+, HQ9+B and HQ9+2D (1 byte)

H

Thank you @victor for the list of languages.

share|improve this answer
4  
This is a polyglot. It works too in H9+, HQ9++, CHIQRSX9+, HQ9+B and HQ9+2D. –  Victor Mar 6 at 4:43
    
I'm pretty sure it also works in Hello. –  Tungsten Mar 7 at 17:15
3  
It works in any language that you invent. –  Sampriti Panda Mar 7 at 17:16
1  
I didn't invented anything... –  Ismael Miguel Mar 7 at 18:14
2  
Unfortunately the output is "hello, world" (esolangs.org/wiki/HQ9%2B), or according to this interpreter "Hello world." (almnet.de/esolang/hq9plus.php) To get "Hello, world!" you might need to increment the accumulator a few times. –  tttppp Mar 10 at 10:03

Python

So what, we just assume everybody reads horizontally? For those users who like to read vertically:

print chr(72) 
print chr(101)
print chr(108)
print chr(108)
print chr(111)
print chr(44)
print chr(32)
print chr(87)
print chr(111)
print chr(114)
print chr(108)
print chr(100)
print chr(33)
share|improve this answer
    
+1 and hahaha! This question had so many downvotes at the beginning, because people believed it was impossible. I don't know Python, but given all the moaning I couldn't believe it was THAT easy in such a common language. –  steveverrill Mar 5 at 19:44
1  
I just wrote the exact same code before this answer was posted. I refreshed to post my answer and found this... –  grovesNL Mar 5 at 19:45
1  
@steveverrill The moaning wasn't for no reason. There's not a single answer here that would have passed the original rules (no braces/parens/brackets, no characters repeated more than once) –  Geobits Mar 5 at 19:47
1  
@grovesNL If it makes you feel better, this is the first thing I've ever used python for. I spent a while combing through docs, trying to figure out if there was any feasible way to concat them into one line before posting. –  Geobits Mar 5 at 19:48
    
@Geobits sys.stdout.write is the standard way to output text without newlines in most versions on Python (the behavior is slightly changed in 3.0). We can't do that here because of the periods. –  grovesNL Mar 5 at 20:05

Ruby (using only alnums and whitespace)

putc 72
putc 101
putc 108
putc 108
putc 111
putc 44
putc 32
putc 87
putc 111
putc 114
putc 108
putc 100
putc 33

Output: Hello, World!

share|improve this answer

OMGROFL

I'm a big fan of esoteric languages. Luckily OMGROFL is alphanumeric:

lol iz 72
rofl lol
lol iz 101
rofl lol
lol iz 108
rofl lol
rofl lol
lool iz 111
rofl lool
loool iz 44
rofl loool
loool iz 32
rofl loool
loool iz 87
rofl loool
rofl lool
lool iz 114
rofl lool
rofl lol
lol iz 100
rofl lol
lol iz 33
rofl lol
stfu

The iz command sets a value to a variable, in this case lol, lool and loool serve as variables...

The rofl command echoes out the ASCII equivalent to the number stored in the variable.

The stfu command terminates the program ;)

share|improve this answer
    
haha, nice! I wanted to attempt a LOLCODE version but the language requires using a colon and quotation marks to coerce ints to chars. –  Jonathan Van Matre Mar 6 at 4:41

base64

SGVsbG8sIFdvcmxkIQ

Satisfies the original rules.

share|improve this answer
2  
Is base64 a language? And what's your output? Does it have the correct capitalization? –  steveverrill Mar 5 at 14:55
14  
Sure it's a language, it's just not Turing-complete. Also, base64decode.org –  Kendall Frey Mar 5 at 14:56
1  
Haha. For that response, +1 your comment, but not your answer. Maybe your answer later if I feel like it. –  steveverrill Mar 5 at 15:06
2  
@Neil you used " –  mniip Mar 6 at 10:51
1  
@KendallFrey By that logic, base10 is a language: 1234567890. –  Cole Johnson Mar 7 at 0:19

DC

DC is just about the perfect tool for the job.

5735816763073854918203775149089P

DCs P-command pops one number from the stack and outputs its raw computer representation to STDIO. Seeing as 5735816763073854918203775149089 = 0x48656C6C6F2C20576F726C6421, which is represented as 0x21, 0x64, 0x6C... = 'H', 'e', 'l'... in a little-endian architecture, it outputs Hello, World!.

share|improve this answer
    
How does this work? Would you mind adding an explanation? –  Tungsten Mar 7 at 17:52
1  
Not at all. An explanation will be added shortly. –  Fors Mar 7 at 17:55
1  
+1. You could do it in hex to save a few chars: 16i48656C6C6F2C20576F726C6421P –  DigitalTrauma Mar 7 at 19:12

JavaScript

with (String) with ([]) {
    push(fromCharCode(72))
    push(fromCharCode(101))
    push(fromCharCode(108))
    push(fromCharCode(108))
    push(fromCharCode(111))
    push(fromCharCode(44))
    push(fromCharCode(32))
    push(fromCharCode(87))
    push(fromCharCode(111))
    push(fromCharCode(114))
    push(fromCharCode(108))
    push(fromCharCode(100))
    push(fromCharCode(33))
    alert(join([]))
}
share|improve this answer
    
ARGH! I hit the same solution, but decided that since it was 2:00 am, I should go to bed and post it in the morning. Kudos to you! –  DocMax Mar 6 at 16:03

BBC BASIC

Emulator at bbcbasic.co.uk

Split from my LOGO answer.

The easy way

The numbers on the right are just ASCII codes. This is just the same as printing. If I was allowed a comma I could do it on a single line (VDU 72,101,108,etc.)

   10 VDU 72
   20 VDU 101
   30 VDU 108
   40 VDU 108
   50 VDU 111
   55 VDU 44
   60 VDU 32
   70 VDU 87
   80 VDU 111
   90 VDU 114
  100 VDU 108
  110 VDU 100
  120 VDU 33

A more creative way

    5 MODE 6
   10 READ B
   12 WHILE B
   15   PROC1(B)
   16   PRINT
   17   READ B
   18 ENDWHILE
   20 END

REM procedure prints first square on line, 
REM then calls itself recursively with A DIV 2 to print the next
REM VDU 17 tell VDU controller we want to change colour
REM Next line changes background colour. 
REM Then following line VDU 32 prints a space in that background colour.

  110 DEFPROC1(A)
  115 VDU 17
  120 IF A AND 1 THEN VDU VPOS DIV 6 EOR 133 ELSE VDU 128
  125 VDU 32
  130 IF A THEN PROC1(A DIV2)
  140 ENDPROC

REM binary bitmap data for each row, least significant at left
  150 DATA 463221
  160 DATA 332053
  170 DATA 332151
  180 DATA 332053
  190 DATA 2586485
  200 DATA 1048576
  210 DATA 4395895
  220 DATA 4527447
  230 DATA 4526935
  240 DATA 333143
  250 DATA 4420981
  260 DATA 0

enter image description here

share|improve this answer

Mathematica

Unprotect[Times]
ClearAll[Times]
Print[Hello FromCharacterCode[44] world FromCharacterCode[33]]
share|improve this answer
    
Haha, clever. Very nice! –  Jonathan Van Matre Mar 6 at 4:37
1  
Are the square brackets allowed? –  Michael Stern Apr 7 at 14:24
    
What is the output ? –  Nicolas Barbulesco May 24 at 8:32
    
Isn’t a space missing ? –  Nicolas Barbulesco May 24 at 8:32

Rebol

Alphanumeric only solution:

prin quote Hello prin add space 12 prin space prin quote World print add space 1

Above is an update which uses Dr Rebmu excellent suggestion of add space 1 (which produces !) to get to all the characters.

Below is the original version:

prin quote Hello prin pick mold system 264 prin space prin quote World print pick mold system 12

Shorter version with brackets:

print rejoin [quote Hello pick mold system 264 space quote World pick mold system 12] 

And even shorter version with braces:

print join {Hello} join pick mold system 264 join { World} pick mold system 12

And shortest version with both brackets & braces:

print rejoin [{Hello} pick mold system 264 { World} pick mold system 12]

Rebol uses braces {} for multi-line quoting. So completely valid under rule changes but not quite in full spirit (IMHO) as my first two answers above.


NB. Printing the ! was a pain!

Rebol allows and uses punctuation characters routinely for function names and datatypes. So options like to-char 33 or to char! 33 would not be allowed under the rules (even though these punctuations are not operators par se).

Fortunately I found a cheeky way by turning the Rebol system object: make object! [...] into a string and cherry pick that ! from it :)

Update: And now also cherry picked comma from license text in system object.

share|improve this answer
1  
! is not allowed –  grovesNL Mar 5 at 20:19
2  
@grovesNL - Solution no longer uses - or ! so you may now remove the down vote –  draegtun Mar 5 at 21:12
1  
You are missing the comma –  mniip Mar 6 at 12:14
1  
@mniip - Thanks missed that! Have now fixed. –  draegtun Mar 6 at 12:32
1  
Pretty tricky, but you could have just added to space to get the characters... ;-) See the Rebmu solution, which clocks in at 46 chars... –  Dr. Rebmu Apr 6 at 23:33

C

Uses only alphanumeric characters, spaces and braces {}, brackets [] and parenthesis ().

main()
{
        if(printf((long long []){0x202c6f6c6c6548}))
                if(printf((long long []){0x21646c726f57})){}
}

printf( ) accepts a char * as an argument, but since we can't use quotes("), I typecast the string as a long long array. The values seen here are ASCII strings, in little endian (0x48=H, 0x65=e, 0x6c=l, and so on). I typecast it to long long [] since that way I can pass an 8-byte argument and hence use only two printf( ) calls instead of four.

share|improve this answer
    
This breaks rule #1 –  Timtech Mar 7 at 21:31
1  
Chars, numbers, spaces and {} () [] are allowed. –  pank4j Mar 8 at 3:13
    
you can cast an int literal to array? I've never seen this before –  Lưu Vĩnh Phúc Mar 10 at 5:48
    
What does this do ? –  Nicolas Barbulesco May 24 at 8:54
    
@LưuVĩnhPhúc Array is a pointer. Pointer is an integer. –  Sieg Jun 5 at 6:17

ferNANDo

h E R
e I S
h E
l L O
w O
r L
d U S
i N G
o N L
y L E
t T E
r S

H e L L o W O R
L d h E L l O w
O r l D h e L L
O w o R l d H E
L l o W o r l d
H E l L o w O R
L D h E L L O W
O r L d H e l l
O w o R l d h e
L l o w O R l D
H e l L o w O R
L d h E L l O W
O R l D H E L l
O w O
r L d
share|improve this answer
    
Missing Comma and ! –  VoronoiPotato Mar 5 at 19:44
    
@VoronoiPotato: works fine over here –  marinus Mar 5 at 20:44
    
whoops sorry :X –  VoronoiPotato Mar 5 at 20:50

JavaScript!

And they said that it couldn't be done... No assignment operators, no concatenators, no quotes! Arghhhh!

Fear not... For the force is with you...

function w(x){
    with(document){
        with(String){
            write(fromCharCode(x))
        }
    }
}
w(72)
w(101)
w(108)
w(108)
w(111)
w(44)
w(32)
w(87)
w(111)
w(114)
w(108)
w(100)
w(33)

Output (on browser screen): Hello, World!
share|improve this answer
    
He said "Bonus if you can do it in Java" not Javascript. –  Almo Mar 7 at 18:39
    
@Almo I wasn't aiming to do it in Java... I was focussing on JavaScript, which is my main strength here on this site... –  WallyWest Mar 7 at 19:22
    
But you said "And they said that it couldn't be done" which I thought was referring to the puzzle stating bonus for doing it in Java. Many people still confuse Java with Javascript. –  Almo Mar 7 at 19:23
    
@Almo, I was just using a general saying... And when I refer to "Javascript", I intend to use JavaScript... Trust me, I wasn't planning on going for a bonus... –  WallyWest Mar 7 at 19:28

Javascript

Update: Managed to cut a bunch of characters by introducing a World function as well.

Another Javascript solution that writes to console.log:

function World() { with (World) return name }
function Hello() {}
with (console)
with (String)
with (Hello)
with (name)
with (concat(fromCharCode(44)))
with (concat(fromCharCode(32)))
with (concat(World()))
log(concat(fromCharCode(33)))

Inspired by this entry.

First, I define functions named Hello and World. This will be used later on.

Then I start my chain of nested withs. The with (console) and with (String) are used so that I can later on invoke console.log and String.fromCharCode without using a dot.

The plan is now to build the string Hello, World! by abusing nested withs. Each time I invoked concat(), the resulting string will be the context in the next with-block. I take a short cut to quickly get "Hello" by accessing the name property of the Hello function. Then I concatenate the comma and space characters by using String.fromCharCode.

The next trick is to get the "World" part of the string. I cannot use the same method I used to get Hello, since I cannot invoke World.name. Instead I put that logic inside the World method, and invoke it.

Finally, I append the final exclamation mark and send the result right to the log function, which is of course console.log.

share|improve this answer

Javascript

with (function SGVsbG8sIFdvcmxkIQ(){}) atob(name)

Use browser's console to test.

share|improve this answer
1  
Wow, very clever! –  Jordon Biondo May 13 at 20:52

Java

No dots or semicolons, but using Unicode escapes.

public static void main(String[] args) {        
    System\u002Eout\u002Eprint(\u0022Hello\u002C World\u0021\u0022)\u003B
}

This is bending the rules, because backslash was not permitted. However, I can't see how this can be done in Java without using either \ or .. Semicolon is not a problem because System.out.append can be used in a condition of an if clause instead of System.out.print.

share|improve this answer

Perl

In a modern Perl (5.10 or newer):

print q{Hello} and print chr 44 and print q{ World} and say chr 33

In older Perl:

print q{Hello} and print chr 44 and print q{ World} and print chr 33 and print chr 10


Both solutions above use Perl q quote-like operator and allows selective delimiters for quoting a string, for eg. q{} q[] q() q//

This solution requires the rule change that allows braces, brackets or parens. So while totally valid I think mniip excellent Perl answer is more in the true spirit of the rules (+1).

However taking a leaf out of mniip answer my solution could be written like so:

print q xHellox and print chr 44 and print q x Worldx and say chr 33

and while harder on the eye it does work.

share|improve this answer
1  
You are missing the comma –  mniip Mar 6 at 10:53
1  
@mniip - Thanks again. Have now added missing comma. –  draegtun Mar 6 at 12:40
    
Looks like AppleScript without the verbosity –  SHiNKiROU May 17 at 23:51
    
On my Mac, the first and third Perl lines do not work, only the second Perl line works. I have Perl 5.16.2. –  Nicolas Barbulesco May 24 at 9:16
    
syntax error at -e line 1, near "say chr" –  Nicolas Barbulesco May 24 at 9:21

Perl

print chr hex for qw z48 65 6c 6c 6f 2c 20 57 6f 72 6c 64 21z
share|improve this answer

dc, (26 bytes for the golfers)

Whitespace and [] brackets are now allowed:

[Hello]n44P[ World]n33P[]p

Output:

$ dc <<< "[Hello]n44P[ World]n33P[]p"
Hello, World!
$ 
share|improve this answer

T-SQL, 52

Ah, this is better! Direct binary conversion, only 52 characters.

SELECT CAST(0x48656C6C6F2C20576F726C6421 AS VARCHAR)

Previously...

There's a much cleverer and golfier solution to this that would work if we could use = and + (Looking up standard built-in data in msdb and using that to construct an EXEC-able query string)

But since we can't, you get this naive approach:

SELECT CHAR(72)SELECT CHAR(101)SELECT CHAR(108)SELECT CHAR(108)SELECT CHAR(111)SELECT CHAR(44)SELECT CHAR(32)SELECT CHAR(87)SELECT CHAR(111)SELECT CHAR(114)SELECT CHAR(108)SELECT CHAR(100)SELECT CHAR(33)
share|improve this answer
1  
I know, the lack of concatenation operators is killing me... I'm trying to think of a way to do it with JavaScript... –  WallyWest Mar 5 at 21:37
1  
Yeah, although this challenge seems to produce mostly naive answers, it has definitely inspired some interesting brain-twisting to try to find interesting non-concatenative approaches. –  Jonathan Van Matre Mar 5 at 21:46

Python:

import antigravity 

causes "Hello, world!" to appear on your screen. Don't believe me? Try it out for yourself! Also, this doesn't actually use the web, it opens a browser, that might lookup a website.

share|improve this answer
1  
I have a 768-pixels height screen, so "Hello, world!" doesn't appear on my screen. –  ogregoire May 16 at 12:57
1  
This does not write "Hello, world!" anywhere in my field of vision. But this opens xkcd.com/353/ in Safari ! –  Nicolas Barbulesco May 24 at 9:33
    
I am not using the Web now. I am writing in a browser, that might connect to a Web site. –  Nicolas Barbulesco May 24 at 9:46

Rebmu, 46 characters

pnUPPqHELLO01pnADsp12pnSPpnUPPqWORLD01pnADsp01

Strongly parallels @dragetun's solution in Rebol (Because Rebmu is a Rebol/Red teaching tool which is a "dialect" that aims to draw attention to the languages by rocking at Code Golf. :-P)

However, to get the missing characters, I did something more obvious. I just added to space, instead of going and looking through system strings. You can get add space 1 to get character literal #"!" and add space 12 to get character literal #",".

If we run this we can see it get "unmushed":

>> rebmu/debug/stats "pnUPPqHELLO01pnADsp12pnSPpnUPPqWORLD01prADsp01"
Original Rebmu string was: 46 characters.
Rebmu as mushed Rebol block molds to: 46 characters.
Unmushed Rebmu molds to: 62 characters.
Executing: [pn upp q hello 1 pn ad sp 12 pn sp pn upp q world 1 pr ad sp 1]
Hello, World!

Which is fairly logial:

; print with no newline the result of doing an uppercase/part
; on the quoting of the symbolic word hello, of only the first
; N characters (where N is 1)
pn upp q hello 1

; print the character you get when you add 12 to the space
; character literal, a.k.a. comma...again no newline
pn ad sp 12

; print a space, no newline
pn sp

; do the same trick of printing the quoted word hello with the
; first letter converted to uppercase
pn upp q world 1

; print the character you get when you add 1 to the space
; character literal, a.k.a. exclamation point...with newline now
pr ad sp 1
share|improve this answer

Groovy

So updated. Much wat.

def wat(i) { print i
  this
}
def wat(int i) { wat i as char }
def getProperty(String p) { p }
wat Hello wat 44 wat 32 wat World wat 33
share|improve this answer

GO (golang)

package main

func main() {
    print(string(72))
    print(string(101))
    print(string(108))
    print(string(108))
    print(string(111))
    print(string(44))
    print(string(32))
    print(string(87))
    print(string(111))
    print(string(114))
    print(string(108))
    print(string(100))
    print(string(33))
}

No "fmt" used... Just print.

share|improve this answer

protected by Community Jun 15 at 20:05

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.