or
Code Golf
Hello World
Lyxal
string optimization
Let's get things up and running with a nice simple challenge. Your task is to create a program or function that outputs or returns the exact string `Hello, World! `

| Input | Output |
|-------|--------|
|  None | `Hello, World!`|
Top Answer
Bubbler
# [Stuck](https://esolangs.org/wiki/Stuck), 0 bytes

An empty program prints `Hello, World!` in [Stuck](https://esolangs.org/wiki/Stuck).
Answer #2
Skillmon
# TeX, 13 (or 17?) bytes

Since every normal text is printed directly in TeX the shortest "function" is:

```tex
Hello, World!
```

A complete script (one needs to end the run to actually get the output file):

```tex
Hello, World!\bye
```

Output is printed to PDF if you use `pdftex`.
Answer #3
liek
# [Actually](https://github.com/Mego/Seriously), 1 byte
The program is a built-in in Actually.

    H

[Try it online!](https://tio.run/##S0wuKU3Myan8/9/j/38A "Actually – Try It Online")
Answer #4
Skillmon
# C, 30 bytes (program)

Using gcc 9.2.0.

```C
main(){puts("Hello, World!");}
```

[Try it online!](https://tio.run/##S9ZNT07@/z83MTNPQ7O6oLSkWEPJIzUnJ19HITy/KCdFUUnTuvb/fwA)
Answer #5
Lyxal
# [Keg], 8 bytes

    «H%c¡|,!

[Try it online!][TIO-k6320gnp]

[Keg]: https://github.com/JonoCode9374/Keg
[TIO-k6320gnp]: https://tio.run/##y05N////0GoP1eRDC2t0FP//BwA "Keg – Try It Online"
Answer #6
Adám
# [APL (Dyalog Unicode)], 15 bytes
Full program.
```apl
'Hello, World!'
```
[Try it online!][TIO-k5yzbyz0]

[APL (Dyalog Unicode)]: https://www.dyalog.com/
[TIO-k5yzbyz0]: https://tio.run/##SyzI0U2pTMzJT///qKO94L@6R2pOTr6OQnh@UU6KojpI8D8A "APL (Dyalog Unicode) – Try It Online"
Answer #7
Mathgeek
# [Golfscript](https://http://www.golfscript.com/), 15 bytes

```
"Hello, World!"
```

I spent a good amount of time trying to find a more efficient way, but the best I could do was in the low-twenties. Guess this will have to do!
Answer #8
Bubbler
# [Japt], 11 bytes

    `HÁM, WŽld!

[Try it online!][TIO-k601tfhj]

[Japt]: https://github.com/ETHproductions/japt
[TIO-k601tfhj]: https://tio.run/##y0osKPn/P8HjcKOvjkL4ob6cFMX//wE "Japt – Try It Online"

Japt has compressed strings delimited by backticks `` ` ``, and supports auto-closing of string literals and parentheses.

The character on the right of W has charcode 142 (0x8E). Japt's default encoding is [ISO-8859-1](https://en.wikipedia.org/wiki/ISO/IEC_8859-1).
Answer #9
xnor
# [Python 2](https://docs.python.org/2), 20 bytes

```python
print"Hello, World!"
```

[Try it online!][TIO-k5u39359]

[TIO-k5u39359]: https://tio.run/##K6gsycjPM/r/v6AoM69EySM1JydfRyE8vygnRVHp/38A "Python 2 – Try It Online"
Answer #10
James Douglas
# [Agony], 236 bytes

    >++++++++{++++}.>+++++{++++++}.>++++++++++++{++++++}.>++++++++++++{++++++}.>+++++++++++++++{++++++}.>++++++++++++{++}.>{++}.>+++++++{+++++}.>+++++++++++++++{++++++}.>++++++++++++++++++{++++++}.>++++++++++++{++++++}.>++++{++++++}.>+{++}.

[Try it online!][TIO-k780a6go]

[Agony]: https://github.com/royvanrijn/JAgony
[TIO-k780a6go]: https://tio.run/##S0zPz6v8/99OGwqqQUStnh2Cg@AiKyFSFJ9yoEg1sng1SQYQ7xYkHti@//8B "Agony – Try It Online"

(Disclaimer: I don't understand any of this code)
Answer #11
James Douglas
# [SQLite](https://sqlite.org/index.html), 22 bytes

```sql
select'Hello, World!';
```
[Try it online!](https://tio.run/##Ky7MySxJ/f@/ODUnNblE3SM1JydfRyE8vygnRVHd@v9/AA "SQLite – Try It Online")
Answer #12
Οurous
# [ABC-assembler](https://hdl.handle.net/2066/113882), 39 bytes

```
.start s
s
	print "Hello, World!"
	halt
```

This is a full program in ABC-assembler ([Clean](https://clean.cs.ru.nl/Clean)'s IL) as described in [this paper](https://hdl.handle.net/2066/113882).

[Try it online!](https://tio.run/##S0xK1k0sLk7NTcpJLfr/X6@4JLGoRKGYq5iLs6AoM69EQckjNScnX0chPL8oJ0VRiYszIzGn5P9/AA "ABC-assembler – Try It Online")
Answer #13
Οurous
# [Clean](https://clean.cs.ru.nl/Clean), 15 bytes

```clean
"Hello, World!"
```
This is an unnamed function taking no arguments and returning a string.  
Due to Clean's use of currying, this is equivalent to a string literal.

It has the same type signature as a named function:
```clean
f :: String
f = "Hello, World!"
```
A superfluous arrow can be added to reinforce this:
```clean
f :: -> String
f = "Hello, World!"
```

As a full program it's 21 bytes, plus a 9-byte-minimum file header:
```clean
Start="Hello, World!"
```
[Try it online!](https://tio.run/##S85JTcz7n5ufUpqTqpCbmJn3P7gksajEVskjNScnX0chPL8oJ0VR6f//f8lpOYnpxf91kwA "Clean – Try It Online")
Answer #14
James Douglas
# [PHP](https://php.net), ~~28~~ 13 bytes

Seeing as:


> PHP echos everything by default outside the <? tags


```php
Hello, World!
```

[Try it online!](https://tio.run/##K8go@P/fIzUnJ19HITy/KCdF8f9/AA "PHP – Try It Online")

(Minus 15 bytes thanks to @manassehkatz!)
Answer #15
Öort
# [Triangularity], 49 bytes

    .... ....
    ..."!"...
    .."rld"..
    ."o, Wo".
    "Hell"+++

[Try it online!][TIO-k758litl]

[Triangularity]: https://github.com/Mr-Xcoder/Triangularity
[TIO-k758litl]: https://tio.run/##KynKTMxLL81JLMosqfz/Xw8IFEAEFxArKSpBWEpFOSlKIJZSvo5CeL6SHpeSR2pOjpK2tvb//wA "Triangularity – Try It Online"
Answer #16
Hosch250
# C#, 45 bytes

```
()=>System.Console.WriteLine("Hello World!");
```

This is an anonymous function that prints `Hello World!`. To run it, you would assign it to a variable and then call the variable like a function:

```
var func = () => System.Console.WriteLine("Hello World!");
func();
```

If that doesn't count, a full program would be 70 bytes:

```
class T{static void Main(){System.Console.WriteLine("Hello World!");}}
```
Answer #17
Wheat Wizard
# Haskell, 15 bytes (function)

    "Hello, World!"
    
In Haskell functions are curried so the string `"Hello, World!"` is no different from a function that takes no arguments and outputs the string.

For a complete program:

# Haskell, 26 bytes (program)

    main=putStr"Hello, World!"
    
This uses `putStr :: String -> IO ()` to turn the string `"Hello, World"` into an `IO` action that results in `()` (Haskell's terminal object, other languages have `void`).  This `IO` action will result in the string `Hello, World!` being output to the console.  We then assign this result to `main`, which is a special function that Haskell calls when the program is run.
Answer #18
ajc2
# [Kotlin], 17 bytes

    {"Hello, World!"}

[Try it online!][TIO-k8469x3n]

[Kotlin]: https://kotlinlang.org
[TIO-k8469x3n]: https://tio.run/##y84vycnM@1@WmKOQYaWgoamga6cQXFKUmZeuYPu/WskjNScnX0chPL8oJ0VRqfZ/WmmeQm5iZh5Qoa1CAVBZiUaGhqbmfwA "Kotlin – Try It Online"
Answer #19
ajc2
# [Ahead], 17 bytes

    "!dlroW ,olleH"W@

[Try it online!][TIO-k7mzjxka]

[Ahead]: https://github.com/ajc2/ahead
[TIO-k7mzjxka]: https://tio.run/##S8xITUz5/19JMSWnKD9cQSc/JyfVQync4f9/AA "Ahead – Try It Online"
Answer #20
A-ee
# [Erlang (escript)], 21 bytes

    f()->"Hello, World!".

[Try it online!][TIO-k7ifqgtz]

[Erlang (escript)]: http://erlang.org/doc/man/escript.html
[TIO-k7ifqgtz]: https://tio.run/##Sy3KScxL100tTi7KLCj5z/U/TUNT107JIzUnJ19HITy/KCdFUUnvf25iZp5GdCxQKjPfKq28KLMkVQOoUlPvPwA "Erlang (escript) – Try It Online"
Hello World
James Douglas replying to manassehkatz
Thanks for the tips! I've updated my answer
manassehkatz
@James Actually, for PHP you can leave out the <? tags and just have the text: Hello, World! PHP echos everything by default outside the <? tags. For more typical PHP answers where you actually have to use real PHP code, you can normally leave the ending ?> off to save 2 bytes.
Bubbler
Also, "Always display the code as written" has a side effect of allowing `U+0000` in code blocks, which CommonMark bans for "security reasons" (I don't know actual implications though).
Bubbler replying to Jack Douglas
Probably yes but not much, mainly because we usually add a link to an online interpreter, where you can access the actual code regardless of the display on TA.
Jack Douglas
or would that not work anyway because the character set is different
Jack Douglas replying to Bubbler
it'll matter to someone copy/pasting your code though right?
Jack Douglas replying to Bubbler
oh I see, that's really helpful to know, thanks for linking to the spec
Bubbler
On second thought, it doesn't matter if it is actually displayed as original charcode or a replacement character if the font doesn't support it anyway.
Bubbler replying to Jack Douglas
No, it isn't the actual char `&#142;`. Outside a code block, it is [replaced with `U+FFFD`](https://spec.commonmark.org/0.29/#decimal-numeric-character).
Jack Douglas replying to Bubbler
If I type `&#142;` in an answer (outside a code block), I get a �, which I can then just copy/paste into the code section like so: `�`. Does that achieve the same thing as using the entity would if it were supported?
Bubbler
Yes, it helps, but that means `<pre><code>` + HTML escape char (or any way to simulate it) is not supported right now (if I read it correctly). Yet it's a language-specific quirk (in this case, Japt), and we can avoid the trailing newline issue (the other main reason to use the tag) by using fenced blocks ` ``` `, so I'm fine with the current features. I guess I need to insist the creator(s) of Japt to use readable SBCS instead of ISO-whatever.
Jack Douglas replying to Bubbler
Does [this on meta](https://topanswers.xyz/meta?q=72#a44) help?
Adám replying to Bubbler
* [Entity and character references are not recognized in code blocks and code spans.](https://spec.commonmark.org/0.29/#entity-and-numeric-character-references)
Bubbler
@Jack Does TA support a way to enter HTML escape chars e.g. `&#142;` inside code blocks? SE allows to use `<pre><code>` tags, so my Japt answer could be entered as ``<pre><code>`HÁM, W&#142;ld!</code></pre>``. Also, do you have a list of Markdown features enabled on TA?
Skillmon replying to Adám
I should read the rules more thoroughly :)
Adám replying to Skillmon
Yes, per default I/O rules.
Skillmon
@Lyxal are trailing newlines ok?
Skillmon
@Bubbler I *knew* this would happen: https://topanswers.xyz/transcript?room=624&id=15452#c15452
Jack Douglas replying to Adám
We've fixed this now, thanks both for pointing it out
Adám replying to Skillmon
It seems to be universal. I've pinged Jack about it.
Skillmon replying to Adám
was the same for me on the nth-string replacement question.
Adám
@Jack This question was at "1 star (1 more required)" so I tried to star it, and now it shows:![nan.png](/image?hash=abe77a9dc6d44a2f9ac8fbd82f449f98d2ae5a2a58a2e255eba07aae03a7ce22)
Jack Douglas
indeed
Skillmon replying to Jack Douglas
I was just judging from that wiki entry's header.
Jack Douglas
but no comma either!
Jack Douglas
although looking at the source the cases do seem to be correct
Jack Douglas
oh good point!
Skillmon replying to Jack Douglas
Luckily the cases aren't correct and the exclamation mark is missing :)
Jack Douglas replying to Skillmon
like this one: http://esolangs.org/wiki/HQ9%2B :)
Skillmon
Yay, currently TeX is the shortest, but then there will be some code golfing language which will just use `.` which is a built in that prints `Hello, World!` if no argument is specified or something like that...
Jack Douglas replying to xnor
that's a good question and I don't think there is — communities can opt in to a default language but that won't help here
xnor replying to Jack Douglas
Thanks. Is there a way to declare a language for all code snippets in an answer? 
Jack Douglas
@xnor I tweaked your answer to get the syntax highlighting working, it's done slightly differently here: https://topanswers.xyz/answer-history?id=673
Lyxal
_First!_ Woot!