405
\$\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\$
  • 1
    \$\begingroup\$ Must the language meet our usual requirements for what a programming language is, or are we operating by kolmogorov complexity rules? \$\endgroup\$ – isaacg Aug 28 '15 at 13:54
  • 2
    \$\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\$ – Martin Ender Aug 28 '15 at 13:56
  • 6
    \$\begingroup\$ If the same program, such as "Hello, World!", is the shortest in many different and unrelated languages, should it be posted separately? \$\endgroup\$ – aditsu Aug 28 '15 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\$ – Martin Ender Aug 28 '15 at 19:34
  • 7
    \$\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\$ – Martin Ender Aug 29 '15 at 23:01

746 Answers 746

27
\$\begingroup\$

Brainfuck, 92 (hirose)

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

This is a slight modification of hirose's 92-byte solution for the lowercase-w version of the problem on Anarchy Golf.

Changing ++ to -- conveniently subtracts 32 from the cell that holds w, turning it into W.

Brainfuck, 95

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

For this solution, I used code that I wrote for this problem on SPOJ and touched up the output a bit by hand.

Note: Both solutions are compatible with Alex Pankratov's bff (brainfuck interpreter used on SPOJ and ideone) and Thomas Cort's BFI (used on Anarchy Golf).

\$\endgroup\$
  • \$\begingroup\$ Here's the variant for a brainfuck derivative, oOo code: pastebin.com/BqNcDnm7 I'm not sure if it deserves its own answer. (It's based on the 92-char one you posted) \$\endgroup\$ – JNV Aug 30 '15 at 8:41
  • \$\begingroup\$ What is the advantage of the 95-byte solution? Why mention it at all? \$\endgroup\$ – anatolyg Aug 31 '15 at 14:29
  • 2
    \$\begingroup\$ @anatolyg The 92 is my modification of hirose's solution. The 95 is another solution that I developed from scratch. If you can't see the value of mentioning alternative approaches, or of distinguishing your own work from (trivial or non-trivial) modifications of someone else's code, I don't know what to say. This type of thing is standard practice on Anarchy Golf, and I'd be happy to see it catch on here as well. Incidentally, I've been informed that the 95 translates to 97 in ???, while the 92 translates to 98. \$\endgroup\$ – Mitch Schwartz Aug 31 '15 at 16:04
  • \$\begingroup\$ (I was misinformed; it's 95 -> 96 and 92 -> 97 for ???.) \$\endgroup\$ – Mitch Schwartz Aug 31 '15 at 20:29
27
\$\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\$
  • \$\begingroup\$ Well it works in Chrome on Android \$\endgroup\$ – Beta Decay Aug 30 '15 at 8:25
  • \$\begingroup\$ Works in Chrome on OS X too \$\endgroup\$ – C0deH4cker Sep 3 '15 at 19:49
  • 1
    \$\begingroup\$ You did a great job here! Be sure to check the last update. \$\endgroup\$ – GOTO 0 Sep 7 '15 at 23:22
  • 4
    \$\begingroup\$ @GOTO0 Wait... you are the author of JScrewIt, right? \$\endgroup\$ – me and my cat Sep 8 '15 at 5:07
  • 1
    \$\begingroup\$ How the hell do you call functions with this? \$\endgroup\$ – mid Feb 6 '17 at 10:59
27
\$\begingroup\$

Python 2, 20 bytes

print"Hello, World!"

Python 2 is better for printing than 3 :D

\$\endgroup\$
  • 24
    \$\begingroup\$ Just in case anybody is wondering: import __hello__ prints "Hello world!", which is incorrect punctuation for this challenge. \$\endgroup\$ – Sp3000 Aug 28 '15 at 15:11
  • 6
    \$\begingroup\$ @Sp3000 Yeah, I looked into it. It actually prints Hello world... (tested on repl.it. You're thinking of Python 3, which has a different result. \$\endgroup\$ – mbomb007 Aug 28 '15 at 15:13
  • \$\begingroup\$ @mbomb007 Ah, I didn't realise Python 2 and Python 3 had different __hello__ messages, indeed I tested on the wrong one. \$\endgroup\$ – Sp3000 Aug 28 '15 at 15:18
  • \$\begingroup\$ Python 2.7 prints Hello world... \o/ What is this!!! \$\endgroup\$ – Zizouz212 Sep 16 '16 at 1:37
26
\$\begingroup\$

Java 8, 76 bytes

Thought I would try to beat Geobit's answer :)

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

Try here!

\$\endgroup\$
23
+100
\$\begingroup\$

Shakespeare Programming Language, 755 749 715 612 605 592 bytes

-34 bytes thanks to jimmy23013

-And a whole 107 bytes more! Wow!

,.Ajax,.Puck,.Act I:.Scene I:.[Enter Ajax and Puck]Ajax:You big big big cat!Puck:You is the sum ofI the square ofI!Speak thy!You is the square ofthe sum ofI a big cat!Ajax:Remember the sum oftwice twice you a cat!Remember I!You is the sum ofI you!Puck:You is the sum ofyou a cat!Speak thy!You is the sum ofa big cat a cat!Ajax:Speak thy!Speak thy!Remember you!You is the sum ofyou I!Speak thy!Remember the sum ofyou I!Remember you!You big big big big big cat!Puck:You is the sum ofI twice twice you!Speak thy!Ajax:Remember the sum oftwice I a pig!Scene V:.Ajax:Speak thy!Recall!Let usScene V!

Try it online!

Non-erroring version, 626 bytes

,.Ajax,.Puck,.Act I:.Scene I:.[Enter Ajax and Puck]Ajax:Remember I!You big big big cat!Puck:You is the sum ofI the square ofI!Speak thy!You is the square ofthe sum ofI a big cat!Ajax:Remember the sum oftwice twice you a cat!Remember I!You is the sum ofI you!Puck:You is the sum ofyou a cat!Speak thy!You is the sum ofa big cat a cat!Ajax:Speak thy!Speak thy!Remember you!You is the sum ofyou I!Speak thy!Remember the sum ofyou I!Remember you!You big big big big big cat!Puck:You is the sum ofI twice twice you!Speak thy!Ajax:Remember the sum oftwice I a pig!Scene V:.Ajax:Speak thy!Recall!Be you nicer zero?If solet usscene V!

Try it online!

An improvement over the previous community wiki answer.

Explanation:

,.Ajax,.Puck,.Act I:.Scene I:.[Enter Ajax and Puck]   #Initialise Ajax and Puck

Ajax:You big big big cat!                    #Set Puck to 8
Puck:You is the sum of I the square of I!    #Set Ajax to 8+8*8=72 ('H')
Speak thy!                                   #Print 'H'
You is the square of the sum of I a big cat! #Set Ajax to (8+2)^2=100 ('d')
Ajax:Remember the sum of twice twice you a cat! #Push 2*2*8+1=33 ('!') to Puck's stack
Remember I!                                  #Push 'd' to Puck's stack
You is the sum of I you!                     #Set Puck to 100+8 ('l')
Puck:You is the sum of you a cat!            #Set Ajax to 100+1=101 ('e')
Speak thy!                                   #Print 'e'
You is the sum of a big cat a cat!           #Set Ajax to 3
Ajax:Speak thy!Speak thy!                    #Print 'll'
Remember you!                                #Push 'l' to Puck's stack
You is the sum of you I!Speak thy!           #Set Puck to 108+3=111('o') and print it
Remember the sum of you I!                   #Push 111+3=114 ('r') to Puck's stack
Remember you!                                #Push 111 ('o') to Puck's stack

You big big big big big cat!                 #Set Puck to 32 (' ')
Puck:You is the sum of I twice twice you!    #Set Ajax to 32+12=44 (',')
Speak thy!                                   #Print ','
Ajax:Remember the sum of twice I a pig!      #Push 2*44-1=87 ('W') to Puck's stack
Scene V:.Ajax:Speak thy!Recall!Let us Scene V!  #Print and pop repeatedly until Puck's stack is empty (', World!')
\$\endgroup\$
  • \$\begingroup\$ Impressive. Take another +1. This should win one of ASCII-only's bounties for improving the RosetTIO solutions. \$\endgroup\$ – Khuldraeseth na'Barya Apr 9 '18 at 12:39
  • \$\begingroup\$ Ah, just noticed the no stderr rule, so the 622 byte version is probably invalid. \$\endgroup\$ – jimmy23013 Apr 11 '18 at 8:43
  • \$\begingroup\$ @jimmy23013 Eh, we already had 43 warnings in stderr, I think we're good. Very nice work! \$\endgroup\$ – Jo King Apr 11 '18 at 10:17
  • \$\begingroup\$ @JoKing They were all compiler messages and it was not the program itself writing to stderr. But this time a runtime error. \$\endgroup\$ – jimmy23013 Apr 11 '18 at 10:35
  • \$\begingroup\$ Let us Scene V works. \$\endgroup\$ – jimmy23013 Apr 11 '18 at 10:42
22
\$\begingroup\$

Stack Cats, 134 + 3 = 137 148 907 bytes

I'm happy to give a 500-rep bounty to the first person who can bring this down below 100 (+3) bytes.

-*(:^-_-_:-_:-_:-_:-_-_:[:^]]:^!-*!->[!_>[!_>[{]>[^-_-_:]]<<<}>[!-:^[[\\>]:^[[>:[>:^[<<]]\\>[*>+:^:-_]:^[[-_*[>>>[-_[/<]>+^[>[<<]]*>[)

Needs to be run with the -l switch of the Ruby interpreter, hence +3 bytes.

Try it online!

There's definitely still room for improvement here, but I haven't quite figured out myself yet how to program in this language effectively. The current solution was just a general idea for how to approach the challenge and I just wrote the code in a rather ad-hoc way. Even without changing the overall approach I'm confident that one can end up much closer to 100 bytes or even below.

Explanation

Proudly introducing my latest creation, this time in collaboration with Sp3000. :) The idea for this language was originally born for feersum's language design CnR, but at the time we weren't able to figure out whether this idea was usable, and then kept putting it off. A couple of weeks ago we decided to revisit the idea, cleaned up the design a lot and managed to make progress towards proving its Turing-completeness, so here it is.

Stack Cats is a stack-based, reversible programming language. In fact, in order to undo any piece of code, you simply mirror it (which means reversing it and swapping all brackets and slashes). Furthermore, every program has to have mirror symmetry itself. This implies that every non-trivial program has odd length and the form f g f-1, where g is a single very simple command which is also an involution. That makes programming and especially golfing in Stack Cats fairly tricky.

Note that the source code above isn't actually symmetric. This is because the -l switch lets you omit the first half (before the g), since it's redundant in any valid program anyway. So the full program is actually:

(]<*[[>>]<]^+<[>\]_-]<<<]*_-]]^:[_-:^:+<*]<//[[>>]^:<]:<]]^:[<//]]^:-!]<{>>>[[:_-_-^]<[}]<_!]<_!]<-!*-!^:[[^:]:_-_-:_-:_-:_-:_-_-^:)*-*(:^-_-_:-_:-_:-_:-_-_:[:^]]:^!-*!->[!_>[!_>[{]>[^-_-_:]]<<<}>[!-:^[[\\>]:^[[>:[>:^[<<]]\\>[*>+:^:-_]:^[[-_*[>>>[-_[/<]>+^[>[<<]]*>[)

When I say "stack-based", I mean that the memory model is actually a tape of stacks. As in my other stack-based languages, each stack is initially implicitly filled an infinite amount of zero (this time, that was actually necessary to ensure full reversibility of all commands on all possible states). In addition to this the initial stack starts with a -1 on top when there is no input (which is the case here).

Output in Stack Cats works simply by printing the contents of the final stack, top to bottom. So the goal is to generate a stack with the following values (top is right):

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

(There are a few other options but this is what the above program does.)

I'm going to represent the tape as follows, with the v indicating the tape head's position:

     v
... -1 ...
     0

Now on to the code. Note that the program begins with a (...) which continues until just before the central *-*. This is a loop, which can be used as a conditional. The loop is entered and exited only when the top of the stack is positive. Since the initial stack holds a -1, the entire first half of the program is skipped. This makes programming a lot easier, but of course it's also somewhat wasteful in terms of golfing. I haven't yet been able to figure out how to make easy use of both halves of the code except for simple toy problems.

Next comes the *-*. Here, * takes the top of the stack XOR 1, i.e. turns -1 into -2, the - negates it to give 2 and then we have another *, giving 3. Now that the top of the stack is positive, we do enter the (...) in the second half. The code in there will be executed only once and now turns this single 3 into the stack we need for the output.

It turns out that the quickest way to obtain large numbers without loops is a Fibonacci-like progression where we repeatedly add the last value to the one before. I say Fibonacci-like because we have some flexibility here since we can occasionally increment or decrement values in the process, or add the last value to the previous one several times before swapping their roles.

For now, we're trying to compute 33 and 87, because they both appear in the same Fibonacci-like sequence. (And they are the character codes of ! and W.) If the top of the stack is a and the value below is b, I'll be writing this as (a, b), so the current state is (3, 0). Let's go:

:    Swap the top two values.              (  0,  3)
^    XOR the second into the first.        (  3,  3)
-    Negate top.                           ( -3,  3)
_    Subtract top from second.             (  6,  3)
     As you can see, -_ can be used to
     add the second-to-top to the top.
-_   Add second into top.                  (  9,  3)
:    Swap.                                 (  3,  9)
-_   Add second into top.                  ( 12,  9) 
     The last two together form a normal
     "Fibonacci step".
:-_  Fibonacci step.                       ( 21, 12)
:-_  Fibonacci step.                       ( 33, 21)
:-_  Fibonacci step.                       ( 54, 33)
-_   Add second into top.                  ( 87, 33)
:    Swap.                                 ( 33, 87)

Now [ pushes the 33 one stack to the left (moving the tape head along), :^ duplicates it and ] moves one copy back. Together, this just puts a 33 on the stack to the left. And then ]:^ moves the 33 to the right and duplicates it again there. So now we've got:

           v
          33    
... 33 87 33 ...
     0  0  0

Next, it turns out that most of the lower case letters are multiples of 3 and their other factors are 36, 37, 38 which aren't too far away. 99 is also useful, since we'll need both 100 and 101, so we now create a stack with those factors so we can multiply all of them by 3 later.

Stack Cats doesn't have a decrement or increment command. The standard way to increment a value is to combine bitwise NOT (!) and unary negation (-). However, if we know that our value is even we can also increment by toggling the least significant bit with *. Hence, the following !-*!- brings the 33 on top of the stack up to 36. Next, we pull over two 0s from the empty stack to the right, turn use them to get incremented copies of the 36 with >[!_>[!_. The tape now looks like this:

           v
          38    
          37    
          36    
... 33 87 33 ...
     0  0  0

Time for the loop:

>[{]>[^-_-_:]]<<<}

Besides the (...) we've already seen, Stack Cats has another loop, {...}, but its semantics are also a bit unusual. The loop body is always executed at least once. When the loop starts, Stack Cats remembers the value on top of the stack, and then the loop doesn't terminate until that value is seen again at the end of an iteration. That means the easiest way to work through a stack is to put a zero on top and then shift the stack away one value at a time until we hit the zero at the bottom. Here is what the loop does:

>[       Fetch a zero from the empty stack to the right.
{        Loop until zero...
  ]        Push the current factor X to the right.
  >[       Fetch a zero from the stack next to that.
  ^        XOR X into that zero, duplicating X.
  -_-_     Add X into the new value twice, computing 3*X.
  :        Swap 3*X and X.
  ]]<<     Push X two stack to the right and return.
  <        Move back to the stack we're looping over.
}
>        Move onto the stack which now holds the multiples.

This is the new tape:

              v
             99   33    
            108   36    
            111   37    
... 33 87   114   38 ...
     0  0 0   0 0  0

The next bit is [!-:^ which you've seen before: it increments the 99 to 100 and duplicates it on the empty stack next to it. The [[ moves one of those 100s over onto the 33 — we're now starting to build the final stack there. Here's what we've got:

      v
                     33    
               108   36    
    100        111   37    
...  33 87 100 114   38 ...
      0  0   0   0 0  0

It's going to be annoying to fetch all the values from so many stacks away, so here's a new command. \ swaps the current stack with the one of the right, moving the tape head along. So the \\ now brings the output stack closer to the useful values:

             v
                     33    
               108   36    
           100 111   37    
... 87 100  33 114   38 ...
     0   0   0   0 0  0

Next, there's >]:^ which moves the 108 onto the empty stack to duplicate it. [[>:[ moves one of them and the 114 onto the output stack. >:^[ duplicates the 111 and moves one copy onto the output stack. Then we fetch the 87 with <<]], and move the stack two positions further with another \\. We've now got World!:

                  v
                 87       
                111       
                114 33    
                108 36    
                100 37    
... 100 111 108  33 38 ...
      0   0   0   0  0

Time for the space: we've still got that 33 around, so we fetch and decrement it with >[*. We don't need those 36, 37, 38 any more, but we do need a 44. We also still need the 72 for the H later on, and we can actually compute that on the way. All of this is accomplished with the following code:

>+:^:-_]:^[[-_*[>>>[-_[

The new command here is + which swaps the top of the stack with the third value from the top. We use it together with : to put the 36 below the 37 and 38. The ^ replaces the 37 with 37 XOR 38 which is 3. We then add this to 38 with :-_ which gives 41. ]:^ duplicates that on the stack to the right. Then we add a 32 into it with [[-_ and decrement it with * by toggling the least-significant bit. Voilà, there's our 72. We move it to the side with [, go back to the other copy of 41 with >>> and add another 3 into it with [-_ before putting it on the output stack with [. Next, we move the current stack to the left with /. Here's the current tape:

              v
             44           
             32           
             87           
            111           
            114           
            108           
            100  72  3    
... 100 111  33 108 36 ...
      0   0   0   0  0

Now all that's left is collecting a few more values with

<]>+^[>[<<]]*>[

The <] fetches the 111. Then >+^ swaps the 72 with the zero below in order to duplicate the 108. [>[ moves both of those onto the output stack. <<]] fetches the 100 and * turns it into a 101. Finally >[ gets the 72 and we're done.

If you've actually followed all of this you'll noticed that there's tons of stuff we could have done differently which may or may not have saved bytes. There are many more ways to compute the different numbers, maybe XOR would have been useful more often. We could also generate some larger or negative numbers, since the final values are taken modulo 256 before being printed. We could also have made more use of loops, or used the stacks differently. There are also further stack manipulation commands like | to reverse it, X to swap the stacks left and right and = to swap only their top values.

As difficult as it is to program in Stack Cats, it still provides quite a large set of useful commands, which allow for many different approaches to any given problem.

\$\endgroup\$
  • 1
    \$\begingroup\$ Crazy language, very nice answer. \$\endgroup\$ – Raghu Ranganathan Apr 28 '18 at 9:27
22
\$\begingroup\$

Java, 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 the bypass[1] 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\$
  • \$\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 '17 at 13:45
  • \$\begingroup\$ @StevenVascellaro Explanations have been added. \$\endgroup\$ – Olivier Grégoire Sep 20 '17 at 13:57
  • 5
    \$\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 '17 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\$ – Olivier Grégoire Sep 20 '17 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\$ – TheNumberOne Oct 9 '17 at 22:56
21
\$\begingroup\$

Common Intermediate Language, 126 123 bytes

.assembly H{}.method static void M(){.entrypoint
ldstr"Hello, World!"
call void[mscorlib]System.Console::Write(string)
ret}

With proper indentation:

.assembly H {}
.method static void M()
{
    .entrypoint
    ldstr "Hello, World!"
    call void[mscorlib] System.Console::Write(string)
    ret
}
\$\endgroup\$
  • \$\begingroup\$ You can save 2 bytes by removing unneccesary newlines (at least in Mono) \$\endgroup\$ – ASCII-only Apr 20 '18 at 1:24
20
\$\begingroup\$

Javascript (ES6), 20 bytes

alert`Hello, World!`

Javascript ES6 features are awesome when it comes to code golf!

Here, the use of templates allows for a two byte savings by removing parentheses.

How it works

This syntax is known as tagged templates, and it is not the same as merely calling a function with a single string as a parameter, as I initially thought. The function, in this case alert, is called with an array of the string portions of the template and an array of the inserted values. Since there were no inserted values and only a single string portion of the template, alert is called with the array ["Hello, World!"] as its sole (defined) parameter. alert displays this, conveniently, as Hello, World!

Try replacing alert with console.log, and it won't work! You'll get Array [ "Hello, World!" ] instead, since the console doesn't follow the same display rules as alert.

\$\endgroup\$
  • \$\begingroup\$ wait, but alert does not print to STDOUT? \$\endgroup\$ – an earwig Aug 30 '15 at 23:38
  • 4
    \$\begingroup\$ @James_Parsons Since JavaScript doesn't really have a traditional STDOUT, alert is typically considered acceptable. \$\endgroup\$ – jrich Aug 30 '15 at 23:41
  • 1
    \$\begingroup\$ @James_Parsons No problem. Welcome to PPCG! \$\endgroup\$ – jrich Aug 30 '15 at 23:50
  • 6
    \$\begingroup\$ console.log("Hello, World!") (28 bytes) outputs to STDOUT if run in node. \$\endgroup\$ – jib Sep 5 '15 at 19:20
  • 3
    \$\begingroup\$ You may use Javascript Shell and change alert to print which will print to STDOUT. \$\endgroup\$ – tsh Sep 8 '15 at 6:27
20
\$\begingroup\$

Jelly, 8 bytes

“3ḅaė;œ»

Try it online!

\$\endgroup\$
  • \$\begingroup\$ Wat. How on earth did you compress it so much... \$\endgroup\$ – ETHproductions Jan 11 '16 at 15:42
  • 4
    \$\begingroup\$ Jelly now has an experimental decompressor that indexes an English dictionary. \$\endgroup\$ – Dennis Jan 11 '16 at 16:00
  • 14
    \$\begingroup\$ Jelly is ḅaė. \$\endgroup\$ – mbomb007 Feb 24 '16 at 19:54
  • 2
    \$\begingroup\$ you mean: ḅaė is jelly \$\endgroup\$ – Daniele D Aug 12 '16 at 9:06
20
\$\begingroup\$

Python 3, 22 bytes

print("Hello, World!")

In Python 3, printing is a function and so it requires parenthesis.

A 16 byte solution would be import __hello__, but annoyingly this prints the message without the comma!

\$\endgroup\$
  • 1
    \$\begingroup\$ Don't forget wrong caps :P \$\endgroup\$ – CalculatorFeline Jun 20 '17 at 21:24
19
+1000
\$\begingroup\$

Hexagony, 23 bytes

H;_\/201;lQP/oe;/W_|@dr

Try it online!


This was found with a brute force program. Time taken:

In 0 days 0 hours 52 minutes 56.4935 seconds

I suspect this is optimal.

\$\endgroup\$
  • 1
    \$\begingroup\$ I was hoping it wouldn't be brute-forced, but you still get the bounty \$\endgroup\$ – Jo King May 19 '18 at 13:56
  • 2
    \$\begingroup\$ @JoKing I was hoping it would be :D ... I've been meaning to write a brute forcer for linear programs for ages and never got around to it, so I'm glad someone finally did. \$\endgroup\$ – Martin Ender May 19 '18 at 13:57
  • 3
    \$\begingroup\$ Any plans on posting the brute-forcer as well? \$\endgroup\$ – Jo King May 20 '18 at 0:29
  • 1
    \$\begingroup\$ @JoKing Before posting the brute force program, I need to optimize it and make sure that it doesn't produce a shorter solution in a reasonable amount of time. \$\endgroup\$ – user202729 May 20 '18 at 13:17
  • 1
    \$\begingroup\$ I'm quite impressed by this backwards code the brute force has worked out, where it uses each ; at least twice in passing, and twice again when the paths cross over \$\endgroup\$ – Jo King May 20 '18 at 13:51
18
\$\begingroup\$

Wordy, 1666 bytes

xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx x x x x x x x.xxx xxx xxx x x.xx x.x x x x x x x x x x x x x x x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x x x.xx x.x x x x x x x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x x x x x.xx x.x x x x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x x x x x.xx x.x x x x x x x x x x x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x x x x x.xx x.x x x x x x x x x x x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x x x x x.xx x.x x x x x x x x x x x x x x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x.xx x.x x x x x x x x x x x x.xxx xxx xxx x x x x x x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x x x x.xx x.x x x x x x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x x x x x.xx x.x x x x x x x x x x x x x x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x x x x x x.xx x.x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x x x x x.xx x.x x x x x x x x x x x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x x x x x.xx x.x x x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x.xx x.x.

We can greet the World by executing the following instructions:

ASSIGN NOP LITERAL 16
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 4 LITERAL 8
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 6 LITERAL 5
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 6 LITERAL 12
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 6 LITERAL 12
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 6 LITERAL 15
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 2 LITERAL 12
OUTCHAR MULTIPLY VALUE NOP LITERAL 2
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 5 LITERAL 7
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 6 LITERAL 15
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 7 LITERAL 2
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 6 LITERAL 12
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 6 LITERAL 4
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 2 LITERAL 1

Wordy encodes all instructions as sentences, where the fraction of words that are longer and shorter than the rounded average selects the command.

The shortest sentences I could find for the used instructions are:

ASSIGN xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx x x x x x x x.
VALUE xxx xxx x x x.
ADD xxx x x.
MULTIPLY xxx xxx xxx x x x x.
OUTCHAR xxx xxx xxx x x x x x x x.
NOP xxx xxx xxx x x.
LITERAL xx x.
\$\endgroup\$
17
+100
\$\begingroup\$

Piet, 93 codels

The 1 pixel bitmap of the 31x3 program :

Piet 31x3 - Codel 1[1]

There might be still some room for improvement.
But the Direction Pointer & Codel Chooser are not making things easier.

This is the 12 codel image :

Piet 31x3 - Codel 12[2]

Remarks :

Because of the upper-left black codel, npiet online seems to have a problem with it.
But it works on PietDev.

\$\endgroup\$
  • \$\begingroup\$ PietDev should be used with caution because it ignores some specs. The black start codel problem is one of them. The other is wrong behavior for the DIV operation that generates float values although the spec says that all values in Piet are integers. Npiet is a good way to check if a program really works. \$\endgroup\$ – M L Sep 8 '15 at 17:33
  • 1
    \$\begingroup\$ Yes, I noticed that after I posted this solution. The div problem on PietDev is not a problem if you just use it for output, since that only uses the integer part. And i.m.h.o., I do believe it would be an enrichment to npiet if it allowed to start with black codels till another colour is found. You could write piet programs with a black frame that way. \$\endgroup\$ – LukStorms Sep 9 '15 at 7:45
  • \$\begingroup\$ I'm awarding the bounty to this submission, despite the black codel. The reuse of 2 and 3-large cells is very nice - I thought I'd try golfing this down a column or two but it's surprisingly hard. Makes me think 87 might be possible though. \$\endgroup\$ – Sp3000 Sep 9 '15 at 7:56
  • \$\begingroup\$ @Sp3000 Thanks for the bounty reward. I've been trying to find a solution without the black codel that's below 30x3. But can't seem to find one. But I still believe there should exist a 29x3 solution. Piet is just a immense pain to golf. It's not just a matter of getting the optimal result from the stack. \$\endgroup\$ – LukStorms Sep 14 '15 at 21:24
17
\$\begingroup\$

Hot Soup Processor, 17 bytes

mes"Hello, World!

This one's pretty straightforward, but I'm not aware of any other language which can use mes ("message") to print. The language itself is actually of Japanese origin, as one can tell from their website.

Apparently the closing quote isn't necessary (as of ver 3.4a), which is unusual for a non-esolang.

\$\endgroup\$
  • 6
    \$\begingroup\$ "HSP is a development language of the interpreter type. The world can be constructed by expanding the wing of the creation." Did you expand the wing of the creation? \$\endgroup\$ – therealfarfetchd Jan 29 '17 at 21:15
16
\$\begingroup\$

IRC, 27 bytes

/nick h
/quit Hello, World!

The esolangs page comes with a really lengthy two-file "Hello, World!" example. It turns out that is completely unnecessary. The main file of an IRC program contains the program name, a list of channels (which are found in separate files and define individual threads) as well a generic error message which is displayed for various errors. However, that error message can be anything and goes to STDOUT. So let's define our error message as Hello, World!. The shortest way to raise an appropriate error is simply not to define any channels. Voilà, almost 800 bytes saved.

\$\endgroup\$
  • 5
    \$\begingroup\$ You know some of the weirdest esolangs. \$\endgroup\$ – kirbyfan64sos Sep 3 '15 at 23:47
  • \$\begingroup\$ Does it print to STDERR? \$\endgroup\$ – minmaxavg Jul 1 '16 at 0:02
  • 1
    \$\begingroup\$ @minmaxavg it's been a while, but since I explicitly mention it in the explanation I'm pretty sure that I checked that the error message goes to STDOUT and not too STDERR. \$\endgroup\$ – Martin Ender Jul 1 '16 at 5:49
16
+100
\$\begingroup\$

Wierd (John's), 432 421 302 289 256 225 197 181 bytes

-*******************           !dlroW ,olleH
 *
 R*   *    *     *
 E*  **    **   *
 T*  **    **  *
 U ***   ***  ****
 R   *  *  *      *
 N  *    *  ********
    *  ****
 0   **

Try it online!

Background

Wierd's workspace determines both code and data. While each character sets the workspace's cell to its code point (missing characters are treated as spaces, which have code point 32), the code is defined by a particle that starts in the upper left corner and moves along a wire. This wire is also defined by the characters: non-spaces form wires, spaces separate these wires. Instructions are encoded into the kind of turns the particle takes.

At the beginning, the upper left corner holds the number 45, which is the x-coordinate of the cell to the right of !dlrow ,olleH. Each loop through the asterisks that form the main wire decrements that coordinate, prints the character, then prints the character it points to. After all 13 characters have been printed, the upper left corner becomes a space, causing the particle to traverse RETURN 0 instead of the main wire. Once 0 is reached, the particle can no longer move; the program ends.

For the first 12 iterations, the particle moves as follows.

<style>body,html,svg{display:block;height:100%;margin:0;padding:0;}</style>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 210 105"><path d="M 20 80 L 20 100" fill="none" stroke="#FFC0C0" stroke-width="3"/><path d="M 20 8.5 L 20 80" fill="none" stroke="#C00000" stroke-width="3"/><path d="M 20 98.5 L 20 101.5" fill="none" stroke="#C00000" stroke-width="3"/><path d="M 180 30 L 200 10 L 199 10" fill="none" stroke="#C0C0C0" stroke-width="3"/><path d="M 200 10 L 10 10 L 30 30 L 30 50 L 40 60 L 60 60 L 70 50 L 70 30 L 60 40 L 60 70 L 50 80 L 50 90 L 60 100 L 70 100 L 80 90 L 110 90 L 90 70 L 100 60 L 120 60 L 130 50 L 130 40 L 120 30 L 120 70 L 130 80 L 200 80 L 180 60 L 150 60 L 180 30" fill="none" stroke="#000000" stroke-width="3"/><path d="M 10 10 L 30 30 L 30 50 L 40 60 L 60 60 L 70 50 L 70 30 L 60 40 L 60 70 L 50 80 L 50 90 L 60 100 L 70 100 L 80 90 L 110 90 L 90 70 L 100 60 L 120 60 L 130 50 L 130 40 L 120 30 L 120 70 L 130 80 L 200 80 L 180 60 L 150 60 L 180 30 L 200 10 Z" fill="none" id="move-loop"/><circle r="4" fill="#00C0C0"><animateMotion dur="10s" repeatCount="indefinite"><mpath xlink:href="#move-loop"/></animateMotion></circle></svg>

However, during the thirteenth and last iteration, the upper left corner if removed, so the particle moves down the red wire instead.

Code

As illustrated in the Stack Snippet, the particle takes the following left turns on the main wire.

  • 315° Subtract. Nothing is done, since the stack is empty.

    This turn, like the other no-ops, is made solely to save space.

  • 45° Push 1. STACK: [1]

  • 45° Push 1. STACK: [1 1]

  • 45° Push 1. STACK: [1 1 1]

  • 45° Push 1. STACK: [1 1 1 1]

  • 135° Pop the stack. Since the popped element is 1, pop two more values (1 1) and push the code point of the character at those coordinates. STACK: [1 n]

    Initially, the character at (1, 1) is -, so n = 45.

  • 45° Push 1. STACK: [1 n 1]

  • 315° Subtract. STACK: [1 (n-1)]

  • 45° Push 1. STACK: [1 (n-1) 1]

  • 45° Push 1. STACK: [1 (n-1) 1 1]

  • 45° Push 1. STACK: [1 (n-1) 1 1 1]

  • 45° Push 1. STACK: [1 (n-1) 1 1 1 1]

  • 315° Subtract. STACK: [1 (n-1) 1 1 0]

  • 135° Pop the stack. Since the popped element is 0, pop two more values (1 1) and store the next value on the stack (n-1) at those coordinates. STACK: [1]

    During the first run, the upper left corner changes from - (45) to , (44).

    During the thirteenth and last run, the upper left corner changes from ! (33) to space (32), essentially cutting the wire.

  • 270° Pop the stack. Since the popped element is 1, continue. STACK: []

  • 315° Subtract. Nothing is done, since the stack is empty.

  • 45° Push 1. STACK: [1]

  • 45° Push 1. STACK: [1 1]

  • 45° Push 1. STACK: [1 1 1]

  • 135° Pop the stack. Since the popped element is 1, pop two more values (1 1) and push the code point of the character at those coordinates. STACK: [(n-1)]

  • 45° Push 1. STACK: [(n-1) 1]

  • 45° Push 1. STACK: [(n-1) 1 1]

  • 135° Pop the stack. Since the popped element is 1, pop two more values (1 (n-1)) and push the code point of the character at those coordinates. STACK: [c]

    During the first run, this retrieves the character at (44, 1), which is H.

  • 45° Push 1.

  • 225° Pop the stack. Since the popped element is 1, pop the next item and print it to STDOUT. STACK: []

  • 180° Jump to the rightmost star on the first line.

  • 135° Get/set. Nothing is done, since the stack is empty.

    After this turn in the upper left corner, the particle starts over.

\$\endgroup\$
  • \$\begingroup\$ That is amazing. I couldn't figure out how to exit the loop and settled for doing it the long way - big mistake. \$\endgroup\$ – Jerry Jeremiah Oct 9 '17 at 9:39
15
\$\begingroup\$

GOTO++, 31 bytes

s=«Hello, World!»
GOTOPRINT()

This one is actually a bit interesting. There is a more intuitive way to output things in GOTO++, which would be this:

GOTOPRINTDUTEXTE()«Hello, World!»

This is however 35 bytes. GOTOPRINTDUTEXTE outputs its arguments to STDOUT (Du texte means some text in french). Note that the arguments of a function don't necessarily have to be inside the brackets, as long as they are to the right of the left bracket. So GOTOPRINTDUTEXTE()«Hello, World!» is just as valid as GOTOPRINTDUTEXTE(«Hello, World!»)

GOTOPRINT() on the other hand, outputs to STDOUT the very last variable modified by a =.

\$\endgroup\$
15
\$\begingroup\$

Starry, 191 188 186 182 172 169 bytes

        + + +* +  * + + +* + .* +         + +* * +      +* .  + + . + . +        + +   +* + . +          +   * +* + .         + +  * +* . +*      + * . + .* . . .  + * .

This is almost definitely suboptimal, but Starry golfing is surprisingly difficult, due to the cost of pushing a number being higher than that of performing an operation. Thankfully we can reuse a lot of past computations, due to duplicate letters in the message "Hello, World!".

Starry operators are determined by the number of spaces before one of +*.,`. The relevant ones used are:

Spaces       Char      Operation
-----------------------------------------------------
1            +         Duplicate top of stack
2            +         Swap top 2 stack elements
3            +         Rotate top 3 stack elements
n >= 5       +         Push n-5 to stack
0 mod 5      *         Add
1 mod 5      *         Subtract
2 mod 5      *         Multiply
1 mod 2      .         Output as ASCII

And here is the program broken down:

Line                        Explanation            Stack                 Out
-------------------------------------------------------------------------------------
        + + +* +  * +       Push 3 and 36, dup     [3 36 36]
 + +* + .                   Dup, x2, dup, print    [3 36 36 72]            H
*                           Add                    [3 36 108]              H
 +         + +* * +         Dup, sub 8, dup        [3 36 108 100 100]      H
      +* .                  Add 1, print           [3 36 108 100]          He
  + + .                     Swap, dup, print       [3 36 100 108]          Hel
 + .                        Dup, print             [3 36 100 108]          Hell
 +        + +               Dup, push 3, dup       [3 36 100 108 108 3 3]  Hell
   +* + .                   Rot 3, add, dup, print [3 36 100 108 3 111]    Hello
 +          +   * +* + .    Dup, //5*2, dup, print [3 36 100 108 3 111 44] Hello,
         + +  * +* .        Print 32               [3 36 100 108 3 111 44] Hello, 
 +*      + * .              Double, sub 1, print   [3 36 100 108 3 111]    Hello, W
 + .                        Dup, print             [3 36 100 108 3 111]    Hello, Wo
* .                         Add, print             [3 36 100 108]          Hello, Wor
 . .                        Print, print           [3 36]                  Hello, World
  + * .                     Swap, sub, print       []                      Hello, World!
\$\endgroup\$
15
\$\begingroup\$

Funciton, 212 209 bytes

╔══════════╗
║2388215291╟
║3945970717║
║0943959830║
║0709090713║
║3592077341║
║6068961777║
║8210571695║
║52834632  ║
╚══════════╝

I found that 10 digits per row yielded the least bytes, although there may have been a mistake in my calculations.

\$\endgroup\$
15
\$\begingroup\$

Minecraft 1.8.7, 26 + 2 = 28 Blytes

This is using this version of byte counting.

the system

The command block contains the code:

tellraw @a "Hello, World!"

This one doesn't really need an explanation.

\$\endgroup\$
  • \$\begingroup\$ Use a button instead on this one. \$\endgroup\$ – SuperJedi224 Nov 13 '15 at 0:42
  • 2
    \$\begingroup\$ This scoring method is called blytes (blocks + bytes). \$\endgroup\$ – user48538 Jan 10 '16 at 15:45
  • \$\begingroup\$ @zyabin101 I know - I created the term. I hadn't updated it though. :P Thanks. \$\endgroup\$ – Addison Crump Jan 10 '16 at 17:58
  • 18
    \$\begingroup\$ You couldn't have taken a screenshot during the day? \$\endgroup\$ – mbomb007 Feb 24 '16 at 19:57
15
\$\begingroup\$

Cheddar, 20 bytes

print"Hello, World!"

Yes!!!!!

I have been waiting for this day a long time. After days of banging my head on my desk trying to get Cheddar to work. I have finally made a Cheddar REPL. The REPL is very alpha, so if you'd like to test it out, ping me in chat @Downgoat

Update: To run simply go to cheddar.vihan.org and follow the download instructions

Update 2: Use the experimental online REPL at: cheddar.vihan.org/repl

\$\endgroup\$
  • 2
    \$\begingroup\$ -1 Language name makes me want cheese ;) \$\endgroup\$ – Beta Decay Aug 15 '16 at 20:22
15
\$\begingroup\$

Wierd, 1341 bytes

Unlike other languages where the symbols in a program determine which instructions are executed, in Wierd, it is the bends in the chain of arbitrary symbols that determine which instructions are executed.

From the website:

First, a Riddle:
Q: What do you get when you put three marginally-sane programmers on a mailing list with the Befunge and BrainF*** programming languages?
A: You get BeF***, and then they get Wierd.
...
Chris Pressey then jumped on it, created the angle-to-instruction mapping, and christened the entire mess "Wierd"--a cross between the words "weird" (which the language seemed to be) and "wired" (which would describe the appearance of programs written in the language).

Try it online at http://catseye.tc/installation/Wierd_(John_Colagioia)

EDIT: Dennis has killed this answer quite thoroughly with this

Even though this is much smaller than the sameple that comes with the interpreter I am positive this can be golfed more (and it has been - by Dennis) Please try to come up with something smaller and edit the question with that version.

,!dlroW             ++
o     #           ++  +
l               ++    + ++++
l     +++     ++      ++  +
e    +   +  ++    ++  +  +
H   +  +  ++    ++  +   +
+  +  ++      ++     +++
+ ++++ +    ++
+      +  ++           ++
+  +++++++   +++     ++  +
 ++    +    +   +  ++    + ++++
       +   +  +  ++      ++  +
       +  +  ++      ++  +  +
       + ++++ +    ++  +   +
       +      +  ++     +++
       +  +++++++
        ++    +   +++
    +         +  +   +  ++
    ++       +  +  +  ++  +
    + +     +  +  ++      + ++++
    +  +    + ++++ +      ++  +
     +  +   +      +  ++  +  +
      +  +  +  +++++++  +   +
    ++++  +  ++    +     +++
    +      +       +
     +      +++++++      +++
      +                ++   +
       +             ++     +
       +           ++      +
++++++++++++     ++   ++  ++++
 +     +    +  ++   ++  +     +
  ++++ +     ++   ++     +++++++
    +  +        ++
   +   +      ++
  +    +    ++
 +     +  ++
+       ++        +++
+               ++   +
+ +++++++     ++     +
+  +     +  ++      +
+   ++++  ++   ++  ++++
+     +      ++  +     +
+    +     ++     +++++++
+    +   ++
+  ++++++   +++++++     +++
 ++  +       +     +  ++   +
     +        ++++  ++     +
     +          +         +
     +      ++++     ++  ++++
     +             ++  +     +
     +  +++++++++++     +++++++
      ++
\$\endgroup\$
  • 1
    \$\begingroup\$ Nice job! I was hoping someone would beat the official HW example eventually. :) \$\endgroup\$ – Martin Ender Jan 12 '16 at 9:15
  • \$\begingroup\$ I wonder if they misspelled "weird" intentionally... \$\endgroup\$ – mbomb007 Feb 24 '16 at 19:58
  • 1
    \$\begingroup\$ @mbomb007 Yes. The web page catseye.tc/view/wierd/dialect/wierd-jnc/doc/wierdspec.txt says that Chris Pressey then jumped on it, created the angle-to-instruction mapping, and christened the entire mess "Wierd"--a cross between the words "weird" (which the language seemed to be) and "wired" (which would describe the appearance of programs written in the language) \$\endgroup\$ – Jerry Jeremiah Feb 24 '16 at 20:12
15
\$\begingroup\$

Brain-Flak, 142 140 136 bytes

((((((((((((()()){}){}){}){}()))){}{}())([][]){})[][])[[]]())[((()[]){}){}])([()[]](([]([](((([][]))([]{}{})))[]{}[])[[]])))(([][][]){})

Try it online!

In the time since this answer was originally posted (original code below) Jo-King wrote a computer program that was able to find a shorter Hello World. After careful examination I was able to shave 2 bytes off of the computers program. Jo-King then improved his program to outgolf me. But I'm not beaten that easily and I've golfed it back, taking another 2 bytes off the machine. I won't explain the entire program because I don't understand it and Jo-King has already done that in the linked post but I will explain my golf. My golf pertains the part that looks like:

([][]([](()[][]){}))

From here I noticed that [][] was repeated twice. I thought it might be a good idea to cache this value instead:

(([][])([]((){}){}))

However because there is a [] between the push and the pop this is off by one. We can fix this by moving the () outside of the double to decrease by 1.

(([][])([]()({}){}))

At this point we can increase the [] in between by another one by pushing [][] twice instead of once

((([][]))([]{}{}))

This saves 2 bytes.

A man ain't nothin' but a man, And before I'll let your [metagolfer] beat me down, I'll die with the [keyboard] in my hand.

Original code, 148 bytes

Now that DJMcMayhem's answer has depreciated. I made a replacement (and even removed a few bytes).

(((((((((((()()()()){}){}){}()))){}{}())[][][][])[][])[[]]())[[][][][][]]())([([]([])[][]{})]()()()([[]](([()()()]([([][][])](((({}()){}))){}{})))))

Try it Online!

Explanation

This explanation was create by Poke

(
 (
  (
   (
    (
     (
      (
       (
        (
         (
          (()()()()){} Add 8... to 0
         ){} Double to 16
        ){}() Double and add 1 to 33 which is !
       ) Push the ! to save it for the end
      ) Push an extra 33 to help add to get to the first letter
     ){}{}() Triple the 33 and add 1 for 100 which is d
    )[][][][] Push the d to save it for the end. Add height-2, 4 times for 108 which is l
   )[][] Push the l to save for the end then add height-3, 2 times = 114 which is r
  )[[]]() Push the r to save for the end then subtract height-4 and add 1 = 111 which is o
 )[[][][][][]]() Push the o to save for the end then subtract height-5 5 times and add 1 = 87 which is W
) Push W to save for the end
At this point the stack contains "!dlroW". 87 Floating
( We're now a level lower so we start at 0 for the math here.
 [([]([])[][]{})]()()() Push 6+6+7+7+6=32 which is the space, then negate it + 3 = -29 Floating
 (
  [[]] negate height-7 = -7 Floating
  (
   (
    [()()()] -3 Floating
    (
     [([][][])] Push 3*height-7 = 21 and negate it = -21 Floating
     (
      (
       (
        ({}()){} 21+1+22 = 44 which is the comma
       ) Push the , to save for the end
      ) Push another 44
     ){}{} 44+44+44 = 132
    ) Push 132 plus the -21 we left floating earlier = 111 which is o
   ) Push 111 plus the -3 we left floating earlier = 108 which is l
  ) Push another l
 ) Push 111 plus the -7 we left floating earlier = 101 which is e
) Push 101 plus the -29 we left floating earlier = 72 which is H
At this point the stack contains "!dlroW ,olleH" and our accumulator is at 159 which doesn't get used.
\$\endgroup\$
  • 4
    \$\begingroup\$ Here's an explanation... It's not great. I don't know the proper vernacular for this language. Try it online! \$\endgroup\$ – Poke Apr 12 '17 at 14:37
14
\$\begingroup\$

Piet, 15x15(225) 13x15(195) codels

I think Piet program size is counted by codels. If someone wants to know the size in bytes anyway, I could shrink it down to 495 bytes(15x15 codels) and 476 bytes(13x15 codels) using PNGGauntlet.

Codel size 10 for better visibility.

13x15 version:

Piet "Hello, World!" 13x15

First version (15x15):

Piet "Hello, World!"

I was a bit lazy with this solution. I should be able to golf it down a bit more. This solution fills up the stack with ASCII-32 and reads it out in a loop (ASCII+32).

Output:

D:\codegolf\Piet\npiet-1.3a-win32>npiet "Hello World codegolf.png"
Hello, World!
D:\codegolf\Piet\npiet-1.3a-win32>
\$\endgroup\$
14
\$\begingroup\$

FiM++, 88 bytes

Dear Princess Celestia:H.Today I learned:I sang "Hello, World!".Your faithful student,M.

FiM++ is an object-oriented language inspired by My Little Pony: Friendship is Magic. Yeah, right.

Printing "Hello, World!" is fairly straightforward, and there was an example in the interpreter's repository which I used as the basis for the above code. The main golfing steps were figuring out which parts could be shortened or left out and which couldn't... and the fact that I could replace I wrote ... with I sang ....

The interpreter prints a bunch of diagnostic information before running the code, but that does not appear to be part of the actual language specification.

\$\endgroup\$
13
\$\begingroup\$

><>, 23 bytes

"!dlroW ,olleH"l?!;oe0.

><>, or "Fish", is a 2D stack-based language like Befunge. Here's the breakdown:

[setup]

"                    Start string parsing
!dlroW ,olleH        Push each of these chars one-by-one onto the stack
"                    Stop string parsing

[main loop]

l?!;                 If the length of the stack is 0, halt
o                    Otherwise, output the top of the stack as char
e0.                  Jump back to just before the l
\$\endgroup\$
13
\$\begingroup\$

Alchemy, 1013 bytes

Fixate 1 dr Eulerius (1 oz Alkahest): Bius
Fixate 1 dr Periphius (1 oz Alkahest): Cius
Fuse 1 dr Bius, 1 dr Bius, 1 dr Cius, 1 dr Cius (4 oz Alkahest): Zius
Fuse 1 dr Zius, 1 dr Bius (2 oz Alkahest): Hium
Fuse 1 dr Cius, 1 dr Periphius, 1 dr Periphius (3 oz Alkahest): Dius
Project 1 oz Hium, 1 oz Dius (3 oz Alkahest): Eium
Fuse 1 dr Zius, 1 dr Cius (2 oz Alkahest): Lium
Project 1 oz Lium, 1 dr Cius (3 oz Alkahest): Oium
Fuse 1 dr Bius, 1 dr Cius, 1 dr Eulerius, 1 dr Eulerius (4 oz Alkahest): Cium
Ferment 1 dr Zius, 1 dr Periphius (2 oz Alkahest): Sium
Project 1 dr Cium, 1 dr Cium (4 oz Alkahest): Wium
Ferment 1 dr Wium, 1 dr Aquaphidium (4 oz Alkahest): Wium
Project 1 dr Oium, 1 dr Cius (3 oz Alkahest): Rium
Ferment 1 dr Eium, 1 dr Aquasoothius (3 oz Alkahest): Dium
Project 1 dr Sium, 1 dr Aquasoothius (3 oz Alkahest): Xium
Multiply 1 oz Hium, 1 oz Eium, 1 oz Lium, 1 oz Lium, 1 oz Oium, 1 oz Cium, 1 oz Sium, 1 oz Wium, 1 oz Oium, 1 oz Rium, 1 oz Lium, 1 oz Dium, 1 oz Xium (26 oz Alkahest): Scribius

This is one weird language. The above is probably not entirely optimal, but I also don't think that the optimal solution will be significantly shorter (I did try to obtain the numbers as efficiently as possible locally). Also, the language spec seems to imply that the amounts of the reagents should actually match up (when multiplied by their "substance numbers" which are the sums of their ASCII values...), but the only interpreter I could find doesn't seem to be checking that.

In fact, the interpreter had a memory corruption bug which I had to fix to run the above code.

Some explanation would probably be helpful. Let e, π, and φ have their usual meanings. Then the above code translates roughly to the following pseudocode:

b = floor(e)         // 2
c = floor(π)         // 3
z = b * b * c * c    // 36
H = z * b            // 72
d = c * π * π        // 29.6088
E = H + d            // 101.6088
L = z * c            // 108
O = L + c            // 111
C = 2 * 3 * e * e    // 44.3343
S = z - π            // 32.8584
W = C + C            // 88.6686
W = W - φ            // 87.0506
R = O + c            // 114
D = E - 1            // 100
X = S + 1            // 33
Print( H, E, L, L, O, C, S, W, O, R, L, D, X )
\$\endgroup\$
12
\$\begingroup\$

Zsh, 17 bytes

<<<Hello,\ World!
\$\endgroup\$
12
\$\begingroup\$

Fission, 17 bytes

R"Hello, World!";

or

;"!dlroW, olleH"L

or any cyclic permutation of the two. In Fission, we need the R or L to release an atom and get control flow going. " toggles print mode, which just prints everything encountered until switched off. Finally ; destroys the atom to avoid an infinite loop.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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