517
\$\begingroup\$

So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with , and counting). While this is not the most interesting code golf in the common languages, finding the shortest solution in certain esolangs can be a serious challenge. For instance, to my knowledge it is not known whether the shortest possible Brainfuck solution has been found yet.

Furthermore, while all of Wikipedia (the Wikipedia entry has been deleted but there is a copy at archive.org ), esolangs and Rosetta Code have lists of "Hello, World!" programs, none of these are interested in having the shortest for each language (there is also this GitHub repository). If we want to be a significant site in the code golf community, I think we should try and create the ultimate catalogue of shortest "Hello, World!" programs (similar to how our basic quine challenge contains some of the shortest known quines in various languages). So let's do this!

The Rules

  • Each submission must be a full program.
  • The program must take no input, and print Hello, World! to STDOUT (this exact byte stream, including capitalization and punctuation) plus an optional trailing newline, and nothing else.
  • The program must not write anything to STDERR.
  • If anyone wants to abuse this by creating a language where the empty program prints Hello, World!, then congrats, they just paved the way for a very boring answer.

    Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language.

  • Submissions are scored in bytes, in an appropriate (pre-existing) encoding, usually (but not necessarily) UTF-8. Some languages, like Folders, are a bit tricky to score - if in doubt, please ask on Meta.
  • This is not about finding the language with the shortest "Hello, World!" program. This is about finding the shortest "Hello, World!" program in every language. Therefore, I will not mark any answer as "accepted".
  • If your language of choice is a trivial variant of another (potentially more popular) language which already has an answer (think BASIC or SQL dialects, Unix shells or trivial Brainfuck-derivatives like Alphuck), consider adding a note to the existing answer that the same or a very similar solution is also the shortest in the other language.

As a side note, please don't downvote boring (but valid) answers in languages where there is not much to golf - these are still useful to this question as it tries to compile a catalogue as complete as possible. However, do primarily upvote answers in languages where the authors actually had to put effort into golfing the code.

For inspiration, check the Hello World Collection.

The Catalogue

The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

## Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

## Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

## Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the snippet:

## [><>](https://esolangs.org/wiki/Fish), 121 bytes

/* Configuration */

var QUESTION_ID = 55422; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 8478; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });  
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];
  
  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>';
    });
    
    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });
    else console.log(body);
  });
  
  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;
    
    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    lang = jQuery('<a>'+lang+'</a>').text();
    
    languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang, user: a.user, size: a.size, link: a.link};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.lang_raw.toLowerCase() > b.lang_raw.toLowerCase()) return 1;
    if (a.lang_raw.toLowerCase() < b.lang_raw.toLowerCase()) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}
body {
  text-align: left !important;
  display: block !important;
}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 500px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/all.css?v=ffb5d0584c5f">
<div id="language-list">
  <h2>Shortest Solution by Language</h2>
  <table class="language-list">
    <thead>
      <tr><td>Language</td><td>User</td><td>Score</td></tr>
    </thead>
    <tbody id="languages">

    </tbody>
  </table>
</div>
<div id="answer-list">
  <h2>Leaderboard</h2>
  <table class="answer-list">
    <thead>
      <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr>
    </thead>
    <tbody id="answers">

    </tbody>
  </table>
</div>
<table style="display: none">
  <tbody id="answer-template">
    <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>
<table style="display: none">
  <tbody id="language-template">
    <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>

\$\endgroup\$
21
  • 4
    \$\begingroup\$ @isaacg No it doesn't. I think there would be some interesting languages where it's not obvious whether primality testing is possible. \$\endgroup\$ Aug 28, 2015 at 13:56
  • 7
    \$\begingroup\$ If the same program, such as "Hello, World!", is the shortest in many different and unrelated languages, should it be posted separately? \$\endgroup\$ Aug 28, 2015 at 15:33
  • 2
    \$\begingroup\$ @mbomb007 Well it's hidden by default because the three code blocks take up a lot of space. I could minify them so that they are a single line each, but I'd rather keep the code maintainable in case bugs come up. \$\endgroup\$ Aug 28, 2015 at 19:34
  • 8
    \$\begingroup\$ @ETHproductions "Unlike our usual rules, feel free to use a language (or language version) even if it's newer than this challenge." Publishing the language and an implementation before posting it would definitely be helpful though. \$\endgroup\$ Aug 29, 2015 at 23:01
  • 2
    \$\begingroup\$ @MartinEnder ... Almost. If two BF solutions have the same size, the one with smaller lexicographical order will take smaller number of bytes in Unary. Of course the smallest Unary solution translated to BF is guaranteed to be smallest. \$\endgroup\$
    – DELETE_ME
    May 20, 2018 at 10:20

976 Answers 976

1
2 3 4 5
33
541
\$\begingroup\$

Stuck, 0 bytes

Well, can't get shorter than that... An empty program will output Hello, World! in Stuck.

\$\endgroup\$
9
  • 76
    \$\begingroup\$ Damn, i was 20 minutes late! :P \$\endgroup\$
    – Kade
    Aug 28, 2015 at 12:55
  • 50
    \$\begingroup\$ Noooo c'mon fastest gun in the west effect ;) \$\endgroup\$
    – Beta Decay
    Aug 28, 2015 at 16:32
  • 52
    \$\begingroup\$ @Zuck Well yes, Stuck was made for code-golfing, just like CJam/GolfScript/Pyth. The Hello, World! thing was just something I had put in as a placeholder early in development. I didn't intend to leave it in so long, just never got around to removing it. \$\endgroup\$
    – Kade
    Sep 8, 2015 at 20:34
  • 185
    \$\begingroup\$ I've been trying to come up with a shorter solution, but I'm stuck. \$\endgroup\$
    – Cyoce
    Dec 24, 2015 at 3:40
  • 23
    \$\begingroup\$ @Shebang 20 minutes, 150+ upvotes. I kinda feel for you \$\endgroup\$ Jan 7, 2016 at 9:26
305
\$\begingroup\$

PHP, 13 bytes

Hello, World!

Yes. It works.

Try it online!

\$\endgroup\$
13
  • 326
    \$\begingroup\$ As usual with PHP, you always wonder how it can work \$\endgroup\$
    – Fatalize
    Aug 28, 2015 at 14:03
  • 124
    \$\begingroup\$ It works, of course, because there's no <?php in the code, causing it not to get interpreted by PHP at all :) \$\endgroup\$
    – Lynn
    Aug 28, 2015 at 19:54
  • 73
    \$\begingroup\$ That means this is just an HTML answer... \$\endgroup\$
    – Nelson
    Aug 29, 2015 at 11:42
  • 101
    \$\begingroup\$ @Nelson no, it doesn't. PHP doesn't necessarily have to be placed in to HTML. And plus, HTML doesn't print to the stdout \$\endgroup\$
    – galexite
    Aug 29, 2015 at 11:43
  • 22
    \$\begingroup\$ See, when I did this, I got a -1, not +173 \$\endgroup\$
    – Stan Strum
    Sep 2, 2017 at 17:37
290
+1500
\$\begingroup\$

Brainfuck, 78 bytes

Open-ended bounty: If anyone can improve this score, I will pass the bounty (+500) on to them. @KSab has found a 76 72 byte solution!

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

Try it online!

The first 28 bytes --<-<<+[+[<+>--->->->-<<<]>] initialize the tape with the following recurrence relation (mod 256):

\$f_n=171(-f_{n-1}-f_{n-2}-f_{n-3}+1)\$, with \$f_0=57, f_1=123,f_2=167\$

The factor of \$171\$ arises because \$3^{-1}=171 \pmod{256}\$. When the current value is translated one cell back (via <+>---) subtracting \$3\$ each time effectively multiplies the value by \$171\$.

At \$n=220\$ the value to be translated is zero, and the iteration stops. The ten bytes preceding the stop point are the following:

\$[130, 7, 43, 111, 32, 109, 87, 95, 74, 0]\$

This contains all of the components necessary to produce Hello, World!, in hunt-and-peck fashion, with minor adjustments.

I've also found an alternative 78 byte solution:

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

Try it online!

I consider this one to be better than the first for several reasons: it uses less cells left of home, it modifies less cells in total, and terminates more quickly.


More Detail

Recurrence relations have surprisingly terse representations in Brainfuck. The general layout is the following:

{...s3}<{s2}<{s1}[[<+>->{c1}>{c2}>{c3...}<<<]>{k}]

which represents:

\$f_n=c_1f_{n-1}+c_2f_{n-2}+c_3f_{n-3}+\cdots+k\$

with

\$f_0=s_1, f_1=s_2+c_1f_0+k,f_2=s_3+c_2f_0+c_1f_1+k,\text{etc.}\$

Additionally, the <+> may be changed to multiply the range by a constant without affecting the stop point, and a term may be added before the >{k} to shift the range by a constant, again without affecting the stop point.


Other Examples

Fibonacci Sequence

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

N-gonal Numbers

Triangular Numbers

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

Defined as \$f_n=2f_{n-1}-f_{n-2}+1\$, with \$f_0=0,f_1=1\$.

Square Numbers

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

Pentagonal Numbers

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

etc.


BF Crunch

I've published the code I used to find some of this solutions on github. Requires .NET 4.0 or higher.

Usage: bfcrunch [--options] text [limit]

Arguments
------------------------------------------------------------
  text              The text to produce.
  limit             The maximum BF program length to search for. If zero, the length of the
                    shortest program found so far will be used (-r). Default = 0

Options
------------------------------------------------------------
  -i, --max-init=#  The maximum length of the initialization segment. If excluded, the
                    program will run indefinitely.
  -I, --min-init=#  The minimum length of the initialization segment. Default = 14
  -t, --max-tape=#  The maximum tape size to consider. Programs that utilize more tape than
                    this will be ignored. Default = 1250
  -T, --min-tape=#  The minimum tape size to consider. Programs that utilize less tape than
                    this will be ignored. Default = 1
  -r, --rolling-limit
                    If set, the limit will be adjusted whenever a shorter program is found.
  -?, --help        Display this help text.

Output is given in three lines:

  1. Total length of the program found, and the initialization segment.
  2. Path taken, starting with the current tape pointer. Each node corresponds to one character of output, represented as (pointer, cost).
  3. Utilized tape segment.

For example, the final result for bfcrunch "hello world" 70 -r -i23 is:

64: ++++[[<+>->+++++>+<<]>]
49, (45, 5), (44, 3), (45, 6), (45, 1), (45, 4), (42, 4), (43, 5), (45, 3), (45, 4), (46, 2), (44, 4)
32, 116, 100, 104, 108, 132, 0, 0, 132, 0

This corresponds to the full program:

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

Other Records

Hello, World!

Wrapping, 78 bytes:
Surpassed by @KSab (72)

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

or

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

Non-wrapping, 80 bytes (previously 92 bytes (mitchs)):
Surpassed by @KSab (76)

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

Hello, world!

Wrapping, 80 bytes:
Surpassed by @KSab (77)

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

Non-wrapping, 81 bytes (previously 92 bytes (hirose)):

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

hello, world!

Wrapping, 74 bytes:
Surpassed by @KSab (70)

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

Non-wrapping, 84 bytes:

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

Esolangs Version

Hello World!\n

Wrapping, 76 bytes:

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

This uses one cell left of home, and thus would be considered 77.

Non-wrapping, 83 bytes:

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

Rdebath approved. profilebf output:

Hello World!
Program size 83
Final tape contents:
 :   0   0  73 101 109 115 112  88  33  10   0
                                         ^
Tape pointer maximum 10
Hard wrapping would occur for unsigned cells.
Counts:     +: 720          -: 79           >: 221          <: 212
Counts:     [: 9            ]: 84           .: 13           ,: 0
Total:         1338

inversed.ru (Peter Karpov)

Hello World!

Wrapping, 70 bytes (previously 781):

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

Non-wrapping, 77 bytes (previously 89?):

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

The author claims that the shortest hand-coded "Hello World!" is 89 bytes, but provides no reference. I hereby claim the record for this, too.

hello world!

Wrapping, 65 bytes (previously 66 bytes):

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

This is actually hand-coded as well (the best I could find by crunching is 68 bytes). The first cell is initialized to 259 (3), and decremented by 7 each iteration, looping 37 times. The next cell is decremented by 6, resulting in 256 − 6·37 = 34. The rest of the cells are decremented by 4 each time, adding one cell each iteration, with each new cell inialized to 252 (-4). The result is the following:

[  3,   0,   0,   0,   0,   0,   0, ...]
[252, 250, 248,   0,   0,   0,   0, ...]
[245, 244, 244, 248,   0,   0,   0, ...]
[238, 238, 240, 244, 248,   0,   0, ...]
[231, 232, 236, 240, 244, 248,   0, ...]
[224, 226, 232, 236, 240, 244, 248, ...]
...
[ 35,  64, 124, 128, 132, 136, 140, ...]
[ 28,  58, 120, 124, 128, 132, 136, ...]
[ 21,  52, 116, 120, 124, 128, 132, ...]
[ 14,  46, 112, 116, 120, 124, 128, ...]
[  7,  40, 108, 112, 116, 120, 124, ...]
[  0,  34, 104, 108, 112, 116, 120, ...]

1 The solution given (79 bytes) can be trivially reduced by one:

-[>>+>+[++>-<<]-<+<+]>---.<<<<++.<<----..+++.>------.<<++.>.+++.------.>>-.<+.
\$\endgroup\$
11
  • 46
    \$\begingroup\$ This is nuts. One of you should submit the 82-byte version to anarchy golf. \$\endgroup\$ Jan 3, 2016 at 17:43
  • 145
    \$\begingroup\$ The best Java solution to this question is 76 bytes. Only 9 more bytes to go to prove Java developers should switch to Brainfuck. \$\endgroup\$ Jan 3, 2016 at 21:51
  • 15
    \$\begingroup\$ @LevelRiverSt The small-letters one is 2 bytes shorter than Java. The endtimes have come. \$\endgroup\$ Apr 13, 2016 at 13:59
  • 6
    \$\begingroup\$ Awesome work Primo! @CᴏɴᴏʀO'Bʀɪᴇɴ the edit was on Jan 29, nearly 4 weeks after my previous comment, and the world has not ended. Remember the fuss about Millenium Bug back in late 1999, and nothing happened in 2000? Just like then, the world remains the same, and developers are STILL using Java. WTF! \$\endgroup\$ Apr 13, 2016 at 15:52
  • 14
    \$\begingroup\$ "Only 9 more bytes to go to prove Java developers should switch to Brainfuck." interface a{static void main(String[]A){System.out.print("No!");}} \$\endgroup\$
    – SE is dead
    Jun 11, 2016 at 1:10
261
\$\begingroup\$

ArnoldC, 71 bytes

IT'S SHOWTIME
TALK TO THE HAND "Hello, World!"
YOU HAVE BEEN TERMINATED

Just for lols...

Try it online!

\$\endgroup\$
8
  • 4
    \$\begingroup\$ Worked for me. Try putting it's showtime on the first line and you have been terminated on the last line \$\endgroup\$
    – JelloDude
    Aug 28, 2015 at 14:55
  • 111
    \$\begingroup\$ I really need to learn how to use this language. \$\endgroup\$
    – Buzz
    Aug 31, 2015 at 14:29
  • 3
    \$\begingroup\$ Doesn't a space and a newline take up the same number of bytes? And technically, IT'S SHOWTIME and TALK TO THE HAND should be on the first and last lines. \$\endgroup\$
    – wizzwizz4
    Dec 29, 2015 at 10:33
  • 7
    \$\begingroup\$ @AlCode But it's more correct and takes up the same number of bytes and there is more compatibility and it looks nicer and why am I making a fuss this is a code golf challenge on PPCG and it is a surprise that your code is readable and well done you made a well golfed answer that was readable and +1. \$\endgroup\$
    – wizzwizz4
    Sep 6, 2016 at 15:36
  • 13
    \$\begingroup\$ @wizzwizz4 thank your very much, I try to be as professional as possible with ArnoldC the language of the future! \$\endgroup\$
    – AlCode
    Sep 8, 2016 at 11:59
243
+500
\$\begingroup\$

Seed, 6016 4234 4203 bytes

20 854872453003476740699221564322673731945828554947586276010721089172712854441839676581917455319274850944955030258951339804246125714958815519550291630078076933441706558540342671975808828643360922071900333028778314875248417953197990571991784126564752005357199892690656368640420204822142316716413192024742766282266114842280731756458212469988291309261528542889299297601723286769284159107438930448971911102280330101196758384815655479640836157495863547199726234352265518586460633795171196315255736880028338460236768181141732764911402112878175632130129852788301009582463631290071329795384336617491655825493435803011947670180368458659271192428341035912236946048939139042310380278430049252171822721598175984923434205610723412240162418996808671543770639111617709604242882388664919702606792443015941265168129550718541372361144081848761690730764968771245566074501485020726368378675085908872608679630368472956274468410052703615106090238423979678950131481176272880569100533049143775921798055136871254424261001442543122666701145111965968366507060931708140304772342855064834334129143038575569044150428480231956133612367393837580345180691911525531699573096952433882387811884727975431823620782822755161559988205401134640722220804177812794328129589949692446031008866917615922944976151073653201316255518389496411696741029209242119521978920200314572718584995265523235225587228975886710511855501710470163649632761488899317729943053884132314641377747687975638119132094777769497069556255954031537245957811105217875011509899497752696062748928963281605780942517262774976217663461063680912331030221981433051827519906741285738915397005702326447635845195923640649166530310494885569783989508000344280715868581532826832242144647203531393142251025361866506821695860883605004105862208004440476654027574832078603305884731766236740069411566854496824754558761536201352147934963241039597221404341132342297870517293237489233057335406510464277610336142382379135365550299895416613763920950687921780736585299310706573253951966294045814905727514141733220565108490291792987304210662448111170752411153136765318541264632854767660676223663544921028492602135525959428999005153729028491208277493747933069008199074925710651071766675870081314909460661981433426167330215548196538791617762566403934129026219366764038390123622134753742930729751695349588862441999672547791630729398908283091638866715502470152431589429837867944760012419885615525232399584379209285060418518373512154801760060312646951597932345591416241634668119867158079946680321131213357200382937049485606706114467095019612014749723443159443363662563254359712162432143334612180576945072905749883870150120687696027984317320305291407322779803583395375616762530641605634303022155218169343410634115050596030685041633824154135240376022159918501703555881290333205131375705406831260759974112248490451605422031345264183102048614606636275942039438138959188478277971377232005036301145411215067576576667743288951344423152531417111852584846747428443123174595987315325304540564683047858415059703724263652136185848573853965992798725654430360647040362341567082462847275277303225817689141675391972818943419663764371222973269129542760661385278009266471167618553065823580448848795731295589715602705860758954890415040763604082216728159486423396295188510311881004469017351709060492844398219491990895826924575575549615118821417543037296628825303328056839433114519945243963946989899508355224823109677424196639930153649890175062456649384605721510239142861693109687536600667811037619175927995599388547421689316110236566026931360164495251160997857372500940728057700473763884480342708897319990346726967220426504612260565552531158509215849649565188655100774748485416791517853427613458459889062942881409801879085054494129489535044719193283409051007851153504224002807392992520076910314763705776345053922387355156981872691537772657428096384535960466923475731297217863371650154415835785630016335858514130863258775100537612371430357576913148500310344278511588325852376442503898849856566716198848377379400158332792027967216204970114516984638014129252882482309132898416484525230488700253065644547798869056136044415413099076332059572505138116227535024546891015836838323022822272664771489129085797354578016574544759934333471793

Try it online! The resulting Befunge-98 program (based on this) is

"9!dlroW ,olleH"ck,@

Try it online!

\$\endgroup\$
33
  • 42
    \$\begingroup\$ Wow! How did you find this? \$\endgroup\$ Oct 28, 2016 at 15:04
  • 36
    \$\begingroup\$ What. That's insane. \$\endgroup\$ Oct 31, 2016 at 14:33
  • 62
    \$\begingroup\$ HOW DID YOU GOLF THIS? \$\endgroup\$ Oct 31, 2016 at 23:55
  • 61
    \$\begingroup\$ Did you reverse engineer the mersenne twister? And does this have any security implications? \$\endgroup\$
    – primo
    Nov 1, 2016 at 14:37
  • 93
    \$\begingroup\$ I'll give you another +500 for a detailed (theoretical) explanation. \$\endgroup\$
    – primo
    Nov 14, 2016 at 12:51
184
\$\begingroup\$

Mornington Crescent, 3614 3568 bytes

Thanks to NieDzejkob for saving 46 bytes by using shorter line names.

Take Northern Line to Hendon Central
Take Northern Line to Bank
Take Circle Line to Bank
Take District Line to Gunnersbury
Take District Line to Victoria
Take Victoria Line to Seven Sisters
Take Victoria Line to Victoria
Take Circle Line to Victoria
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Cannon Street
Take Circle Line to Hammersmith
Take Circle Line to Cannon Street
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to Paddington
Take District Line to Acton Town
Take Piccadilly Line to Holloway Road
Take Piccadilly Line to Acton Town
Take District Line to Acton Town
Take District Line to Gunnersbury
Take District Line to Hammersmith
Take Circle Line to Notting Hill Gate
Take District Line to Upminster
Take District Line to Notting Hill Gate
Take District Line to Upminster
Take District Line to Victoria
Take Victoria Line to Seven Sisters
Take Victoria Line to Victoria
Take Circle Line to Victoria
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to Mile End
Take District Line to Hammersmith
Take Circle Line to Notting Hill Gate
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Mile End
Take District Line to Paddington
Take Circle Line to Paddington
Take District Line to Acton Town
Take Piccadilly Line to Heathrow Terminals 1, 2, 3
Take Piccadilly Line to Holborn
Take Central Line to Holborn
Take Central Line to Mile End
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Barking
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to Barking
Take District Line to Gunnersbury
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Wood Lane
Take Circle Line to Victoria
Take Circle Line to Victoria
Take District Line to Gunnersbury
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to Paddington
Take Circle Line to Paddington
Take District Line to Mile End
Take Central Line to Fairlop
Take Central Line to Mile End
Take District Line to Barking
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Hammersmith
Take Circle Line to Notting Hill Gate
Take District Line to Upminster
Take District Line to Mile End
Take District Line to Gunnersbury
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take District Line to Mile End
Take District Line to Richmond
Take District Line to Mile End
Take District Line to Paddington
Take Circle Line to Paddington
Take District Line to Richmond
Take District Line to Bank
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Stepney Green
Take District Line to Hammersmith
Take District Line to Stepney Green
Take District Line to Upney
Take District Line to Notting Hill Gate
Take Circle Line to Notting Hill Gate
Take Circle Line to Notting Hill Gate
Take District Line to Upminster
Take District Line to Upney
Take District Line to Upminster
Take District Line to Bank
Take Circle Line to Bank
Take Northern Line to Charing Cross
Take Bakerloo Line to Charing Cross
Take Bakerloo Line to Paddington
Take Circle Line to Bank
Take Circle Line to Bank
Take Northern Line to Mornington Crescent

Try it online!

This is most certainly suboptimal, but it's half the size of the solution on esolangs.

Hello, World is constructed via slicing the following station names and concatenating the results:

Hendon Central
▀▀
Holloway Road
  ▀▀▀
Heathrow Terminals 1, 2, 3
                       ▀▀
Wood Lane
▀▀
Fairlop
   ▀▀
Richmond
       ▀

Finally, I'm computing the character code of ! as (2<<4)+1 == 33. All these parts are concatenated in Paddington and finally printed in Mornington Crescent.

Note: The language doesn't specify whether it's possible to travel to same station twice in a row, but the interpreter does allow it, so I've made use of it.

\$\endgroup\$
16
  • 56
    \$\begingroup\$ This is absolutely brilliant :D \$\endgroup\$
    – Beta Decay
    Sep 4, 2015 at 18:03
  • 41
    \$\begingroup\$ I love this language. Excuse me, while I do systems programming in this language. \$\endgroup\$
    – cat
    Dec 20, 2015 at 3:46
  • 6
    \$\begingroup\$ Where on EARTH has this language been all my life? \$\endgroup\$ Jul 11, 2017 at 23:04
  • 47
    \$\begingroup\$ @ScottMcGready between Camden Town and Euston. \$\endgroup\$ Jul 12, 2017 at 11:25
  • 5
    \$\begingroup\$ Mornington Crescent is on TIO now. tio.run/#mornington-crescent \$\endgroup\$
    – Dennis
    Sep 13, 2017 at 3:13
162
+1000
\$\begingroup\$

brainfuck, 72 bytes

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

Try it online!

And the original non-wrapping 76 byte solution:

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

Try it online!

Other shortest known (to my knowledge) solutions I've found

'Hello, world!' 77 bytes:

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

Try it online!

'hello, world!' 70 bytes:

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

Try it online!


These were found using a c++ program I wrote here: https://github.com/ksabry/bfbrute

Note: I originally wanted to clean up this code before I posted it to make it actually somewhat readable and usable, but since I haven't gotten around to it in over a year I figure I'll just post it as is. It makes heavy use of templates and compile time constants for any potential optimizations and it has a bunch of commented out code from my testing but no helpful comments so sorry but it's a bit horrible.

There is nothing terribly clever about the code, it's brute forcer at it's core, however it is quite optimized. The major optimization is that it first iterates through all programs without loops (no [ or ]) up to a specified length (16 currently) and caches an array of all the changes it will make on the data array. It will only store a single program per unique array of changes so for example only one of >+<<-> and <->>+< will be stored. It then iterates through all possible programs which are composed of any program in this cache with any combination of loops between them. After executing each program it does a simple greedy hunt and peck for the characters and appends this to the end of the program.

After running this through the space of all programs I noticed that almost all the shortest programs (up to length ~19) were of the form *[*[*]*]. Restricting the search to programs of this form sped up the search considerably. The current record holder was found at length 27. This one was actually computed to be length 74, but I noticed a particular sequence .>.>.>. which was lucky enough to have a 0 in the data cell to it's right allowing it to be simplified to [.>]< bringing it down to 72.

I let it run for quite awhile and completed the search with the current parameters up to length 29, I suspect it will be difficult to beat the current one by simply going higher, I think the most promising approach would probably be increasing the search space in some intelligent way.

\$\endgroup\$
16
  • 38
    \$\begingroup\$ How on Earth did you find this? \$\endgroup\$
    – Dennis
    Apr 27, 2018 at 18:50
  • 50
    \$\begingroup\$ Hey you beat Java. \$\endgroup\$
    – Poke
    Apr 27, 2018 at 19:20
  • 21
    \$\begingroup\$ That's some device, it doesn't even require wrapping cells ó_Ò \$\endgroup\$
    – primo
    Apr 28, 2018 at 12:08
  • 5
    \$\begingroup\$ Would love to see the algorithm behind this :) \$\endgroup\$ May 5, 2018 at 3:40
  • 3
    \$\begingroup\$ Does someone still have bfbrute's source code? Github link is down..... \$\endgroup\$
    – apollyon
    Mar 22, 2022 at 14:58
138
\$\begingroup\$

evil, 70 bytes

aeeeaeeewueuueweeueeuewwaaaweaaewaeaawueweeeaeeewaaawueeueweeaweeeueuw

Try it online!

It uses the following four commands:

a - increment the register
u - decrement the register
e - interweave the register's bits (01234567 -> 20416375)
w - write the value of the register as an ASCII character
\$\endgroup\$
8
  • 72
    \$\begingroup\$ That is evil... \$\endgroup\$ Sep 1, 2015 at 14:18
  • 70
    \$\begingroup\$ Especially since your avatar is Black Hat. \$\endgroup\$
    – TheDoctor
    Sep 1, 2015 at 23:47
  • 5
    \$\begingroup\$ can u explain me the interweave process. \$\endgroup\$ Nov 4, 2015 at 14:25
  • 4
    \$\begingroup\$ @KishanKumar yes \$\endgroup\$
    – grc
    Nov 4, 2015 at 16:12
  • 41
    \$\begingroup\$ If you read this program out loud, it sounds like a dubstep bass. \$\endgroup\$
    – Joe Z.
    Jun 17, 2016 at 15:04
96
\$\begingroup\$

Piet, 90 codels

enter image description here

This is a 30 by 3 image. Alternatively, at codel size 10:

enter image description here

The uses a 3-high layout so that I only need to pointer once. If this is still golfable I could probably shave at most another column, since there's a push-pop no-op in there.

Edit: @primo's 84 codel solution.

\$\endgroup\$
17
  • 6
    \$\begingroup\$ Trying to take your own bounty? I thought more of you Sp3000 ;) \$\endgroup\$
    – Beta Decay
    Sep 2, 2015 at 11:18
  • 8
    \$\begingroup\$ Hah, just because I set a bounty doesn't mean I can't join in the fun :P \$\endgroup\$
    – Sp3000
    Sep 2, 2015 at 11:29
  • 10
    \$\begingroup\$ A push-pop isn't a no-op to me. It's this. \$\endgroup\$
    – mbomb007
    Feb 24, 2016 at 19:46
  • 1
    \$\begingroup\$ What the hell is this "language"? I love it! \$\endgroup\$ Oct 11, 2016 at 12:50
  • 10
    \$\begingroup\$ "push-pop no-op" is now my favourite phrase \$\endgroup\$ Jan 20, 2017 at 22:27
95
\$\begingroup\$

Haystack, 17 Bytes

Haystack is a 2D programming language that executes until it finds the needle in the haystack |, all while performing stack-based operations. All programs start from the top left corner, and can use the directional characters ><^v to move around the program. Direction is inherited, so you do not need to keep using > to go right, direction will only change when it hits a different directional character.

By default, the interpreter reads from the top left going right, so we can just put "Hello, World!" onto the stack, use o to print it, then place the needle to finish executing.

"Hello, World!"o|

Try it online!

Bonus: A more exciting version:

v      >;+o|
v      "
v      !
v      d
v      l
v      r
>>"Hello, ">>>v
       W      v
       "      v
       ^<<<<<<<
\$\endgroup\$
8
  • \$\begingroup\$ Just out of curiosity, what happens if you include one of the characters in a string? \$\endgroup\$
    – Random832
    Aug 28, 2015 at 16:34
  • \$\begingroup\$ @Random832 In a string, directional characters are treated as regular characters, i.e. you can include them in a string. \$\endgroup\$
    – Kade
    Aug 28, 2015 at 17:23
  • 50
    \$\begingroup\$ >;+o​​​​​​​​​​​ \$\endgroup\$
    – bjb568
    Sep 13, 2015 at 0:10
  • 4
    \$\begingroup\$ I wish I was half as smart as everyone here, but in the "documentation" (read: some guy's forum post) it says o outputs as a number. Shouldn't it be c at the end? Is there proper documentation anywhere? This is super interesting! \$\endgroup\$ Jan 15, 2016 at 15:49
  • 4
    \$\begingroup\$ @Scott Super late to reply to this, that forum post was probably me! o outputs the top stack item as-is, i.e. if a number is there it prints that. c would simply cast that to a char. So, if you have a string or char on the top of the stack o would be what you want :) Eventually these docs will be updated.. \$\endgroup\$
    – Kade
    Oct 3, 2016 at 13:17
81
\$\begingroup\$

Help, WarDoq!, 1 byte

H

Not only does Help, WarDoq! have a built-in for most common spellings of the phrase, it even satisfies our usual definition of programming language.

Try it in the official online interpreter (code goes in Input).

\$\endgroup\$
9
  • 8
    \$\begingroup\$ So, HQ9++, essentially, eh? ;-) \$\endgroup\$ Aug 28, 2015 at 13:52
  • 8
    \$\begingroup\$ @TimmyD Nope, not HQ9++. \$\endgroup\$
    – Dennis
    Aug 28, 2015 at 13:58
  • 33
    \$\begingroup\$ Oh for crying out loud. Is there anything that isn't an esolang at this point? :) \$\endgroup\$ Aug 28, 2015 at 14:22
  • 119
    \$\begingroup\$ "Space: Begin a comment. The next non-space character ends the comment and is interpreted as usual." So you can only have comments made of spaces then??? I suppose even the most useful language in the world has to have one unuseful feature +1, \$\endgroup\$ Aug 29, 2015 at 18:44
  • 34
    \$\begingroup\$ @steveverrill Maybe if tabs are also considered as comments, then we can have the comments written as Whitespace programs \$\endgroup\$
    – Optimizer
    Sep 3, 2015 at 19:12
75
\$\begingroup\$

MarioLANG, 259 249 242 240 235 bytes

+>+>)+)+)+++)++++((((-[!)>->.
+"+"===================#+".")
+++!((+++++++++)++++++)<.---+
++=#===================")---.
++((.-(.)).+++..+++++++.<---
 !+======================---
=#>++++++++++++++.).+++.-!>!
  =======================#=#

Try it online!

This has been tested in the Ruby implementation.

After obfuscating "Hello, World!" in MarioLANG I looked into golfing it a bit. The above is the shortest I have found so far.

As before I started from a Brainfuck solution which sets four cells to the nearest multiple of 10 to the characters He, and space and converted it to MarioLANG. You can then shorten the code a bit by making use of the auxiliary floor in the loop which almost halves the width of the loop. Note that the bottom is only executed one time less than the top, so you don't get exact multiples of the initial counter in all 4 cells any more.

Finally, I wanted to make use of the wasted space in front of the loop, so I added a bunch of elevators to make use of the vertical space there. And then I realised that I could fold the code after the loop (see previous revision) below the loop to make use of some more vertical space, which saved five more bytes.

This is likely still far from perfect, but it's a decent improvement over the naive solution, I think.

Metagolf

Time for some automation...

I have started setting up a solver in Mathematica to find an optimal solution. It currently assumes that the structure of the code is fixed: counter set to 12, 4 cells for printing, with the fixed assignment to He,<space> and the same order of those cells. What it varies is the number of +s in the loop as well as the necessary corrections afterwards:

n = 12;
Minimize[
 {
  3(*lines*)+
   12(*initialiser base*)+
   Ceiling[(n - 6)/2] 3(*additional initialiser*)+
   8(*loop ends*)+
   18(*cell moves*)+
   26(*printing*)+
   43*2(*steps between letters in one cell*)+
   -2(*edge golf*)+
   4 Max[4 + a + d + g + j + 2 Sign[Sign@g + Sign@j] + 2 Sign@j + 2,
     4 + b + e + h + k + 2 Sign[Sign@h + Sign@k] + 2 Sign@k] +
   2 (Abs@c + Abs@f + Abs@i + Abs@l),
  a >= 0 && d >= 0 && g >= 0 && j >= 0 &&
   b >= 0 && e >= 0 && h >= 0 && k >= 0 &&
   n*a + (n - 1) b + c == 72 &&
   n*d + (n - 1) e + f == 101 &&
   n*g + (n - 1) h + i == 44 &&
   n*j + (n - 1) k + l == 32
  },
 {a, b, c, d, e, f, g, h, i, j, k, l},
 Integers
 ]

It turns out, that for an initial counter of 12 my handcrafted solution is already optimal. However, using 11 instead saves two bytes. I tried all counter values from 6 to 20 (inclusive) with the following results:

6: {277,{a->7,b->6,c->0,d->16,e->1,f->0,g->0,h->9,i->-1,j->0,k->6,l->2}}
7: {266,{a->6,b->5,c->0,d->11,e->4,f->0,g->2,h->5,i->0,j->0,k->5,l->2}}
8: {258,{a->2,b->8,c->0,d->3,e->11,f->0,g->5,h->0,i->4,j->4,k->0,l->0}}
9: {253,{a->8,b->0,c->0,d->5,e->7,f->0,g->2,h->3,i->2,j->0,k->4,l->0}}
10: {251,{a->0,b->8,c->0,d->3,e->8,f->-1,g->4,h->0,i->4,j->3,k->0,l->2}}
11: {240,{a->1,b->6,c->1,d->1,e->9,f->0,g->4,h->0,i->0,j->3,k->0,l->-1}}
12: {242,{a->6,b->0,c->0,d->6,e->3,f->-4,g->0,h->4,i->0,j->0,k->3,l->-1}}
13: {257,{a->1,b->5,c->-1,d->6,e->2,f->-1,g->3,h->0,i->5,j->0,k->3,l->-4}}
14: {257,{a->1,b->4,c->6,d->0,e->8,f->-3,g->3,h->0,i->2,j->2,k->0,l->4}}
15: {242,{a->1,b->4,c->1,d->3,e->4,f->0,g->1,h->2,i->1,j->2,k->0,l->2}}
16: {252,{a->0,b->5,c->-3,d->4,e->2,f->7,g->0,h->3,i->-1,j->2,k->0,l->0}}
17: {245,{a->4,b->0,c->4,d->5,e->1,f->0,g->0,h->3,i->-4,j->0,k->2,l->0}}
18: {253,{a->4,b->0,c->0,d->1,e->5,f->-2,g->2,h->0,i->8,j->0,k->2,l->-2}}
19: {264,{a->0,b->4,c->0,d->5,e->0,f->6,g->2,h->0,i->6,j->0,k->2,l->-4}}
20: {262,{a->0,b->4,c->-4,d->5,e->0,f->1,g->2,h->0,i->4,j->0,k->2,l->-6}}

Note: This solver assumes that the linear code after the loop is all on the top line, and the above code is that solution folded up. There might be a shorter overall solution by making the solver aware of the folding, because now I get 3 more +s in the first part for free, and the next 4 instructions would cost only 1 byte instead of 2.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ @justhalf You should see my Pada answer. :P \$\endgroup\$ Aug 29, 2015 at 14:49
  • \$\begingroup\$ Martin I love this answer. Would you consider making a post about this at our official forum ? We use the same as stackexchange editor. Our editorial would like to add it to Staff Picks. \$\endgroup\$ Sep 20, 2017 at 15:24
72
\$\begingroup\$

Dark, 106 bytes

+h hell
h$twist sign s
s$scrawl " Hello, World!
s$read
h$twist stalker o
o$stalk
o$personal
o$echo
h$empty

I'll just let some quotes from the language specification speak for the brilliance of this esolang:

Dark is a language based on manipulating entire worlds and dimensions to achieve goals and to build the best torturous reality possible.

Whenever a syntax error occurs, the program's sanity decreases by 1. [...] If the program's sanity reaches zero, the interpreter goes insane.

Corruption flips a single bit in the variable when it occurs.

When the master dies, all servant variables attached to that master also die. This is useful for grouping and mass killing variables.

Forces a variable to kill itself, freeing it (remember though that it will leave decay).

Sets a variable to a random value. Uses the Global Chaos Generator.

If a stalker is not initialized, any attempts to perform IO will result in depressing error messages to be written to the console.

\$\endgroup\$
4
  • 42
    \$\begingroup\$ This language is so metal. \$\endgroup\$
    – Alex A.
    Sep 2, 2015 at 19:53
  • 10
    \$\begingroup\$ If we had to list programming languages in order of evilness, Dark would top evil. \$\endgroup\$
    – LukStorms
    Oct 2, 2015 at 11:21
  • 45
    \$\begingroup\$ there is hell in hello \$\endgroup\$
    – Khaled.K
    Dec 13, 2015 at 8:13
  • \$\begingroup\$ super evil, you can even raise an army of walking gotos \$\endgroup\$
    – bobrobbob
    Jun 11, 2018 at 12:48
71
\$\begingroup\$

Homespring, 58 bytes

Universe net hatchery Hello,. World!  powers a b snowmelt 

Try it online!

The trailing space is significant.

Let me tell you a story. There was once a power plant which powered a nearby salmon hatchery. The salmon hatchery hatched a young homeless salmon which embarked on a journey upriver to find a spring. It did find such a spring, with the poetic name "Hello, World!", where it matured and spawned a new young salmon. Both fish now swam downstream, in search of the wide ocean. But just short of the mouth of the river, there was a net in the river - the mature fish was caught and only the young one managed to slip through and reached the ocean and the rest of the universe. In the meantime, the hatchery had hatched more salmon which had travelled upstream as well and spawned and so on and so on.

However, vast amounts of melting snow had been travelling down a different arm of the river. And just after our first young salmon from the springs of "Hello, World!" has reached the ocean, the snowmelt hit the universe and... uh... destroyed it. And they lived happily ever after... or I guess they didn't.

Those were actually the semantics of the above program. Homespring is weird.

\$\endgroup\$
5
  • 20
    \$\begingroup\$ This is...weird... \$\endgroup\$ Sep 3, 2015 at 22:35
  • 13
    \$\begingroup\$ I haz found a new favorite salmon-powered universe destroyer...uh...I mean "Hello, World!" program. +1 \$\endgroup\$ Nov 21, 2015 at 18:58
  • 8
    \$\begingroup\$ Every time I come back to this, I have a good laugh. Thanks for creating possibly the most entertaining Hello, World! program of all time. \$\endgroup\$ Mar 14, 2016 at 16:18
  • 3
    \$\begingroup\$ This is my new favorite language. \$\endgroup\$
    – univalence
    Jul 8, 2017 at 12:23
  • \$\begingroup\$ tio.run/#homespring \$\endgroup\$
    – Dennis
    Apr 28, 2018 at 4:47
66
\$\begingroup\$

Chef, 465 bytes

H.

Ingredients.
72 l h
101 l e
108 l l
111 l o
44 l C
32 l S
87 l w
114 l r
100 l d
33 l X

Method.
Put X into mixing bowl.Put d into mixing bowl.Put l into mixing bowl.Put r into mixing bowl.Put o into mixing bowl.Put w into mixing bowl.Put S into mixing bowl.Put C into mixing bowl.Put o into mixing bowl.Put l into mixing bowl.Put l into mixing bowl.Put e into mixing bowl.Put h into mixing bowl.Pour contents of the mixing bowl into the baking dish.

Serves 1.

Try it online!

Tested with the Ruby interpreter. Makes alphabet soup.

I tried to be as compliant to the original spec as I could, so even though the interpreter I used lets you drop the thes in the Pour contents instruction, I haven't done so.

The mixing bowl is pretty expensive, so there might be a better approach. I tried using base conversion to encode the message, but unfortunately the spec doesn't clarify whether Divide uses integer or floating point division, and the interpreter I have uses the latter. There's also no modulo operator, which doesn't help either.

\$\endgroup\$
3
  • 22
    \$\begingroup\$ If anyone could golf in Chef it's Sp. \$\endgroup\$
    – Alex A.
    Aug 28, 2015 at 16:47
  • 13
    \$\begingroup\$ Now try golfing recipes in real life. :D \$\endgroup\$
    – mbomb007
    Jan 15, 2016 at 19:24
  • 2
    \$\begingroup\$ Lol, this is not only not good to eat, but also uses non-standard measuring units. XD \$\endgroup\$ Jun 29, 2016 at 20:28
65
+200
\$\begingroup\$

Piet, 84 codels

Piet Hello World

28x3, here shown with codel width 10.

Created with PietDev (zip), tested with npiet. The layout of the program is the following:

Piet Layout

Yellow fill indicates codels where the path overlaps, orange fill indicates codels which must be the same color, for purposes of control flow.

To aid in the creation of this, I wrote a rudimentary interpreter for a stack-based language with piet-like commands, which I have dubbed "pasm" (source). The output from this interpreter (with this input) is the following:

    1 nop     blu1 []
    4 push 3  blu2 [3]
    5 dup     grn2 [3, 3]
    6 add     cyn2 [6]
    7 dup     ylw2 [6, 6]
    8 mul     grn1 [36]
    9 dup     red1 [36, 36]
   10 dup     blu1 [36, 36, 36]
   11 add     mgn1 [36, 72]
H  12 putc    blu0 [36]
   15 push 3  blu1 [36, 3]
   16 sub     mgn2 [33]
   17 dup     cyn2 [33, 33]
   20 push 3  cyn0 [33, 33, 3]
   21 mul     blu2 [33, 99]
   22 push 1  blu0 [33, 99, 1]
   23 add     mgn0 [33, 100]
   24 dup     cyn0 [33, 100, 100]
   25 push 1  cyn1 [33, 100, 100, 1]
   26 add     blu1 [33, 100, 101]
e  27 putc    cyn0 [33, 100]
   28 dup     ylw0 [33, 100, 100]
   32 push 4  ylw1 [33, 100, 100, 4]
   33 dup     mgn1 [33, 100, 100, 4, 4]
   34 add     red1 [33, 100, 100, 8]
   35 add     ylw1 [33, 100, 108]
   36 dup     mgn1 [33, 100, 108, 108]
l  37 putc    blu0 [33, 100, 108]
   38 dup     grn0 [33, 100, 108, 108]
l  39 putc    ylw2 [33, 100, 108]
   40 dup     mgn2 [33, 100, 108, 108]
   43 push 3  mgn0 [33, 100, 108, 108, 3]
   44 add     red0 [33, 100, 108, 111]
   45 dup     blu0 [33, 100, 108, 111, 111]
o  46 putc    cyn2 [33, 100, 108, 111]
   47 dup     ylw2 [33, 100, 108, 111, 111]
   48 dup     mgn2 [33, 100, 108, 111, 111, 111]
   53 push 5  mgn0 [33, 100, 108, 111, 111, 111, 5]
   54 div     ylw0 [33, 100, 108, 111, 111, 22]
   55 dup     mgn0 [33, 100, 108, 111, 111, 22, 22]
   56 add     red0 [33, 100, 108, 111, 111, 44]
   57 dup     blu0 [33, 100, 108, 111, 111, 44, 44]
,  58 putc    cyn2 [33, 100, 108, 111, 111, 44]
   59 dup     ylw2 [33, 100, 108, 111, 111, 44, 44]
   60 add     grn2 [33, 100, 108, 111, 111, 88]
   64 push 4  grn0 [33, 100, 108, 111, 111, 88, 4]
   65 dup     red0 [33, 100, 108, 111, 111, 88, 4, 4]
   66 mul     ylw2 [33, 100, 108, 111, 111, 88, 16]
   67 dup     mgn2 [33, 100, 108, 111, 111, 88, 16, 16]
   68 add     red2 [33, 100, 108, 111, 111, 88, 32]
   69 putc    mgn1 [33, 100, 108, 111, 111, 88]
   70 push 1  mgn2 [33, 100, 108, 111, 111, 88, 1]
   71 sub     red0 [33, 100, 108, 111, 111, 87]
W  72 putc    mgn2 [33, 100, 108, 111, 111]
o  73 putc    blu1 [33, 100, 108, 111]
   76 push 3  blu2 [33, 100, 108, 111, 3]
   77 add     mgn2 [33, 100, 108, 114]
r  78 putc    blu1 [33, 100, 108]
l  79 putc    cyn0 [33, 100]
d  80 putc    grn2 [33]
!  81 putc    ylw1 []

No pointer, switch, or roll commands are used. No codels are wasted either; in fact two are reused.

\$\endgroup\$
5
  • \$\begingroup\$ Congrats, you got my bounty :) \$\endgroup\$ Dec 25, 2015 at 12:19
  • \$\begingroup\$ @LegionMammal978 Thanks, it was fun to work on. And merry christmas :) \$\endgroup\$
    – primo
    Dec 25, 2015 at 12:25
  • 16
    \$\begingroup\$ This is what hollywood should show on "hacker" screens. \$\endgroup\$
    – Hugo G
    May 29, 2017 at 16:09
  • \$\begingroup\$ Your pasm source link is dead. But I like the whole idea. Can you put the source somewhere accessible? \$\endgroup\$ Apr 21, 2021 at 1:09
  • \$\begingroup\$ @JerryJeremiah rehosted. The reason for making this, is that I had to ensure that 53 and 55 were both the same color and shade, as well as 27 and 79. \$\endgroup\$
    – primo
    Apr 24, 2021 at 6:30
63
\$\begingroup\$

HTML, 13 bytes

Hello, World!

The text is automatically inserted into the <body>, and is displayed.

\$\endgroup\$
17
  • 192
    \$\begingroup\$ Wow. That's some really hardcore coding skills \$\endgroup\$
    – BlueWizard
    Aug 28, 2015 at 22:06
  • 54
    \$\begingroup\$ HTML is not a programming language, but a markup language (that's why it ends with ML). \$\endgroup\$
    – CodeManX
    Sep 3, 2015 at 0:17
  • 40
    \$\begingroup\$ But HTML isn't printed in STDOUT. \$\endgroup\$ Sep 4, 2015 at 5:44
  • 33
    \$\begingroup\$ -1 HTML Doesn't meet the requirements for a valid language \$\endgroup\$
    – Downgoat
    Sep 8, 2015 at 0:25
  • 166
    \$\begingroup\$ -1 not enough jQuery \$\endgroup\$ Jun 1, 2016 at 19:40
57
\$\begingroup\$

CSS, 30 bytes

:after{content:"Hello, World!"

Cascading Style Sheets (CSS) isn't a typical programming language, but it can do fixed output fairly well. This is done by creating a pseudo-element after every element with the content Hello, World!. So only one element (<html>) is selected, this assumes that we're using the most basic HTML document, i.e.

<html><style>:after{content:"Hello, World!"</style></html>

This works in most major browsers, with the notable exception of Firefox, which applies the selector to the <html> and <body> elements. This is also why Stack snippets don't work, because there is always a body element that gets styled as well. Below is a slightly modified version to test.

* :after{content:"Hello, World!"

\$\endgroup\$
9
  • 3
    \$\begingroup\$ You can also use * * to select body. \$\endgroup\$
    – jimmy23013
    Aug 31, 2015 at 7:50
  • 21
    \$\begingroup\$ @jimmy23013 That sounds gloriously inefficient. Thanks \$\endgroup\$ Aug 31, 2015 at 18:09
  • 1
    \$\begingroup\$ For whatever reasons * :after also seemed to work. \$\endgroup\$
    – jimmy23013
    Sep 1, 2015 at 2:20
  • 12
    \$\begingroup\$ I'm asking my self which of the letters in CSS is the abrreviation for "language". \$\endgroup\$
    – Zaibis
    Sep 7, 2015 at 14:27
  • 17
    \$\begingroup\$ @zaibis the same letter for PHP probably :) \$\endgroup\$ Feb 2, 2017 at 22:55
56
\$\begingroup\$

Java, 79

class H{public static void main(String[]a){System.out.print("Hello, World!");}}

Try it online!

Earlier versions of Java may allow you to use a static block (51 bytes), but currently I don't know of a way to bypass the main method.

\$\endgroup\$
14
  • 9
    \$\begingroup\$ Use enum instead of class. \$\endgroup\$ Aug 29, 2015 at 7:41
  • 6
    \$\begingroup\$ @ThomasEding What compiler does that actually work on? I've tried this tip on several, and have never been able to save bytes with it. \$\endgroup\$
    – Geobits
    Aug 29, 2015 at 15:57
  • 5
    \$\begingroup\$ @Luminous Ah, it might have worked for 1.5. I'm not going to install it to find out, though, but stick to something released in the last 10 years. If I never see Java 5 again it'll be a nice life :) \$\endgroup\$
    – Geobits
    Sep 1, 2015 at 13:34
  • 2
    \$\begingroup\$ @TheDoctor From what I've seen, Processing is usually seen as a separate language here. You should post it as an answer, or at least ask for clarification from the OP. \$\endgroup\$
    – Geobits
    Sep 2, 2015 at 0:41
  • 6
    \$\begingroup\$ User OptiFine suggested saving 3 bytes by using an interface and ditching the public specifier. I've rejected the edit following policy but since they can't comment, I thought I'd let you know so you can use it if you like. \$\endgroup\$ Apr 7, 2016 at 9:09
55
\$\begingroup\$

Whitespace, 192 150 146 bytes

Whitespace only needs spaces, tabs and linefeeds while other characters are ignored.
Which can be troublesome to display on here.
So in the code below the spaces & tabs were replaced.
And a ';' was put in front of the linefeeds for clarity.
To run the code, first replace . and > by spaces and tabs.

...;
..>>..>.>.;
..>>>>;
...>;
...>>>;
...>..;
..>>.>..;
..>>..>.>>;
..>>>>>>>;
...>..;
...>;
.;
...>>>.;
..>>...>>;
;
..;
.;
.;
>.>;
...>>.>.>>;
>...>;
..;
.;
;
;
..>;
;
;
;

Try it online!

Hexdump of code

00000000: 2020 200a 2020 0909 2020 0920 0920 0a20
00000010: 2009 0909 090a 2020 2009 0a20 2020 0909
00000020: 090a 2020 2009 2020 0a20 2009 0920 0920
00000030: 200a 2020 0909 2020 0920 0909 0a20 2009
00000040: 0909 0909 0909 0a20 2020 0920 200a 2020
00000050: 2009 0a20 0a20 2020 0909 0920 0a20 2009
00000060: 0920 2020 0909 0a0a 2020 0a20 0a20 0a09
00000070: 2009 0a20 2020 0909 2009 2009 090a 0920
00000080: 2020 090a 2020 0a20 0a0a 0a20 2009 0a0a
00000090: 0a0a

Whitespace assembly code:

push 0      ;null
push -74    ;! chr(33)
push -7     ;d chr(100)
push 1      ;l chr(108)
push 7      ;r chr(114)
push 4      ;o chr(111)
push -20    ;W chr(87)
push -75    ;  chr(32)
push -63    ;, chr(44)
push 4      ;o
push 1      ;l
dup         ;l
push -6     ;e chr(101)
push -35    ;H chr(72)
p:
 dup jumpz e
 push 107 add printc
 jump p
e:
 exit

Remarks:

I had to write a program just to calculate that adding 107 gives the optimal golf for the sentence. Since the bytesize that an integer takes in the code changes. : 4+int(abs(log2($n)))
The code will still run without the "e:" label & exit part on whitespace.kauaveel.ee. But that could make the whitespace code invalid on other whitespace compilers. So those bytes weren't golfed out from the solution.

It Should Be Noted That

As Kevin Cruijssen pointed out in the comments, by allowing an "exit by error" as per meta, the Whitespace can be golfcoded more to 126 characters.

..>>..>.>.;
..>>>>;
...>;
...>>>;
...>..;
..>>.>..;
..>>..>.>>;
..>>>>>>>;
...>..;
...>;
.;
...>>>.;
..>>...>>;
;
..;
...>>.>.>>;
>...>;
..;
.;
;

Try it online!

Assembly:

push -74
push -7
push 1
push 7
push 4
push -20
push -75
push -63
push 4
push 1
dup
push -6
push -35
label_0:
push 107
add 
printc
jmp label_0
\$\endgroup\$
4
  • 1
    \$\begingroup\$ I know it's been a while, and I see you're mentioning it does run without the exit-label on most compilers, but you can lower it to 129 bytes by exiting with an error using an SSN (error value) instead of SSSN (push 0), which is allowed according to the meta. Try it online (with added highlighting and explanation), or try it online raw. \$\endgroup\$ Mar 16, 2018 at 15:44
  • \$\begingroup\$ @KevinCruijssen I finally checked your version. It's basically the old version with the assembly dup jumpz e and the e: exit removed. But at least on whitespace.kauaveel.ee it keeps on looping till the browser complains. I'd rather not change my version to that, despite the lower golf and the meta allowing "exit by error". But you're free to submit your version as a new answer. \$\endgroup\$
    – LukStorms
    Mar 27, 2018 at 19:49
  • \$\begingroup\$ Nah, I won't post a separated answer. It's basically the same as yours, just a tiny bit shorter due to exit by error. I also just realized I can lower it to 126 instead of 129 by removing the SSN at the start, in which case it errors with Can't do Infix Plus when it only has a single item on the stack (the 107). (Try it online.) I'll just leave my comment here when anyone has the same suggestion. And I've already +1-ed your answer about a year ago I think. ;) \$\endgroup\$ Mar 27, 2018 at 20:08
  • 1
    \$\begingroup\$ @KevinCruijssen In that case, your solution has now been noted in the answer. Whitespace is one of the most unlikely languages to golf in. But for the sake of saving bytes your findings are worth mentioning. \$\endgroup\$
    – LukStorms
    Mar 27, 2018 at 20:35
49
+500
\$\begingroup\$

Seed, 4154 4135 4117 4078 bytes

Explanation, quite long, along with the description of the generation algorithm on my home page (as per request in comments): link

Possibly smallest one can create in finite amount of time.

Feersum's generator has been outscored by 125 digits.

18 1999111369209307333809858526699771101145468560828234645250681099656696029279480812880779443148152835266354745917034724622145903651417563371730237765283326056988244774110441802133624468817714160177386022056512108401823787027806425684398448067970193332644167536135089961308323052217690818659345826221618714547471817786824952177760705661213021136861627615564344797191592895410701640622192392412826316893318666484043376230339929937013414786228802341109250367744273459627437423609306999946689714086908789713031946200584966850579209651689981508129953665360591585003323062426849065928803791631705897655870676902001410564547259097078231664817435753967511921076054045034302323796976905054512737624542497156263914722954936458789312271946701667519720841308380062811251340113402138536813062807047486584549696366881131076129644333426157514410757991556230404583924322168740934746079177400690540383270574734570453863131129670312070568678426587468145691141064452504683450565188718043501125177371576228281599163415914580472091806809959254536307112226422637068036069837636348250796013947548859219492684001888592443619271863264913733271796439829896342322684180478385639971904415730730155249230972472713598001454701479081682503703435292522488015910406951417625194589254609756805750713606175216991897729604817653297756338264018378339186646236428245791304007449872675676823828828025054891324604572924113135541994460293993994930010757779465315482913805320566037487246911578188713647298779820394853314711728701462997760060773720597833413054385989484972761510228922232188763499675904892361201334056531237561182096332707820332381472154893517831468669407424867949853884550905603295504680929068346527584718316837786318710085149722173684889784734888358566137013072868037395888296895408992035862679921478330680631465096402120764369879221964359613565641652779510635224788673321444028128955312660697375763703507924497355056468329176678508797277505818080245055083627993568557883893217501909841992899324584338401263402065617507377073719573642373296064002058833488593469308722954567388945161866200094063588423591356962865924188962743278147095803148276100759174767606637848987740320689762075562393521992008413240632519860537097220403160035470139899869535541445941688033346042941342229305392639867768112643798588915164061012851035069872578424685533430920913310727097269791325370108354115267003538502506307401037702631576755065238836157990287620373910423088628131973441805618500402407032751005850768445522318425479521483938945040598642922742796671148454685792926662105094734939468210307429214048710552195412807154088634170043145174020299723624868716804740205833308025010299791473201989330179511900752421521748244324520372384555472905196933204791343923384985673930225356512632819977168423365518584516873151142795940198973519372718229122661025988052451376835210066645728260048500257088773609522352231828810506243886764860621803233068079848240668323783996022507908005888468315483796728648978952610219628600082949325089555677853995177602958596492703349550377871982505777660804519503438416790609328789548538308170189581940118961959513239411467871900221985235702327603132341245854941342838886675363828149587290416073764877392438738417021129652498464495269870868163299830870636019233313974206364225614175115905798645888824666280593535350493547833757379214088677125769505793280646751090271497879000895725329057103702349349795211071357094147037863458426851391499872003703049553149335378055054176480977774050198041879243243264959205957441742983643583697591926138999543475339555662645088503078864968452030049140027407987267835123806661736568594687416676322591834962173789578844522343172160526435025531896189408441645468352864002987706103448393710107805248652709736711528349633758515438315407447026188178510124322920110858766628704828773265703683997486487094455425009292414948853993709223752434073750917088611480305840639869649933404702780843770306859066070919534638022435125602050780767420448917941603557783974740312706609928585387278690009349321957381507513875981113699582062422293555869483805964659436085153933836036107786

Try it online!

Original, 4154 byte version

Added per request of @JoKing, because the 1st program doesn't quite run on TIO, albeit being valid.

20 77698190481213510983405846204529755428212736563278528088055816123655499433757607718113585773285686740433752335768949721107461077652705328567448384490378909463204984642622585570301449419608763821501335954761638946551568252142160714228369356054944595121742743720935369219143086698092657062614382519069928478344861416117079283276656675368390764675728501797178208908097054412833019383889935034413095990596139618411133857423995278221670378808372393943846302426674985203826030563290800228881174929701934609803807325868775242909948272754141956168876233403760199007405891058308908050926690654387065882097924294620229833663324754801060691573338185912369627367088050915813931912943122729210762147280440619571047157836177316082899933374851699282897590433145623725705072835054748369992455883804733164985993447304652512229557984322495162682327137071900307763332392727562988633724175094951314863886096190608268953115914497741446723188169519334729165647294618083444761551231012944903572063441813639201051793052623561949314826491616145873848990439549320951496534538450810083853945092224500179417650727351532486362656533602860500906935826231374501097567347929533018944533000919137863885267937690665655625569011036163950983389810112758403211861147501289650757555111271813737813381172074709337306647481507917983021055643749698971365256395367215437223669891280521155247529741719633106765965869860677198632388808752014013939448563313855130972968670015202479226496876067874099463222366536167126653600056389712632892652810365218798697007191747287017174284819764736012653205048166550645507761123345279502597627995423826537299795220169894222867163817508592362092945387317777666016102146798532337718546431888424995701016828542559577710937459975677354300708252448630110787487122698124054544454425586794841157136743408274159313823745226919626156949004386804874236325506583268311452185182143521552429596087556634158778951670223004413763782647825362665491934988477225698133609360969370513836064317152213804169538880632390908441210809806024082600637872813704781431414342781727628446451808751293046212690472851527294326981763969926510021099532791692362104324026231160941956411410511639925420026544463125250979130259151326444714248961523031316570018708849878676230362246913063109584502143502908906243190007062857721367402065760878808920961082444422470813023453274563914735545463757909757689866565064353853099958949763412521666109346825939993377745919874506439752272141853783745051726268592621080457687000431023453539135927140364910898906534604541224314820195082362228787083990333757268808864746297304451768935814651205074884015268982492445996542040655715230139673520569765431617018824427859214902954216246257690105154030408059145566852643855789351907818461502260430297487602982850090037405732117988720732457199005151517240766953718440639691354185802798689950155164379549518496065038927905828230066053603755553745353618846804435103593395141938947781375633374976924393453162350331593801284839409264892975739791751842620029351535320807733966984270102067017902086335370470815153908942490581427972998999752666174807935897314584088695849094389002316139005810918748032068307783088481430339303809949409414892479892121893571274086727250767713365523021125610242269894861374297866741571608166536165735922984579027986499758294460652554897534526492251140681138244025665400003029337114012766773010641359450599171473565675885966777145500248501370644599274741842644014722083732709145488157998306684831419559774212264003518406013032514468522158218837161285401631773099549510145156007147884565387852623860047153609138110997222297132678660783411624002400927435687937355446057878202312894093195453248164648271580944753933355967626542678764854079218206499479071658357103085513937246462858404881973219571392564909528645166637501279457604649906515968389831094896970731573714836150178126997674563415266672131632765794599548356902607125568792417432226125654028873443580337866760487651905138461301986816386866811155111486155341154153322710638921116465132825486519667178335471102213200521032618562169530188826434060179505699797068436325168526618824444305122475837890944742004331675952611756641739756206337285946

Try it online!

\$\endgroup\$
13
  • 2
    \$\begingroup\$ I don't know Befunge nor Seed, but is there a reason both you and @feersum use the Befunge-98 program "9!dlroW ,olleH"ck,@ (20 bytes)? Won't the Befunge-98 Hello World answer posted here: "ck,@!dlroW ,olleH (which is 18 bytes) result in a shorter Seed program as well? \$\endgroup\$ Sep 10, 2019 at 8:06
  • 3
    \$\begingroup\$ Also, the shorter befunge solution is incorrect - it starts with a leading space and no excalamation mark. To fix these issues, the program would be 19 bytes big - that's as much as the no-9 solution I've been working on. \$\endgroup\$ Sep 10, 2019 at 14:12
  • 1
    \$\begingroup\$ The output of the latest revision appears to be incorrect. \$\endgroup\$
    – Dennis
    Sep 28, 2019 at 17:38
  • 2
    \$\begingroup\$ > Seed uses Pyfunge - no, it doesn't. The specification doesn't mention what kind of interpreter can be used to execute the resulting code. It only happens so that TIO is utilizing PyFunge. \$\endgroup\$ Jul 24, 2020 at 10:52
  • 2
    \$\begingroup\$ I'm not calling for it to be deleted, but the first version is invalid. The implementation you are using does not print the correct string (and on CGCC implementations are the definitions of languages), and I don't know of any other implementations of Seed that print correctly (though one would be trivial to create). Even if you wanted to go by the pure language specification of Seed and Befunge (though I note the Seed esolang page never mentions which version of Befunge, 93, 98 or the unappreciated 97), your shorter version would still produce the leading space. Forgive my pedantary \$\endgroup\$
    – Jo King
    Aug 3, 2020 at 13:41
47
\$\begingroup\$

Hexagony, 37 32 bytes

Notice: I'll be giving a bounty of 500 rep to the first person who finds a valid solution in a hexagon of side-length 3 or a provably optimal solution of side-length 4. If you can't find such a solution but manage to beat my score in a side-length 4 hexagon (by getting more no-ops at the end of the program, which can be omitted from the source code), I'm willing to give out a smaller bounty for that as well.

H;e;P1;@/;W;o;/l;;o;Q/r;l;d;2;P0

Try it online!

I proudly present my second 2D programming language, and (to my knowledge) the first ever 2D language on a hexagonal grid.

The source code doesn't look very 2D, does it? Well, whitespace is optional in Hexagony. First, the source code is padded to the next centred hexagonal number with no-ops (.). The next such number is 37, so we insert five no-ops at the end. Then the source code is rearranged into regular hexagon:

   H ; e ;
  P 1 ; @ /
 ; W ; o ; /
l ; ; o ; Q /
 r ; l ; d ;
  2 ; P 0 .
   . . . .

This is also runnable. Try it online!

Hexagony has a bunch of pretty funky features, including 6 different instruction pointers and a memory layout which is the line graph of a hexagonal grid, but this code uses only one IP and one memory edge, so let's not worry about that for now.

Here is an overview over the relevant commands:

  • Letters just set the current memory edge to their ASCII value
  • ; prints the current value, modulo 256, as a byte to STDOUT.
  • / is a mirror which behaves as you'd expect (causing the IP to take a 120 degree turn).
  • Digits work as they do in Labyrinth: they multiply the current cell by 10 and then add themselves.
  • @ terminates the program.

Now the final catch is that the source wraps around all 3 pairs of edges. Furthermore, if the IP leaves the grid through one of the six corners, there are two possible rows to jump to. Which one is chosen depends on whether the current value is positive or non-positive. The following annotated version shows where the IP re-enters each time it leaves the grid:

         H ; e ;     -> 1
5 ->    P 1 ; @ /    -> 4
3 ->   ; W ; o ; /   -> 2
1 ->  l ; ; o ; Q /
4 ->   r ; l ; d ;   -> 5
2 ->    2 ; P 0 .    -> 3
         . . . .

So if we remove all the direction changes, this program boils down to the following linear code:

H;e;l;;o;Q2;P0;W;o;r;l;d;P1;@

What's with Q2, P0 and P1? Letters are printed easily because we can just set the edge to the corresponding value. For the comma, the space and the exclamation mark, that doesn't work. We also can't just set their value with 44, 32, 33, respectively, because the memory edge is non-zero to begin with, and due to the semantics of individual digits that would wreak all sorts of havoc. If we wanted to do that, we'd have to reset the edge value to zero with something like *, +, -, & or ^ first. However, since the value is taken modulo 256 before being printed we don't have to set the values exactly to 44, 32, or 33. For instance, Q2 will set the edge value to 81*10 + 2 = 812, which is 44 when taken modulo 256. This way we can save a byte on each of those three characters. (Unfortunately, it's never possible to get there with a single digit from the value the cell already has. Amusingly, where it does work is the o in World, because that can also be obtained from W9.)

You can use this CJam script to find all letter-digit combinations that result in a given character.

I'm not sure whether this is optimal. I doubt it's possible to do it in a hexagon of side-length 3 (where you'd only have 19 characters available), but it might be possible to solve it in a hexagon with side-length 4 with less than 32 commands, such that there are more no-ops at the end of the grid.

\$\endgroup\$
7
  • 1
    \$\begingroup\$ Dammit, you beat me to it. I myself am working on a hexagonal language kind of similar to Cardinal. \$\endgroup\$
    – M L
    Sep 14, 2015 at 16:49
  • \$\begingroup\$ How did you find this solution? By hand or brute-force? Anyway, +1 :) \$\endgroup\$
    – Adnan
    Jan 25, 2016 at 15:19
  • 1
    \$\begingroup\$ The Q2, P0 and P1 is very clever. I didn't know the modulo 256 part. \$\endgroup\$
    – Adnan
    Jan 25, 2016 at 15:27
  • 1
    \$\begingroup\$ @Adnan The person who suggested the mod-256 part on GitHub actually did so along with the example that linefeeds could then be printed as M8; (or g4;), which I've used a couple of times since then. It just never occurred to me until now to revisit this answer after I made that change. \$\endgroup\$ Jan 25, 2016 at 15:29
  • 3
    \$\begingroup\$ Note: This was reduced to 31 a while ago. H;e;P;2Q/d;l;r/l;$@;o];o;W;03&; \$\endgroup\$ Oct 24, 2016 at 10:00
47
\$\begingroup\$

x86_64 machine code for Linux, 32 bytes

When Linux starts a new process, all the registers (except RSP) are zero, so we can get RAX=1 by only modifying the low byte. The x86-64 System V ABI doesn't guarantee this, but it's what Linux actually does. This code only works as _start in a static executable.

0000000000000000 <_start>:
   0:   e8 0d 00 00 00          call   12 <hello>
   5:   48 65 6c 6c 6f
   a:   2c 20 57 6f 72
   f:   6c 64 21 5e 40

0000000000000012 <hello>:
  12:   5e                      pop    rsi
  13:   40 b7 01                mov    dil,0x1
  16:   b2 0d                   mov    dl,0xd
  18:   b0 01                   mov    al,0x1
  1a:   0f 05                   syscall
  1c:   b0 3c                   mov    al,0x3c
  1e:   0f 05                   syscall

The call instruction pushes the next address, which contains the hello world string, onto the stack. We pop the address of the string into rsi.

Then the other arguments are set up for a syscall to sys_write, which prints the string.

The program terminates with a syscall to sys_exit. sys_write returns the number of bytes written, so the upper bytes of RAX are zero after the first syscall (unless it returned an error), so mov al, 60 gives us RAX = __NR_exit in only 2 bytes.

You can make this program segfault by closing its stdout (./a.out >&-), so sys_write() will return -EBADF, the second syscall will return -ENOSYS, and then execution will fall off the end. But we don't need to handle write() errors gracefully.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Specifically this only works on Linux, where __NR_write is 1. This is not standard across different x86-64 Unix systems. You're also depending on the Linux behaviour of zeroing all registers except RSP before entry into a fresh process (so this only works if you build it as a static executable, otherwise the dynamic linker will leave garbage in the upper bytes of rax and you'll get -ENOSYS). The x86-64 System V ABI says registers can hold arbitrary garbage values on entry to _start, the Linux kernel itself chooses zero them to avoid info leaks. \$\endgroup\$ Apr 13, 2018 at 3:40
  • 1
    \$\begingroup\$ You can save a byte with mov al, 1 / mov edi, eax (2 bytes), instead of needing a REX prefix for DIL, because __NR_write == STDOUT_FILENO = 1 \$\endgroup\$ Apr 13, 2018 at 3:43
  • 1
    \$\begingroup\$ This only works in a Linux static executable, so the address of your string is guaranteed to be in the low 2G of virtual address space (the default memory model for non-PIE executables puts all symbols where they can be used as zero or sign-extended 32-bit immediates). Thus you can use 5-byte mov esi, msg (NASM) aka mov esi, OFFSET msg (GAS .intel_syntax). Put your string after the last syscall. call/pop is 1 byte shorter than 64-bit RIP-relative LEA, but mov is best. \$\endgroup\$ Apr 13, 2018 at 3:48
  • \$\begingroup\$ NASM source for 30 byte version (checked size on my desktop), tio.run/##TY8/… \$\endgroup\$ Apr 13, 2018 at 4:11
  • \$\begingroup\$ save a quick byte by removing mov dil,0x1 and putting in mov edi,%eax after the mov al,0x1. \$\endgroup\$
    – Noah
    Sep 28, 2023 at 23:24
46
\$\begingroup\$

C, 30 Bytes

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

Try it online!

Fairly vanilla, but I can't think of a commonly compilable way to do it any shorter (unless maybe some kind of raw asm trick might work?). Still, beats most esolangs!

\$\endgroup\$
7
  • 4
    \$\begingroup\$ It's not worth a separate answer, but the fully ISO compliant C89 and C99 answers are 39 main(){puts("Hello, World!");return 0;} and 53 #include <stdio.h> int main(){puts("Hello, World!");} bytes respectively. Slightly more if you think main(void) is required. \$\endgroup\$
    – Random832
    Aug 28, 2015 at 16:29
  • 27
    \$\begingroup\$ @Random832: for the former, main(){return!puts("Hello, World!");} is two bytes shorter. \$\endgroup\$
    – Lynn
    Aug 28, 2015 at 19:56
  • 27
    \$\begingroup\$ The program h is 29 bytes shorter. Note: you'll have to compile it with -Dh='main(){puts("Hello, World!");}' I'm half trolling, half amusing myself with compiler abuse. \$\endgroup\$
    – matega
    Aug 29, 2015 at 19:54
  • 26
    \$\begingroup\$ @matega That is clearly cheating. For it not to be cheating you'd have to make the file contain only __FILE__ (8 bytes) and name the file main(){puts("Hello, World!");}. Then it is totally not cheating ;) \$\endgroup\$
    – C0deH4cker
    Sep 3, 2015 at 8:12
  • 1
    \$\begingroup\$ main(){puts(_FILE_"!");} with a file name of "Hello, World" is 26 bytes. \$\endgroup\$
    – mreff555
    Jun 21, 2020 at 15:31
41
\$\begingroup\$

Fourier, 15 bytes

BIG CHANGES to Fourier!

`Hello, World!`

Try it on FourIDE!

Yes, the days of typing out the ASCII code of each character are gone forever: Fourier now kind of supports strings. When you enclose a string in backticks, that string will be outputted.

Note that you can't do anything other than output that string: you cannot store it in a variable, it is not stored in the accumulator and there are no string manipulation tools.


Here, you can find the train wreck that was old Fourier. ;)

72a101a+7aa+3a44a32a87a111a+3a-6a-8a33a

Try it online!

Now, some of you will probably have met Fourier before and may be fairly familiar with the language. The whole language is based upon an accumulator: a global variable which pretty much all operators use.

The most important part of the code is the a operator. This takes the numerical value of the accumulator and converts it to a character using the Python code chr(accumulator). This is then printed to STDOUT.

Unfortunately, I haven't had the chance to use Fourier yet (nudge nudge, wink wink), mainly because of its lack of strings and string operators. Even so, it's still usuable for many other challenges (see the examples section of its EsoLangs page).

Note that this is shorter than my entry into the Esolangs list because I didn't actually think that I could golf it any more. And then, when writing the Fourier string golfing challenge, I realised I could go quite a bit shorter.

Note

If you were wondering about variable syntax, Geobits wrote a program which uses variables and is the same length:

72a101a+7aa+3~za44a32a87aza+3a-6a-8a/3a

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ What's a usuable? Is it like a usable? \$\endgroup\$ Mar 25, 2016 at 23:59
40
\$\begingroup\$

C--, 155 bytes

target byteorder little;import puts;export main;section"data"{s:bits8[]"Hello, World!\0";}foreign"C"main(){foreign"C"puts("address"s);foreign"C"return(0);}

Unfortunately, the only known C-- compiler, Quick C-- is no longer maintained. It's a pain in a neck to build, but it is possible...

\$\endgroup\$
5
  • 13
    \$\begingroup\$ Really fascinating language - I'd never heard of it before, and it's certainly an ambitious project that they (were/are) doing. But in terms of code golf, I don't think it'll be a contender. I mean ... dang, this thing loses to Java ... \$\endgroup\$ Aug 28, 2015 at 20:20
  • 14
    \$\begingroup\$ @TimmyD It's really an assembler. There's a reason it loses to Java... :) \$\endgroup\$ Aug 28, 2015 at 20:21
  • 3
    \$\begingroup\$ I have good news for you. While the C-- project itself seems to be quite dead, one variant is quite alive. The Glasgow Haskell Compiler (GHC) uses C-- as its final stage before assembly or LLVM, and that version is still actively maintained. It shouldn't be any trouble whatever to get it installed (along with the rest of GHC). \$\endgroup\$
    – dfeuer
    Aug 12, 2019 at 17:39
  • \$\begingroup\$ @dfeuer Indeed I tried using their Cmm backend directly before, but I had some weird issues and never really looked into it much further ¯\\_(ツ)_/¯ \$\endgroup\$ Aug 13, 2019 at 0:27
  • \$\begingroup\$ You can probably get some help on the Haskell mailing lists. Try [email protected], or perhaps [email protected]. \$\endgroup\$
    – dfeuer
    Aug 13, 2019 at 1:12
40
\$\begingroup\$

Java 5, 61 bytes

enum H{H;{System.out.print("Hello, World!");System.exit(0);}}

This is valid in both Java 5 and Java 6. This won't work in Java 4 or earlier (because enum didn't exist) and will not work in Java 7 or after (because this solution uses a bypass[1] that was "fixed").

enum H {                               // An enum is basically a class.
  H;                                   // Static initialization of the mandatory instance, invoking the default constructor.
                                       // Happens before the existence check of "main"-method.
                                       // No constructor means default constructor in Java.
  {                                    // Instance initialization block.
                                       // Executed in each constructor call.
    System.out.print("Hello, World!"); // duh!
    System.exit(0);                    // Exit before the JVM complains that no main method is found.
                                       // (and before it writes on stderr)
  }
}

Rough equivalence in Java as usually written

The above code is roughly equivalent to the following one.

class HelloWorld {
  public final static HelloWorld INSTANCE;
  static {
    INSTANCE = new HelloWorld();
  }
  public HelloWorld() {
    System.out.print("Hello, World!");
    System.exit(0);
  }
}

Proof of correctness

$ java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)

$ javac H.java

$ java H
Hello, World!
$

  1. The bypass consists of the static execution of code when the class is being linked. Before Java 7, the main-method-containing class was no exception to the static initialization code. Afterwards, static initialization was delayed until the main method would actually be found.
\$\endgroup\$
10
  • \$\begingroup\$ I recommend changing the title to “Java 6, 62 bytes” to clarify the version requirement. I’d also like to ask for more detail on the “bypass” fixed in Java 7. \$\endgroup\$
    – Stevoisiak
    Sep 20, 2017 at 13:45
  • \$\begingroup\$ @StevenVascellaro Explanations have been added. \$\endgroup\$ Sep 20, 2017 at 13:57
  • 11
    \$\begingroup\$ The explanation is much appreciated. I still recommend specifying the language as Java 6 in the title to distinguish it as a unique, version specific language \$\endgroup\$
    – Stevoisiak
    Sep 20, 2017 at 14:09
  • \$\begingroup\$ @StevenVascellaro "This is not about finding the language with the shortest "Hello, World!" program. This is about finding the shortest "Hello, World!" program in every language." This is the shortest answer in Java (so far); not writing the version is actually more correct as answer. Plus you're aware of the Java 8 answer, but haven't asked that answer to be Java 8 tagged. Double standard? \$\endgroup\$ Sep 20, 2017 at 14:15
  • 1
    \$\begingroup\$ @OlivierGrégoire Nice job ;) Also, I changed my program's header to Java 8 when I saw the comments here. \$\endgroup\$ Oct 9, 2017 at 22:56
39
\$\begingroup\$

Malbolge, 112 bytes

('&%:9]!~}|z2Vxwv-,POqponl$Hjihf|B@@>,=<M:9&7Y#VV2TSn.Oe*c;(I&%$#"mCBA?zxxv*Pb8`qo42mZF.{Iy*@dD'<;_?!\}}|z2VxSSQ

I'm going to see if there's a shorter one. Got a better computer since last time, so I can generate quite a bit faster.

For show, here's "Hello World!" without the comma.

(=<`#9]~6ZY32Vx/4Rs+0No-&Jk)"Fh}|Bcy?`=*z]Kw%oG4UUS0/@-ejc(:'8dc
\$\endgroup\$
2
  • \$\begingroup\$ How about this one? ('<;_#"~6Z|{y1UTvt,PrpMo,llj"Fgge{A??P=^t:8&7YtFVqjSQ@PNM)u(I8%$#"D2AA/[TYXQu88MLp3n1Gk.D-ge (92 bytes) \$\endgroup\$ Oct 15, 2019 at 0:50
  • 6
    \$\begingroup\$ 71 bytes \$\endgroup\$
    – ceilingcat
    Feb 19, 2020 at 23:29
38
\$\begingroup\$

Unreadable, 843 755 732 666 645 629 577 bytes

'"'""'""'""'"'"'""""""'""'"""'""'""'""'""'""'""'""'"'""'""""""'""'""'""'"""'""'""'""'""'""'""'""'""'""'""'""'""'""'""""""'""'""'"""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'"'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""""""'""""""""'"""'""'""'""'""'""'""'""'""'""'""'""'""'""""""'"""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'"""'"'"""""""'""""""""'"""'"'"""""""'"""'"'"""""""'""'""'"""'"'""'""'""'"'""'""'""'"""""""'""'"""'"'"""""""'""'"""'"'"""""""'""'""'""'"""'"'""'"""""""'"""

Unreadable programs are supposed to be displayed with a variable-width font, so they honor the language's name. I'm slightly disappointed that my more sophisticated approaches turned out to be a lot longer. Loops are insanely expensive in Unreadable...

Try it online!

How it works

Unreadable has only ten functions; six of these are used in this code:

'"        p Print.
'""       + Increment.
'"""      1 Return 1.
'""""""   : Set.
'"""""""  = Get.
'"""""""" - Decrement.

After using my single-character notation and adding some whitespace and comments, the above code looks like the following. Multi-line statements are executed from bottom to top.

p+++                                        Print 3 + variable 2 (o).
 pp                                         Print variable 2 two times (l).
  :+1+++++++                                Save 8 + variable 3 in variable 2.
   p+                                       Print 1 + variable 3 (e).
    :++1+++++++++++++                       Save 13 + variable 4 in variable 3.
     :+++1+++++++++++++++                   Save 43 + variable 0 in variable 4.
      p++++++++++++++++++++++++++++         Print 28 + variable 0 (H).
       :-1++++++++++++                      Save 44 in variable 0.
        :1+++++++++++++++++++++++++++++++1  Save 32 in variable 1.
p=-1                                        Print variable 0 (,).
p=1                                         Print variable 1 ( ).
p=+++1                                      Print variable 4 (W).
p+++                                        Print 6 + variable 2 (r).
 p+++=+1                                    Print 3 + variable 2 (o).
p=+1                                        Print variable 2 (l).
p=++1                                       Print variable 3 (d).
p+=1                                        Print 1 + variable 1 (!).

I've generated the actual source code by running the uncommented version of the above pseudocode through this CJam program.

\$\endgroup\$
4
  • 6
    \$\begingroup\$ What are you talking about? Its pretty readable! \$\endgroup\$
    – Optimizer
    Sep 3, 2015 at 19:03
  • 23
    \$\begingroup\$ @Optimizer Fixed. \$\endgroup\$
    – Dennis
    Sep 3, 2015 at 19:06
  • 5
    \$\begingroup\$ Still readable! (of course I am telling the truth. Why won't you believe me?) \$\endgroup\$
    – Optimizer
    Sep 3, 2015 at 19:10
  • 8
    \$\begingroup\$ Feels like this language would benefit from a better huffman coding - both in terms of size, and unreadability. \$\endgroup\$
    – primo
    Sep 29, 2015 at 9:05
37
\$\begingroup\$

JSFuck, 6293 6289 6277 bytes

This may get a mention as one of the longest "shortest Hello, World! programs" (actually I do not know if this is optimal, but it's the shortest I managed to get).

Warning: only works in Firefox and Safari

[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]][([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+([][[]]+[])[+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+(!![]+[])[+!![]]]([(![]+[])[+!![]]+(![]+[])[!![]+!![]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]+([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[!![]+!![]+!![]]]+([]+[])[(![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+([][[]]+[])[+!![]]+(!![]+[])[+[]]+([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+(!![]+[])[+!![]]]()[+!![]+[!![]+!![]]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]][([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+([][[]]+[])[+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]]+[])[!![]+!![]+[+[]]]+([][(!![]+[])[!![]+!![]+!![]]+([][[]]+[])[+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([![]]+[][[]])[+!![]+[+[]]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]+!![]]]()+[])[!![]+!![]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+(![]+[])[+!![]])()(!![])[+!![]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]][([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+([][[]]+[])[+!![]]+([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+[]]](([][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]]+[])[!![]+!![]+[+[]]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]][([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+([][[]]+[])[+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]]+[])[!![]+!![]+[+[]]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]]+(![]+[])[+[]])())[+!![]+[+!![]]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+(!![]+[])[+!![]]+(![]+[])[!![]+!![]]+([][[]]+[])[!![]+!![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]][([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+([][[]]+[])[+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]]+[])[!![]+!![]+[+[]]]+(![]+[])[+!![]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+([][(!![]+[])[!![]+!![]+!![]]+([][[]]+[])[+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([![]]+[][[]])[+!![]+[+[]]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]+!![]]]()+[])[!![]+!![]])()((+(+!![]+(!![]+[])[!![]+!![]+!![]]+(+!![])+(+[])+(+[])+(+[]))+[])[+[]]+![])[+[]]+([]+[])[(![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+([][[]]+[])[+!![]]+(!![]+[])[+[]]+([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+(!![]+[])[+!![]]]()[+!![]+[!![]+!![]]]+(+[]+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+[+[]]]))()

There is also a slightly longer version (+4 bytes) that also works in Chrome and Microsoft Edge:

[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]][([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+([][[]]+[])[+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+(!![]+[])[+!![]]]([(![]+[])[+!![]]+(![]+[])[!![]+!![]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]+([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[!![]+!![]+!![]]]+([]+[])[(![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+([][[]]+[])[+!![]]+(!![]+[])[+[]]+([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+(!![]+[])[+!![]]]()[+!![]+[!![]+!![]]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]][([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+([][[]]+[])[+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+(![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+[+[]]]+([][(!![]+[])[!![]+!![]+!![]]+([][[]]+[])[+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([![]]+[][[]])[+!![]+[+[]]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]+!![]]]()+[])[!![]+!![]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+(![]+[])[+!![]])()(!![])[+!![]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]][([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+([][[]]+[])[+!![]]+([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+[]]]((![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+[+[]]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]][([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+([][[]]+[])[+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+(![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+[+[]]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]]+(![]+[])[+[]])())[+!![]+[+!![]]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+(!![]+[])[+!![]]+(![]+[])[!![]+!![]]+([][[]]+[])[!![]+!![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]][([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+([][[]]+[])[+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+(![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+[+[]]]+(![]+[])[+!![]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+([][(!![]+[])[!![]+!![]+!![]]+([][[]]+[])[+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([![]]+[][[]])[+!![]+[+[]]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]+!![]]]()+[])[!![]+!![]])()((+(+!![]+(!![]+[])[!![]+!![]+!![]]+(+!![])+(+[])+(+[])+(+[]))+[])[+[]]+![])[+[]]+([]+[])[(![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+([][[]]+[])[+!![]]+(!![]+[])[+[]]+([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[+!![]+[+[]]]+(!![]+[])[+!![]]]()[+!![]+[!![]+!![]]]+(+[]+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+[+[]]]))()

For those unfamiliar with JSFuck, it's about writing JavaScript as if there were only six characters, and it can get pretty crazy at times.

This table shows how the characters used in the Hello, World! program are encoded in JSFuck. The plain text code is just alert("Hello, World!").

+----------+--------------------------------------+---------------------------+
|JavaScript|               write as               |           JSFuck          |
+----------+--------------------------------------+---------------------------+
|     a    | (false+[])[1]                        | (![]+[])[+!![]]           |
|     l    | (false+[])[2]                        | (![]+[])[!![]+!![]]       |
|     e    | (true+[])[3]                         | (!![]+[])[!![]+!![]+!![]] |
|     r    | (true+[])[1]                         | (!![]+[])[+!![]]          |
|     t    | (true+[])[0]                         | (!![]+[])[+[]]            |
|     (    | ([]+[]["fill"])[13]                  | 114 bytes                 |
|     "    | ([]+[])["fontcolor"]()[12]           | 539 bytes                 |
|     H    | btoa(true)[1]                        | 1187 bytes                |
|     o    | (true+[]["fill"])[10]                | 105 bytes                 |
|   space  | ([]["fill"]+[])[20]                  | 107 bytes                 |
|     W    | (NaN+self())[11]                     | 968 bytes                 |
|     d    | (undefined+[])[2]                    | ([][[]]+[])[!![]+!![]]    |
|     !    | atob((Infinity+[])[0]+false)[0]      | 1255 bytes                |
|     )    | (0+[false]+[]["fill"])[20]           | 114 bytes                 |
+----------+--------------------------------------+---------------------------+

Here the strings "fill", "fontcolor", etc. must be written as "f"+"i"+"l"+"l", "f"+"o"+"n"+"t"+"c"+"o"+"l"+"o"+"r" to be encoded.

The global identifiers self, atob and btoa get written like Function("return self")().

Function itself should be []["fill"]["constructor"].

The comma "," is tricky, I'm not 100% sure how it works but it uses the []["concat"] function to create an array. I'll post an update when I have time to do more tests.


I encoded this using JScrewIt - credits to GOTO 0 for creating such a sophisticated tool:

  • Open Firefox (You can choose any other browser(s), but Firefox only code is the shortest.)
  • Navigate to JScrewIt: http://jscrew.it
  • Input: alert("Hello, World!")
  • Executable code: checked
  • Compatibility: Only this browser

This differs from my answer to this question for the presence of the comma after "Hello".

Interestingly, the ES6 syntax

alert`Hello, World!`

takes even more bytes to encode (+1500 or so) because of the higher complexity of encoding two backticks rather than (" and ").

\$\endgroup\$
10
  • \$\begingroup\$ Well it works in Chrome on Android \$\endgroup\$
    – Beta Decay
    Aug 30, 2015 at 8:25
  • \$\begingroup\$ Works in Chrome on OS X too \$\endgroup\$
    – C0deH4cker
    Sep 3, 2015 at 19:49
  • 2
    \$\begingroup\$ You did a great job here! Be sure to check the last update. \$\endgroup\$
    – GOTO 0
    Sep 7, 2015 at 23:22
  • 4
    \$\begingroup\$ @GOTO0 Wait... you are the author of JScrewIt, right? \$\endgroup\$ Sep 8, 2015 at 5:07
  • 1
    \$\begingroup\$ How the hell do you call functions with this? \$\endgroup\$
    – user47018
    Feb 6, 2017 at 10:59
1
2 3 4 5
33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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