523
\$\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 = (function(){
  var headerTag     = String.raw `h\d`
  var score         = String.raw `\-?\d+\.?\d*` // with negative/floating-point support
  var normalText    = String.raw `[^\n<>]*` // no HTML tag, no newline
  var strikethrough = String.raw `<s>${normalText}</s>|<strike>${normalText}</strike>|<del>${normalText}</del>`
  var noDigitText   = String.raw `[^\n\d<>]*`
  var htmlTag       = String.raw `<[^\n<>]+>`

  return new RegExp(
  String.raw  `<${headerTag}>`+
  String.raw    `\s*([^\n,]*[^\s,]),.*?`+
  String.raw    `(${score})`+
  String.raw    `(?=`+
  String.raw      `${noDigitText}`+
  String.raw      `(?:(?:${strikethrough}|${htmlTag})${noDigitText})*`+
  String.raw      `</${headerTag}>`+
  String.raw    `)`
  );
})();

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,
      });
    
  });
  
  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('<i>' + a.language + '</i>').text().toLowerCase();
    
    languages[lang] = languages[lang] || {lang: a.language, user: a.user, size: a.size, link: a.link, uniq: lang};
  });

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

  langs.sort(function (a, b) {
    if (a.uniq > b.uniq) return 1;
    if (a.uniq < b.uniq) 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}

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

#language-list {
  padding: 10px;
  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/primary.css?v=f52df912b654">
<div id="language-list">
  <h2>Winners 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><a href="{{LINK}}">{{SIZE}}</a></td></tr>
  </tbody>
</table>
<table style="display: none">
  <tbody id="language-template">
    <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td><a href="{{LINK}}">{{SIZE}}</a></td></tr>
  </tbody>
</table>

\$\endgroup\$
22
  • 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\$ Commented 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\$ Commented 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\$ Commented 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\$ Commented 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\$
    – user202729
    Commented May 20, 2018 at 10:20

1002 Answers 1002

1 2 3
4
5
34
9
\$\begingroup\$

Ziim, 1222 bytes

In an unexpected turn of events, I'm counting this submission in UTF-16.

↘ ↓↘↘↘↘↙↓↘↘ ↙↓↘ ↓↘ ↙↘←↓ ↘↘↙↓↘↘↘↙↓↘↘↘↘↙↓↘↘↘↘↙↓ ↘↘↙↓↘↘↙↓↘ ↙ ↘ ↓↘ ↙↘←↓↘ ↙ ↘ ↓ ↘↘↙↓↘↘↙↓↘↘↘↘↙↓ ↘ ↙↘←↓↘ ↙ ↘ ↓ ↘ ↙ ↘ ↓↘↘↙↓↘↘↘↙↓↘↘↘↙↓↘↘ ↙↓↘←↓↘ ↙↓↘ ↓↘↘↙↓ ↘↘↙↓↘↘↙↓↘ ↙↘←↓↘ ↙↘←↓ ↘ ↙↘←↓ ↘↘↙↓↘↘↙↓ ↘ ↙ ↘ ↓↘↘ ↙ ↘ ↓↘ ↙↓↘←
↓→↘ ↑↑↓→↘ ↑↓  ↓→↘ ↓↓↓→↘↘ ↓→↘ ↑↓→↘ ↑↑↓→↘ ↑↑↓→↘↘ ↓→↘ ↓→↘ ↓↓↓↓→↘ ↓↓↓→↘ ↓↓↓↓→↘↘ ↓→↘ ↓→↘ ↑↑↓→↘↘ ↓↓↓→↘ ↓↓↓↓→↘↘ ↓↓↓↓→↘ ↓→↘ ↑↓→↘ ↑↓→↘ ↑↓  ↓→↘ ↓  ↓→↘ ↓→↘↘ ↓→↘ ↓→↘ ↓↓↓→↘ ↓↓↓→↘↘ ↓↓↓→↘↘ ↓→↘ ↓→↘↘ ↓↓↓↓→↘ ↑↓↓↓↓→↘ ↓  ↓→
↗  ↑↖ ↗  ↑↖↗↑↗↗  ↑↗↗↗  ↑↑↗  ↑↖↗  ↑↖ ↗  ↑↖ ↗  ↑↑↗  ↑↗  ↑↗↗↗↗  ↑↗↗↗  ↑↗↗↗↗  ↑↑↗  ↑↗  ↑↖ ↗  ↑↑↗↗↗  ↑↗↗↗↗  ↑↑↗↗↗↗  ↑↗  ↑↖↗  ↑ ↗  ↑↖↗↑↗↗  ↑↗↑↗↗  ↑↗  ↑↑↗  ↑↗  ↑↗↗↗  ↑↗↗↗  ↑↑↗↗↗  ↑↑↗  ↑↗  ↑↑↗↗↗↗  ↑↖↗↗↗↗  ↑↗↑↗↗

Because the code snippet above will likely not render in a very readable manner for you (either because of missing characters, or because the diagonal arrows aren't as monospaced as they should be), here is an image of the solution. I've marked the concatenators where a new byte starts in red:

enter image description here
Click for larger version

Well, this is a bit embarrassing. I spent quite some time on this solution, and at 610 characters, it is 267 characters shorter than the one on the esolangs page. However, it contains a lot more arrows, and because those are 3 bytes in UTF-8, it's actually longer than the one on esolangs (1516 vs 1345). But because this solution is so dense and contains far more arrows than spaces, I'm actually saving bytes by using UTF-16 and counting each character as two bytes.

Anyway, regardless of how we're counting, this is far from optimal. The above code is entirely linear, and builds one bit at a time. So I'm not reusing any bitstrings (like I could for the ls or os or even other substrings). I chose this approach because I wanted to start with something where it would be easier to pack the arrows very densely. If one used a more square layout, one could make use of a lot more repetition in the output (on a bit level), and thereby make massive savings.

\$\endgroup\$
4
  • \$\begingroup\$ Most 2d languages are generally scored by the area of the bounding box, why not do that here? \$\endgroup\$ Commented Jan 29, 2016 at 17:31
  • \$\begingroup\$ @SuperJedi224 [citation-needed]? I've never scored any 2D language like that and the only one which I've seen like that is Piet where I think that's not how we should do it. \$\endgroup\$ Commented Jan 29, 2016 at 17:40
  • \$\begingroup\$ I've definitely seen befunge and <>< scored that way before, and that's how I've generally been scoring BotEngine. \$\endgroup\$ Commented Jan 29, 2016 at 17:56
  • 2
    \$\begingroup\$ @SuperJedi224 if I saw that I would recommend changing it. Programs should be scored by the size of the source file and I don't know any 2D language that chokes on omitted trailing spaces. Plus, if a submission did use up the entire bounding box, you wouldn't be counting any bytes for the aspect ratio of the grid, which is also important information. \$\endgroup\$ Commented Jan 29, 2016 at 18:11
9
\$\begingroup\$

Monicelli, 46 bytes

Lei ha clacsonato
"Hello, World!" a posterdati

Probably appreciated only by italian coders, all the tokens of this language are taken from a well-known italian movie called "amici miei"

\$\endgroup\$
9
\$\begingroup\$

Emotinomicon, 18 characters / 30 bytes

Try it here.

😭!dlroW ,olleH😲⏪⏬⏩

Explanation:

😭  !dlroW ,olleH   😲  ⏪   ⏬   ⏩   explanation
😭                                   begin quote string
    !dlroW ,olleH                   
                    😲               end quote string
                        ⏪           open loop
                            ⏬       pops and outputs top of stack as character
                                ⏩   close loop
\$\endgroup\$
0
9
\$\begingroup\$

ELF 64-bit LSB executable (Linux), 104 bytes

0000000: 7f 45 4c 46 02 01 01 03 b0 04 b3 01 b2 0e eb 18  .ELF............
0000010: 02 00 3e 00 01 00 00 00 08 00 40 00 00 00 00 00  ..>.......@.....
0000020: 30 00 00 00 00 00 00 00 b9 48 00 40 00 90 eb 30  [email protected]
0000030: 01 00 00 00 01 00 38 00 01 00 00 00 00 00 00 00  ......8.........
0000040: 01 00 40 00 00 00 00 00 48 65 6c 6c 6f 2c 20 57  [email protected], W
0000050: 6f 72 6c 64 21 0a 00 00 6f 72 6c 64 21 0a 00 00  orld!...orld!...
0000060: cd 80 b0 01 b3 00 cd 80                          ........

This sets as many proper headers as possible without affecting the byte count, prints a trailing linefeed and exits cleanly with exit code 0.

Try it online!

Verification

$ cksum hw64
3288151474 104 hw64
$ file hw64
hw64: ELF 64-bit LSB executable, x86-64, version 1, statically linked, corrupted section header size
$ ./hw64
Hello, World!
$ echo $?
0
\$\endgroup\$
3
  • 1
    \$\begingroup\$ Disassembly output of the code stuffed into the ELF headers would be nice, if you needed any special tricks to make instruction bytes also be valid ELF headers. (Future readers: see muppetlabs.com/~breadbox/software/tiny/teensy.html for more about this kind of hack.) \$\endgroup\$ Commented Apr 13, 2018 at 0:57
  • \$\begingroup\$ O_o why is there an extra orld! \$\endgroup\$
    – ASCII-only
    Commented Apr 13, 2018 at 4:55
  • 1
    \$\begingroup\$ @ASCII-only The answer saves bytes by storing data in the ELF's program header. The longs at 0x50 and 0x58 encode the virtual and physical addresses of the segment, and they program segfaults if they do not match. \$\endgroup\$
    – Dennis
    Commented Apr 13, 2018 at 5:26
9
\$\begingroup\$

INTERCAL, 285 bytes

DO,1<-#14
DO,1SUB#1<-#238
DO,1SUB#2<-#108
DO,1SUB#3<-#112
PLEASE DO,1SUB#4<-#256
DO,1SUB#5<-#64
DO,1SUB#6<-#194
PLEASE DO,1SUB#7<-#48
DO,1SUB#8<-#26
DO,1SUB#9<-#244
PLEASE DO,1SUB#10<-#168
DO,1SUB#11<-#24
DO,1SUB#12<-#16
PLEASE DO,1SUB#13<-#162
DO,1SUB#14<-#52
DO READ OUT,1
DO GIVE UP

Try it online!

\$\endgroup\$
9
\$\begingroup\$

Self-modifying Brainfuck, 28 19 bytes

represents a literal NUL byte.

<[.<]␀!dlroW ,olleH

Try it online

This is my Python interpreter that is referenced on the Esolangs page for SMBF. The default/example program is the program above. The SMBF code is entered on line 178 so that the Input box can be used for STDIN.

If input is not empty, it would need to be this (20 bytes):

<[.+<]␀!dlroW ,olleH

Since SMBF has its own source code on the same tape, we put the string on the tape in reverse to facilitate printing. Then we print all the cells from right to left up to the cell with zero in it (the cell represented by ). After printing, I have to change the comma to a different character so it doesn't look for input. Using + changes it to a - and vice versa, so either way it's a no-op (not that it matters, since printing is done anyway).

\$\endgroup\$
6
  • \$\begingroup\$ The second version could be just <[.+<]\x00!dlroW ,olleH, couldn't it? \$\endgroup\$
    – primo
    Commented Jul 27, 2016 at 12:55
  • \$\begingroup\$ @primo Yeah, it could. \$\endgroup\$
    – mbomb007
    Commented Jul 28, 2016 at 14:16
  • 1
    \$\begingroup\$ Doesn't the second version work even with input? Sure, it'll read a byte of input, but the program does the same thing regardless of whether any byte or EOF is read. \$\endgroup\$
    – user62131
    Commented May 1, 2017 at 1:13
  • \$\begingroup\$ Taking input when you're not supposed to isn't allowed. That's what the 2nd program is assuming. \$\endgroup\$
    – mbomb007
    Commented May 1, 2017 at 14:29
  • \$\begingroup\$ Try it online! \$\endgroup\$
    – Deadcode
    Commented Apr 7, 2021 at 19:23
9
\$\begingroup\$

Mornington Crescent, 3328 3271 bytes

Take Northern Line to Leicester Square
Take Piccadilly Line to Heathrow Terminals 1, 2, 3
Take Piccadilly Line to Holborn
Take Central Line to Holborn
Take Central Line to Bank
Take District Line to Hammersmith
Take District Line to Gunnersbury
Take District Line to Hammersmith
Take District Line to Parsons Green
Take District Line to Bank
Take District Line to Hammersmith
Take District Line to Bow Road
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Parsons Green
Take District Line to Parsons Green
Take District Line to Gunnersbury
Take District Line to Paddington
Take District Line to Hammersmith
Take District Line to Parsons Green
Take District Line to Bank
Take District Line to Hammersmith
Take District Line to Gunnersbury
Take District Line to Barking
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 District Line to Parsons Green
Take District Line to Elm Park
Take District Line to Acton Town
Take Piccadilly Line to Heathrow Terminal 5
Take Piccadilly Line to Acton Town
Take District Line to Acton Town
Take District Line to Parsons Green
Take District Line to Bank
Take District Line to Hammersmith
Take District Line to Plaistow
Take District Line to Hammersmith
Take District Line to Gunnersbury
Take District Line to Mile End
Take District Line to Elm Park
Take District Line to Mile End
Take District Line to Paddington
Take Circle Line to Paddington
Take Hammersmith & City Line to Barking
Take Hammersmith & City Line to Paddington
Take Circle Line to Paddington
Take Bakerloo Line to Piccadilly Circus
Take Bakerloo Line to Piccadilly Circus
Take Piccadilly Line to Turnpike Lane
Take Piccadilly Line to Turnpike Lane
Take Piccadilly Line to Leicester Square
Take Northern Line to Leicester Square
Take Northern Line to Charing Cross
Take Northern Line to Charing Cross
Take Northern Line to Bank
Take Circle Line to Bank
Take District Line to Upminster
Take District Line to Bank
Take Circle Line to Bank
Take Northern Line to Charing Cross
Take Northern Line to Bank
Take Circle Line to Westminster
Take District Line to Gunnersbury
Take District Line to Bow Road
Take District Line to Bank
Take District Line to Hammersmith
Take District Line to Gunnersbury
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Aldgate
Take Metropolitan Line to Chorleywood
Take Metropolitan Line to Aldgate
Take Circle Line to Aldgate
Take Circle Line to Bank
Take District Line to Bow Road
Take District Line to Hammersmith
Take District Line to Gunnersbury
Take District Line to Plaistow
Take District Line to Gunnersbury
Take District Line to Mile End
Take Hammersmith & City Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take District Line to Mile End
Take District Line to Bow Road
Take District Line to Mile End
Take Hammersmith & City Line to Paddington
Take Circle Line to Paddington
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!

-57 bytes by using shorter lines and transfer stations

Short explanation: I extract following strings:

Heathrow Terminals 1, 2, 3 (also extracting the numbers for some operations)
--                     --

Holloway Road
  ---

Westminster
-

Chorleywood
  ---     -

The strings are cut in pieces, using the left and right substring functions of Gunnersbury and Mile End with the integers of "Heathrow Terminals 1, 2, 3" and "Heathrow Terminal 5" (which can be extracted using Parsons Green).

Then I concatenate them in Paddington and append a "!" by using the char code of (space)+1.

Source:

// ### Milestone: Extract "He", 1, 2, ", " from "Heathrow Terminals 1, 2, 3"

// Get "Heathrow Terminals 1, 2, 3"
Take Northern Line to Leicester Square
Take Piccadilly Line to Heathrow Terminals 1, 2, 3

// Copy that string
Take Piccadilly Line to Holborn
Take Central Line to Holborn
Take Central Line to Bank // Hammersmith = "Heathrow Terminals 1, 2, 3"

// Prepare for left substring
Take District Line to Hammersmith
Take District Line to Gunnersbury // Gunnersbury = "Heathrow Terminals 1, 2, 3"

// Extract 1 from "Heathrow Terminals 1, 2, 3"
Take District Line to Hammersmith
Take District Line to Parsons Green // Acc = 1, Parsons Green = ", 2, 3"

// Copy and store it somewhere (Parsons Green only returns its stored value if it gets a number)
Take District Line to Bank // Hammersmith = 1
Take District Line to Hammersmith
Take District Line to Bow Road // Bow Road = 1

// Store it in Upminster for later calculations
Take District Line to Hammersmith
Take District Line to Upminster

// Store 2
Take District Line to Hammersmith
Take District Line to Parsons Green // Acc = ", 2, 3"
Take District Line to Parsons Green // Acc = 2, Parsons Green = ", 3"

// Get "He"
Take District Line to Gunnersbury

// Store it in Paddington for concatenation
Take District Line to Paddington // Paddington = "He"

// Extract ", " from ", 3"
Take District Line to Hammersmith
Take District Line to Parsons Green
Take District Line to Bank
Take District Line to Hammersmith
Take District Line to Gunnersbury // 2 was still stored in Gunnersbury

// Store it somewhere
Take District Line to Barking // Barking = ", "

// ### Milestone: Extract "llo" from "Holloway Road"

// Get "Holloway Road"
Take District Line to Acton Town
Take Piccadilly Line to Holloway Road

// Prepare for left substring
Take Piccadilly Line to Acton Town
Take District Line to Acton Town
Take District Line to Gunnersbury // Gunnersbury = "Holloway Road"

// Store 3
Take District Line to Hammersmith
Take District Line to Parsons Green // Acc = 3
Take District Line to Elm Park // Elm Park = 3

// Get 5 from "Heathrow Terminal 5"
Take District Line to Acton Town
Take Piccadilly Line to Heathrow Terminal 5
Take Piccadilly Line to Acton Town
Take District Line to Acton Town
Take District Line to Parsons Green // Acc = 5

// Copy and Store it somewhere
Take District Line to Bank
Take District Line to Hammersmith
Take District Line to Plaistow // Plaistow = 5

// Get "Hollo" from "Holloway Road"
Take District Line to Hammersmith
Take District Line to Gunnersbury // Gunnersbury = 5

// Prepare for right substring
Take District Line to Mile End // Mile End = "Hollo"

// Get "llo" from "Hollo"
Take District Line to Elm Park
Take District Line to Mile End

// Append it to "He"
Take District Line to Paddington
Take Circle Line to Paddington

// Append ", "
Take Hammersmith & City Line to Barking
Take Hammersmith & City Line to Paddington
Take Circle Line to Paddington // Paddington = "Hello, ", Acc = ", Hello, "

// ### Milestone: Get "!" by adding 1 to char value of " "
// Reverse acc
Take Bakerloo Line to Piccadilly Circus
Take Bakerloo Line to Piccadilly Circus
Take Piccadilly Line to Turnpike Lane
Take Piccadilly Line to Turnpike Lane

// Get ASCII value of " "
Take Piccadilly Line to Leicester Square
Take Northern Line to Leicester Square
Take Northern Line to Charing Cross
Take Northern Line to Charing Cross // Acc = 32

// Add 1
Take Northern Line to Bank
Take Circle Line to Bank
Take District Line to Upminster // 1 was stored in Upminster earlier
Take District Line to Bank
Take Circle Line to Bank
Take Northern Line to Charing Cross // Charing Cross = 33

// ### Milestone: Append "W" from "Westminster"
// Get "Westminster"
Take Northern Line to Bank
Take Circle Line to Westminster

// Get "W"
Take District Line to Gunnersbury // Gunnersbury = "Westminster"
Take District Line to Bow Road
Take District Line to Bank
Take District Line to Hammersmith
Take District Line to Gunnersbury

// Append it to "Hello, "
Take District Line to Paddington
Take Circle Line to Paddington

// ### Milestone: Append "orl" and "d" from "Chorleywood"
// Get "Chorleywood"
Take Circle Line to Aldgate
Take Metropolitan Line to Chorleywood

// Save it for copy
Take Metropolitan Line to Aldgate
Take Circle Line to Aldgate
Take Circle Line to Bank

// Bank had 1 in it, so save it for later
Take District Line to Bow Road

// prepare left substring
Take District Line to Hammersmith
Take District Line to Gunnersbury

// get "Chorl"
Take District Line to Plaistow
Take District Line to Gunnersbury

// get "orl"
Take District Line to Mile End // 3 is still stored in Mile End

// append it to "Hello, W"
Take Hammersmith & City Line to Paddington
Take Circle Line to Paddington

// get "d"
Take Circle Line to Hammersmith
Take District Line to Mile End
Take District Line to Bow Road
Take District Line to Mile End

// append it to "Hello, Worl"
Take Hammersmith & City Line to Paddington
Take Circle Line to Paddington

// get "!" and append it to "Hello, World"
Take Bakerloo Line to Charing Cross
Take Bakerloo Line to Paddington

// go home
Take Circle Line to Bank
Take Circle Line to Bank
Take Northern Line to Mornington Crescent
\$\endgroup\$
9
\$\begingroup\$

// TODO: fix, 51 bytes

//TODO:idea:"Hello, World!"TODO:this code is cursed

// TODO: fix is a joke language with commands that look like "TODO" comments in source code, created by RocketRace for JT's langjam.

  • // TODO: idea: "string" pushes a string literal
  • // TODO: this code is cursed outputs that string

The language isn't really designed for golfing, but a bit of fiddling with the syntax got this down to 51 bytes. Here is a more "idiomatic" example taken from the language's README:

use std::io::{stdout, Write};
// TODO: someone on the internet told me "Hello, world!" is a good idea
fn hello() {
    let chars = &[
        '\n', '!', 'd', 'l', 'r', 'o', 'w', ' ', ',', 'o', 'l', 'l', 'e', 'H'
    ];
    let mut out = stdout();
    // TODO: somehow fix this cursed code
    for c in chars.iter().rev() {
        let mut buf = vec![0; 4];
        c.encode_utf8(&mut buf).unwrap();
        out.write(&buf).unwrap();
    }
    out.flush.expect("unwrap");
}

(the language simply ignores everything except the TODOs)

\$\endgroup\$
9
\$\begingroup\$

Aussie++, 34 bytes

G'DAY MATE!
GIMME "Hello, World!";

Tested in commit 0a5de7e. You're supposed to end the program with CHEERS C***!, but as of that commit it isn't strictly necessary. The opening G'DAY MATE!, with trailing whitespace, is; anything before that statement is not executed.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ +1 for introducing me to this amazing language \$\endgroup\$
    – Mayube
    Commented Oct 29, 2021 at 17:52
9
\$\begingroup\$

Plumber, 1606 445 bytes

[]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
[[]=]=]=]=]=]=]
]
[[]=]=]=]=]=]=]=]=]=]=]=]=]
]
]
]
]
]
]
]
]
]
]
]
[[]=]=]=]=]=]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
[[]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
[[]=]=]=]=]=]=]=]
]
]
]
]
]
]
]
]
]
]
]
]
]
[[]=]=]=]=]=]=]=]=]=]=]=]
]
[[]=]
]
]
]
]
]
]
]
]
[[]=]=[[[[]=]=]=]=]=]=[]
]
]
]
[[]=]=]=]=[[]=]=]=[]
]
]
]
][]=]=]=]=]=]=]=]=]=[]
]]]]]]]]]]]]]]]]]]]]]]]]]]]]
][[=

With some modifications of an idea by @dzaima, I've golfed 1161 bytes off of this. This one uses a single falling packet, incrementing each time it falls, and forks it off each time it reaches the right value to be outputted.

Old version

[]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
[[[[[[[[[[[[[[[[[[[[[[[[[[
] ] ] ] ] ]   ]
] ] ] ] ] ]   ]
] ] ] ] ] ]   ]
] ] ] ] ] ]   ]
] ] ] ] ] ]   ]
] ] ] ] ] ]   ]
] ] ] ] ] ]   ]
] ] ] ] ] ]   ]
] ] ] ] ] ]   ]
] ] ] ] ] ]   ]
] ] ] ] ] ]   ]
] ] ] ] ] ]   ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
] ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
  ] ] ] ]     ]
              [[[[[[[[[]]
  ] ] ] ]     [ ]
    ] ] ]     [ ]
    ] ] ]     [ ]
    ] ] ]     [ ]
    ] ] ]     [ ]
    ] ] ]     [ ]
    ] ] ]     [ ]
    ] ] ]     [ ]
                [[[[[[
        ]     [ ] ]
        ]     [ ] ]
        ]     [ ] ]
              [   ]
              [   ]
              [   ]
              [
              [
              ]
              ]
              ]
]]]]]]]]]]]]]]]]]]]]]]]]]]
][[=

It's a little long. I could probably steal some tricks from a BF solution, maybe.

In Plumber, the program is divided into units, each of which are 2 characters wide. Each line is padded to the length of the longest line with spaces, which can be used to shorten programs. Each ] unit is an increment operator on a falling packet of information, which is dropped by the [] at the top. Chains of [[ can be used to duplicate packets and drop them one by one in different columns.

\$\endgroup\$
4
  • 3
    \$\begingroup\$ @downvoter Please explain? I worked pretty hard to golf this down from over 2500 bytes. It's a new language, but according to the challenge spec, Unlike our usual rules, feel free to use a language (or language version) even if it's newer than this challenge. \$\endgroup\$
    – rydwolf
    Commented Dec 9, 2019 at 23:50
  • 3
    \$\begingroup\$ Wish I could vote this up a second time; sweet golf! \$\endgroup\$
    – squid
    Commented Dec 11, 2019 at 11:36
  • \$\begingroup\$ Wish I could vote this up a second time; sweet golf! \$\endgroup\$ Commented Mar 11, 2022 at 5:33
  • 1
    \$\begingroup\$ Try It Online? (Charcodes only though) \$\endgroup\$
    – emanresu A
    Commented Mar 19, 2022 at 0:52
9
\$\begingroup\$

Objective-Java*#++--.NETScriptnotation.sh, 22 bytes.

"Hello, World!".pdf.txt

Try it online!

How it works:

"Hello, World!".pdf     # Pushes "Hello, World!" to the stack.
                   .txt # Print the top item on the stack.
This is a stack-based esolang that I created that uses file extensions for commands.
\$\endgroup\$
8
\$\begingroup\$

Yorick, 21 bytes

write,"Hello, World!"

Yorick is a fast programming language for scientific number-crunching and graph-potting. It's relatively unknown and doesn't distinguish itself too much from other languages like R, but this Y-language completes the alphabet. Whoo!

\$\endgroup\$
1
  • 3
    \$\begingroup\$ +1 for completing the alphabet. Also for answering like 20 times. \$\endgroup\$ Commented Aug 28, 2015 at 19:02
8
\$\begingroup\$

05AB1E, 14 7* bytes

*14 bytes for the use of the trademarked Ÿ

Code:

”Ÿ™,‚ï!

Try it online!

Like Jelly, this uses a compression method using an English dictionary. How it works? Let's find out:

”       # Start a compressed string with all words titlecased
 Ÿ      # In Info.txt, you can see that this has index 24
  ™     # Index 19
        # These two indexes combined is 2419, in the dictionary you can see that the
          2419th word is hello
   ,    # Since this has no index, this will be interpreted as a normal character
    ‚ï  # Index 0118, which is the word "world". An extra space before this word is
        # implicitly added.
      ! # Regular exclamation mark
        # All the compressed words are automatically title cased.
          resulting in: "Hello, World!"
        

This uses CP-1252 encoding

Previous version:

"Hello, World!
\$\endgroup\$
2
  • 12
    \$\begingroup\$ Ÿ™, That's right, I just trademarked Ÿ. You cannot use it without doubling your code golf score :P \$\endgroup\$ Commented Feb 11, 2016 at 23:37
  • 3
    \$\begingroup\$ @CᴏɴᴏʀO'Bʀɪᴇɴ Hahaha, fair enough then :p \$\endgroup\$
    – Adnan
    Commented Feb 12, 2016 at 11:50
8
\$\begingroup\$

Flummery v3, 165 bytes

Flummery is a BF derivative, but not in the usual sense. It's a meta BF, if you will. There is a pointer, and there is a tape.

 [ < > + - ]
 ^

The > command moves the pointer right one, < moves the pointer left one, . is ., , is ,, and any other character is a no-op. After each character is read, the character pointed to is added to the transpiled code. (At the moment, you'll have to copy+paste the transpiled code into a BF interpreter.) Without further ado, here is the code:

>>>>;;;<<<;;>>>;;<<<;;;>><<<>>><<<>;>><>>;;;;<<>>;;<<>>;;<<>>;;<<<;;;;>>>><<<>>><<<<;;;>>>;;.;<<<;;>>;;;;;.<<;;;>>>;..;<<<;;.;;>>.<;.;;.<;;.;>>;;.<;.;;>>;.;<<<;;;;>>.

All in one textbox:

>>>>;;;<<<;;>>>;;<<<;;;>><<<>>><<<>;>><>>;;;;<<>>;;<<>>;;<<>>;;<<<;;;;>>>><<<>>><<<<;;;>>>;;.
;<<<;;>>;;;;;.<<;;;>>>;..;<<<;;.;;>>.<;.;;.<;;.;>>;;.<;.;;>>;.;<<<;;;;>>.

Or, in a readable fashion:

>>>>;;
;<<<;
;>>>;
;<<<;;
;>>
<<<
>>>
<<<
>
;>>
<
>>;;;
;<<
>>;
;<<
>>;
;<<
>>;
;<<<;;;
;>>>>
<<<
>>>
<<<<;;
;>>>;;
.
;<<<;
;>>;;;;;
.
<<;;
;>>>;
..
;<<<;;
.
;
;>>
.
<;
.
;;
.
<;;
.
;>>;;
.
<;
.
;;
>>;
.
;<<<;;;
;>>
.

Each line represents a single character added to the source code.

oh heavens what have I made

\$\endgroup\$
7
  • \$\begingroup\$ What do the ';' do? A combination of . and ,? \$\endgroup\$
    – Riker
    Commented Mar 14, 2016 at 2:35
  • \$\begingroup\$ @RikerW any non > or < character is treated as "add the currently pointed at character to the result" \$\endgroup\$ Commented Mar 14, 2016 at 2:36
  • \$\begingroup\$ Oh, okay. That makes sense. \$\endgroup\$
    – Riker
    Commented Mar 14, 2016 at 2:41
  • \$\begingroup\$ I hate you so much. So, so much. So much. \$\endgroup\$
    – anon
    Commented Apr 6, 2016 at 21:29
  • \$\begingroup\$ @QPaysTaxes Thanks mate :) \$\endgroup\$ Commented Apr 6, 2016 at 21:29
8
\$\begingroup\$

Bodyless HTTP response headers, 134 bytes

HTTP/1.1 200 OK
content-type: text/html
link: <data:text/css,body:after{content:"Hello, World!"}>; rel=stylesheet
content-length: 0

It is a valid http-response headers set. They have to be followed by 2 newlines \r\n\r\n. The response body is empty. Firefox can handle such response and shows an HTML page with Hello, World! text.

Line breaks are counted as 2 symbols, according to HTTP specification. The 2 trailing newlines are not counted as they do not belong to the headers themselves.

\$\endgroup\$
3
  • \$\begingroup\$ Does it work if you omit content-length and just close the connection? \$\endgroup\$
    – jimmy23013
    Commented Sep 4, 2015 at 8:04
  • \$\begingroup\$ @jimmy23013, I didn't check it. I expect your version to work, but it won't be a valid response as I understand. \$\endgroup\$
    – Qwertiy
    Commented Sep 4, 2015 at 10:50
  • 1
    \$\begingroup\$ Is this a programming language? No, it's not. It can't represent natrual numbers in a mathematically useful way, it cannot represent tuples, it cannot check for primes, and it cannot add two natural numbers. see eg here I'm not sure if programming language-ness actually matters for this challenge; it's just a note. \$\endgroup\$
    – cat
    Commented Jun 28, 2016 at 13:42
8
\$\begingroup\$

Monkeys, 484 460 455 448 bytes

7 RIGHT
7 RIGHT
7 RIGHT
7 RIGHT
7 UP
5 DOWN
5 RIGHT
4 DOWN
7 TEACH
7 BOND
4 UP
7 BOND
7 TEACH
7 TEACH
6 YELL
4 TEACH
4 TEACH
7 FIGHT
5 TEACH
6 YELL
7 TEACH
7 TEACH
5 FIGHT
6 YELL
6 YELL
7 TEACH
5 FIGHT
6 YELL
7 EGO
4 TEACH
5 TEACH
6 YELL
4 FIGHT
7 TEACH
6 YELL
4 TEACH
4 TEACH
4 DOWN
7 TEACH
4 UP
4 TEACH
5 FIGHT
6 YELL
4 TEACH
7 TEACH
6 YELL
7 TEACH
5 FIGHT
6 YELL
7 FIGHT
5 FIGHT
5 FIGHT
6 YELL
7 FIGHT
7 FIGHT
6 YELL
7 EGO
7 TEACH
7 TEACH
6 YELL

Try it online!

How it works

Monkeys consists internally of a 10x10 grid containing 7 monkeys (and 14 bananas we won't use). The grid initially looks as follows.

..!1.!....
.......2!.
.........!
.3.!......
.......!..
.!....!...
..5.!4....
....6...!.
......!...
.7......!.

All monkeys initially have a value of 0. Moving a monkey UP, DOWN, LEFT, or RIGHT increments its value by 1, unless the target square is adjacent (horizontally, vertically, or diagonally) to another monkey.

In addition, any monkey can modify all adjacent monkeys' values with TEACH (adding the "teacher's" value to adjacent monkeys' values), FIGHT (subtracting), BOND (multiplying), and EGO (dividing).

First,

7 RIGHT
7 RIGHT
7 RIGHT
7 RIGHT
7 UP
5 DOWN
5 RIGHT

moves monkeys 5 and 7 to their final positions. This sets 5's value to 1 and 7's value to 4. The grid now looks as follows.

..!1.!....
.......2!.
.........!
.3.!......
.......!..
.!....!...
....!4....
...56...!.
.....7!...
.!......!.

Now,

4 DOWN
7 TEACH
7 BOND
4 UP

monkey 4 moves down (and is now adjacent to 7), monkey 7 adds its value (4) to monkeys 4 and 6, monkey 7 multiplies 4's and 6's values by 4, then 4 moves back to its place. The monkeys' values are now as follows.

 5:  1
 7:  4
 4: 16

 6: 16

From now on, we'll mostly use monkeys 5, 7, and 4 to add or subtract 1, 4, or 16 to/from monkey 6's value. Making monkey 6 YELL prints its value as a character.

If we represent monkey 6's value with v, the remainder of the program looks as follows in pseudo-code.

7 BOND   v *=  4 // v ==  64
7 TEACH  v +=  4 // v ==  68
7 TEACH  v +=  4 // v ==  72 == 'H'
6 YELL   putchar(v)
4 TEACH  v += 16 // v ==  88
4 TEACH  v += 16 // v == 104
7 FIGHT  v -=  4 // v == 100
5 TEACH  v +=  1 // v == 101 == 'e'
6 YELL   putchar(v)
7 TEACH  v +=  4 // v == 105
7 TEACH  v +=  4 // v == 109
5 FIGHT  v -=  1 // v == 108 == 'l'
6 YELL   putchar(v)
6 YELL   putchar(v)
7 TEACH  v +=  4 // v == 112
5 FIGHT  v -=  1 // v == 111 == 'o'
6 YELL   putchar(v)
7 EGO    v /=  4 // v ==  27
4 TEACH  v += 16 // v ==  43
5 TEACH  v +=  1 // v ==  44 == ','
6 YELL   putchar(v)
4 FIGHT  v -= 16 // v ==  28
7 TEACH  v +=  4 // v ==  32 == ' '
6 YELL   putchar(v)
4 TEACH  v += 16 // v ==  48
4 TEACH  v += 16 // v ==  64
4 DOWN   The next operation will affect monkey 4 as well.
7 TEACH  v +=  4 // v ==  68
4 UP     Monkey 4's value changed from 16 to 20.
4 TEACH  v += 20 // v ==  88
5 FIGHT  v -=  1 // v ==  87 == 'W'
6 YELL   putchar(v)
4 TEACH  v += 20 // v == 107
7 TEACH  v +=  4 // v == 111 == 'o'
6 YELL   putchar(v)
7 TEACH  v +=  4 // v == 115
5 FIGHT  v -=  1 // v == 114 == 'r'
6 YELL   putchar(v)
7 FIGHT  v -=  4 // v == 110
5 FIGHT  v -=  1 // v == 109
5 FIGHT  v -=  1 // v == 108
6 YELL   putchar(v)
7 FIGHT  v -=  4 // v == 104
7 FIGHT  v -=  4 // v == 100 == 'd'
6 YELL   putchar(v)
7 EGO    v /=  4 // v ==  25
7 TEACH  v +=  4 // v ==  29
7 TEACH  v +=  4 // v ==  33 == '!'
6 YELL   putchar(v)
\$\endgroup\$
8
\$\begingroup\$

Fueue,  44  42 41 40 bytes

Thanks to Ørjan Johansen for saving 2 bytes.

72:108)<101[44+-6:114)32[100 33H]87]:111

Try it online!

Explanation

Fueue is, as the name suggests, a queue-based language, which is a lot more mindboggling than it sounds (although a lot of that is due to the fact that the program and the data reside in the same queue).

Here is a breakdown of the program's execution (there are no negative integer literals in Fueue, so there's no syntax for them; I'll be representing the minus sign as _ to distinguish it from the negation command -):

Cmd    Explanation               Queue
72     Print 'H'.                :108)<101[44+-6:114)32[100 33H]87]:111
:108   Duplicate 108.            )<101[44+-6:114)32[100 33H]87]:111 108 108
)      Inactive.                 <101[44+-6:114)32[100 33H]87]:111 108 108)
<      Inactive.                 101[44+-6:114)32[100 33H]87]:111 108 108)<
101    Print 'e'.                [44+-6:114)32[100 33H]87]:111 108 108)<
[...]  Inactive.                 :111 108 108)<[44+-6:114)32[100 33H]87]
:111   Duplicate 111.            108 108)<[44+-6:114)32[100 33H]87]111 111
108    Print 'l'.                108)<[44+-6:114)32[100 33H]87]111 111
108    Print 'l'.                )<[44+-6:114)32[100 33H]87]111 111
)      Inactive.                 <[44+-6:114)32[100 33H]87]111 111)
<      Append to block.          111)[44+-6:114)32[100 33H]87 111]
111    Print 'o'.                )[44+-6:114)32[100 33H]87 111]
)      Deblock.                  44+-6:114)32[100 33H]87 111
44     Print ','.                +-6:114)32[100 33H]87 111
+      Inactive.                 -6:114)32[100 33H]87 111+
-      Negate 6.                 :114)32[100 33H]87 111+_6
:      Duplicate 114.            )32[100 33H]87 111+_6 114 114
)      Inactive.                 32[100 33H]87 111+_6 114 114)
32     Print ' '.                [100 33H]87 111+_6 114 114)
[...]  Inactive.                 87 111+_6 114 114)[100 33H]
87     Print 'W'.                111+_6 114 114)[100 33H]
111    Print 'o'.                +_6 114 114)[100 33H]
+      Add -6 and 114.           114)[100 33H]108
114    Print 'r'.                )[100 33H]108
)      Deblock.                  108 100 33H
108    Print 'l'.                100 33H
100    Print 'd'.                33H
33     Print '!'.                H
H      Halt the program.

I guess the more interesting question is how on earth did we get here. I started from the basic "Hello, World!":

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

My primary goal was to get rid of the duplicate 108 for ll, since Fueue has a duplication command. So the naive thing to try is this:

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

The problem is that now the 108 doesn't get printed when its duplicated: every command in Fueue puts the result at the end of the queue. So after printing He, and duplicating the 108 we'd end up with this queue:

111 44 32 87 111 114 108 100 33H108 108

Which would just print o, World! and then halt the program, dropping the ll completely.

So we need to delay the execution of everything from 111 to H until after we had time to print the ll. To delay a piece of code by one cycle through the queue, we can wrap it in a block and "unblock" it:

72 101:108)[111 44 32 87 111 114 108 100 33H]

This works! It prints He, then duplicates the 108, then puts the entire rest of the code after the double 108 so we have this queue now:

108 108 111 44 32 87 111 114 108 100 33H

Which is exactly what we want. But we can save one more byte: since the 108 don't get printed immediately, we're free to move the 72 and 101 around in the program: they're going to be printed in the first cycle through the queue no matter what and the 108s are going to end up after them. So by moving the 101 to the end of the program, we can avoid the space between the two numbers.

At this point, we've got my initial 44-byte solution. But I wanted to get rid of the duplicate 111 as well, which seems kinda possible since one of them is now at the start of the block and we've got swap commands. So the first idea is to split up our block around the 111 and add in a duplicate and swap:

72:108~[44 32 87]:111)[114 108 100 33H]101

Of course, this doesn't quite work. There's a couple of problems here: a) we've got no deblock command for the first block. b) The swap happens on the first cycle through the queue, so it actually swaps the block with the duplication wreaking all sorts of havoc. What we really want is to duplicate the 111, then swap the block between the two numbers, but then we also want to deblock that before printing the second 111. That last part is an issue, because if we don't deblock the block the first time around, the 111 is going to printed on the second cycle (before the block can be executed), but if we do deblock it immediately, we can't swap it between the two numbers as a single unit.

The trick is to use the "append" command instead of swap. Instead of trying to get from here:

[44 32 87]111 111

to here:

111 44 32 87 111

We are going to go here instead:

111[44 32 87 111]

By appending the first copy of 111 into the block, and making use of the automatic move to the end of the queue, we hit two birds with one stone: we've moved the , W characters in between the two os and we've ensured that the second 111 can't be printed before the other characters get deblocked. So the basic idea now looks something like this:

72:108<[44 32 87]:111)[114 108 100 33H]101

There's still an issue: the < should happen on the second cycle, because we need the duplication to happen first. We could go with the )[<] technique we used for the 44-byte solution, but we can also delay it by moving the101between it and its argument (because numbers are not a valid first argument for<, the<` will be inactive on the first cyle). We also still need a deblock command for the first block:

72:108)<101[44 32 87]:111)[114 108 100 33H]

Now we're talking. On the first cycle, ) has nothing to deblock so it just moves to the end. Likewise, < has nothing to append we have time to duplicate the 111. On the second cycle, ) still has nothing to deblock, and < appends one copy of the 111 to the block, whereas the other one gets printed. On the third cycle, ) can finally deblock [44 32 87 111], so that they get printed on the fourth cycle. Woohoo, we got Hello, Wo!

But wait: what about the second block? In the current code, it gets deblocked immediately in the first cycle so it would already be executed on the second cycle, printing rld! and terminating the program way too early. The trick is to move it into the first block. That way, it can't possibly be deblocked or executed before those other characters are printed:

72:108)<101[44 32 87)[114 108 100 33H]]:111

We're at 43 bytes now, but we can save two more. This is similar to how we saved the space in the original solution: it doesn't matter where the three numbers inside the outer block appear, because they are going to be printed on the first cycle regardless of where they are. So we can move the ) and the inner block between the numbers to avoid the spaces again:

72:108)<101[44)32[114 108 100 33H]87]:111

This does in fact delay the program by one cycle (because the ) can't deblock the inner block on the first cycle of the outer block), but it doesn't affect the program's result.

The final byte is saved with a bit of arithmetic, courtesy of Ørjan Johansen, to compute the 108 from the 114. The actual code to do so is fairly simple: +-6:114. We make a copy of the 114, we negated a 6 and then add them together to get 108. Since -6 is not a negative literal, but a command applied to a 6, this computation takes two cycles. Thankfully, the : delays the 114 as well, so this just works out. We also now need to remove this from the inner block, so that we have enough time for these two cycles to go through before the d! is printed:

72:108)<101[44+-6:114)32[100 33H]87]:111
\$\endgroup\$
3
  • \$\begingroup\$ Got another byte with arithmetic: Try it online! \$\endgroup\$ Commented Mar 8, 2018 at 9:33
  • \$\begingroup\$ @ØrjanJohansen Oh wow, now it's getting crazy. :D \$\endgroup\$ Commented Mar 8, 2018 at 10:34
  • \$\begingroup\$ Very odd language.. And a good explanation of how it works, nice! \$\endgroup\$
    – cnamejj
    Commented Apr 21, 2021 at 0:02
8
\$\begingroup\$

Lua , 22 20 bytes

print"Hello, World!"

Try it online!

Thanks to @mathmandan for saving 2 bytes

\$\endgroup\$
6
  • 1
    \$\begingroup\$ I don't think you need the parentheses, so you can save two bytes: repl.it/BEPR \$\endgroup\$
    – mathmandan
    Commented Aug 28, 2015 at 15:22
  • \$\begingroup\$ How about ="Hello, World!" – because technically this does output "Hello, World!". \$\endgroup\$
    – ascx
    Commented Sep 7, 2015 at 16:26
  • 1
    \$\begingroup\$ @Socialz I just relized(thanks to you) that the = is not even necessary. \$\endgroup\$ Commented Sep 7, 2015 at 16:29
  • \$\begingroup\$ @JakeBacker I can't reproduce that though, heh, which version are you running? \$\endgroup\$
    – ascx
    Commented Sep 7, 2015 at 16:30
  • \$\begingroup\$ @Socialz repl.it/BGIS \$\endgroup\$ Commented Sep 7, 2015 at 16:31
8
\$\begingroup\$

Backhand, 15 bytes

"ol!,ld elWHro"

Now on Try It Online thanks to Dennis!

Backhand is my first new language, taking inspiration from 2D languages like Befunge and ><>. However, it is 1D, but makes up for the missing dimension by having the pointer move more than one character at a time. Initially, the program starts at location 0 with step count 3.

"  !  d  l  r       " starts a string literal and starts pushing characters to the stack
 o  ,     W  o      Change direction and go left when you reach the end
  l  l  e  H  "     Switch direction again to go right and end the string literal
           H        Halt and output stack

Of course, it looks quite funny, since the program is also an anagram of just "Hello, World!".

\$\endgroup\$
0
8
\$\begingroup\$

Symbolic Python, 175 157 147 136 bytes

_=-~(_==_)
_*=_-~_
__=_*_+~-~-_
_=('%'+`''`[~_/_])*-~-~_%(~-_*~-~-_,_*_+_/_,__,__,_*_-~_,',',' ',__-_+~_,_*_-~_,`_==_`[_/_],__,_*_)+'!'

Try it online!

I'm not sure this is optimal, but it sure was fun.

Explanation:

_=-~(_==_)           # Set _ to 2
_*=_-~_              # Set _ to 2*(2+2+1) = 10
__=_*_+~-~-_         # Set __ to 10*10+(10-1-1) = 108
_=                   # Set _ to
  ('%'+`''`[~_/_])      # %c, where c is coming from the character \x0c
  *-~-~_                # Repeated 12 times
  %(...                 # Then format into that format string
  ~-_*~-~-_,              # (10-1)*(10-1-1) = 72  = 'H'
  _*_+_/_,                # 10*10+1         = 101 = 'e'
  __,                     #                   108 = 'l'
  __,                     #                   108 = 'l'
  _*_-~_,                 # 10*10+10+1      = 111 = 'o'
  ',',                    #                         ','
  ' ',                    #                         ' '
  __-_+~_,                # 108-10-(10+1)   = 87  = 'W'
  _*_-~_,                 # 10*10+10+1      = 111 = 'o'
  `_==_`[_/_],            # second letter of True = 'r'
  __,                     #                   108 = 'l'
  _*_                     # 10*10           = 100 = 'd'
)+'!'                   # Then add the last char    '!'
                     # And implicitly print _
\$\endgroup\$
0
8
\$\begingroup\$

EBCDIC Punched Card, 13 bytes

enter image description here

Disk Operating System/360, also DOS/360, or simply DOS, is a discontinued operating system for IBM mainframes. It was announced by IBM on the last day of 1964, and it was first delivered in June 1966.In its time, DOS/360 was the most widely used operating system in the world.

A typical configuration might consist of a S/360 model 30 with 32KB memory and the decimal instruction set, an IBM 2540 card reader/card punch, an IBM 1403 printer, two or three IBM 2311 disks, two IBM 2415 magnetic tape drives, and the 1052-7 console.

\$\endgroup\$
8
\$\begingroup\$

ARM (Thumb), 29 bytes

Assembly:

.section .text
.global _main
.thumb
_main:
    mov r7, #4         // 2704   syscall #4 (write)
    mov r0, #1         // 2001   fd #1 = stdout
    add r1, pc, #8     // a102   string address = (pc+4) + 8 (msg)
    mov r2, #13        // 220d   string length = 13
    svc #0             // df00   write(1, msg, 13)

    mov r7, #1         // 2701   syscall #1 (exit)
    mov r0, #0         // 2000   exit code 0
    svc #0             // df00   exit(0)

msg: .ascii "Hello, World!" // 13 bytes, without trailing newline

How to run this on Ubuntu:

sudo apt-get install qemu-user qemu-user-static build-essential gcc-arm-linux-gnueabihf binutils-arm-linux-gnueabihf binutils-arm-linux-gnueabihf-dbg
# build and run as Thumb executable
arm-linux-gnueabihf-as main.as -o main.o
arm-linux-gnueabihf-ld --thumb-entry=_main main.o -o main
qemu-arm -L /usr/arm-linux-gnueabihf ./main
# see disassembly and calculate machine code size
arm-linux-gnueabihf-objdump -d main

Most parts of the instructions and the code structure are from this guide. A full Thumb instruction set reference can be found in this pdf, but I couldn't find any easier-to-lookup reference.

25 bytes (exits by segfault)

.section .text
.global _main
.thumb
_main:
    mov r7, #4         // 2704   syscall #4 (write)
    mov r0, #1         // 2001   fd #1 = stdout
    add r1, pc, #4     // a102   string address = (pc+4) + 4 (msg)
    mov r2, #13        // 220d   string length = 13
    svc #0             // df00   syscall
    nop                // 46c0   for 4-byte alignment of msg

msg: .ascii "Hello, World!"

While it is possible to call puts and similar by dynamically linking to libc, I don't think it's fair to discount the glue code generated by the linker (single puts call adds 36 bytes as section .plt).

\$\endgroup\$
8
\$\begingroup\$

AArch64 machine language Linux, 48 45 37 bytes

00:   d2800020        mov     x0, #0x1  ; stdout is fd=1
04:   100000a1        adr     x1, 18    ; put addr of string to x1
08:   d28001a2        mov     x2, #0xd  ; length of string
0c:   d2800808        mov     x8, #0x40 ; select write() syscall
10:   d4000001        svc     #0x0      ; syscall
14:   d65f03c0        ret
18:   6c6c6548        "Hello, World!"
1c:   57202c6f
20:   646c726f
24:   00000021

To try it out on an AArch64 Linux machine or Android device with Termux, compile and run the following C program. You may need to pass the -zexecstack argument to the compiler.

int main[]__attribute__((section(".text")))={0xd2800020,0x100000a1,0xd28001a2
,0xd2800808,0xd4000001,0xd65f03c0,'lleH','W ,o', 'dlro', '!'};
\$\endgroup\$
0
7
\$\begingroup\$

J, 15 bytes

'Hello, World!'

No call to any write function needed.

\$\endgroup\$
7
\$\begingroup\$

Pascal, 32 bytes

begin write('Hello, World!')end.
\$\endgroup\$
7
\$\begingroup\$

Trigger, 40 bytes

HHHeeelll#lllooo,,,   WWWooorrrlllddd!!!

Trigger is pattern-based, so commands are symbol independent. Three of the same character outputs that character to STDOUT.

The # is to introduce a break in the middle so that the double l doesn't turn into a six-long pattern, which will not decompose as intended. A single char is a NOT operation, but it is irrelevant for our purposes.

\$\endgroup\$
2
  • \$\begingroup\$ Can you only go 1 letter at a time? Or could you say Hello, World!Hello, World!Hello, World! which would be 1 character shorter because it doesn't need the "#"? \$\endgroup\$ Commented Sep 29, 2015 at 21:23
  • \$\begingroup\$ @AlbertRenshaw Trigger is based on patterns, and three of the same char in a row outputs. A pattern of AAB (e.g. llo) is a jump operation, and any other one-char pattern is NOT. So the example you give would be a lot of NOTs and jumps, rather than outputs. \$\endgroup\$
    – Sp3000
    Commented Sep 29, 2015 at 23:14
7
\$\begingroup\$

Deadfish~, 1 byte

w

Hooray for built-ins.

\$\endgroup\$
0
7
\$\begingroup\$

Prolog, 23 bytes

write('Hello, World!').
\$\endgroup\$
5
  • \$\begingroup\$ What did you use to define a string if you didn't use "? \$\endgroup\$
    – Beta Decay
    Commented Aug 28, 2015 at 12:57
  • 1
    \$\begingroup\$ @BetaDecay Nothing, strings didn't exist as far as I know. So using " to create strings would create an array of character codes (ie ascii/unicode codes) representing the string. Character codes strings is created with backquotes in SWI-Prolog now. \$\endgroup\$
    – Fatalize
    Commented Aug 28, 2015 at 13:01
  • \$\begingroup\$ You can use single quotes to turn this into an atom, and thus make the program completely portable: write('Hello, World!'). More declaratively, I would simply define a a fact like: msg('Hello, World!').. Usage example: ?- msg(M)., succeeding with M = 'Hello, World!'.. \$\endgroup\$
    – mat
    Commented Sep 1, 2015 at 12:18
  • \$\begingroup\$ @mat Good suggestion that I use atoms instead of strings. For the msg('Hello, World!') though, I don't think it's valid in this challenge because it outputs M = 'Hello, World!'. instead of just Hello, World! (granted, it also outputs true after in my answer but I assume this is acceptable because Prolog really likes to output true or false :)) \$\endgroup\$
    – Fatalize
    Commented Sep 1, 2015 at 12:25
  • \$\begingroup\$ I know, the way this challenge is formulated kind of forces you to use impure langauge elements. Too bad! (BTW: The last sentence of your post is no longer applicable.) \$\endgroup\$
    – mat
    Commented Sep 1, 2015 at 12:27
7
\$\begingroup\$

7, 45 bytes

(Important note: 7 is an unpublished esolang of my creation.)

4**++o/++d*no++doo:+do:/+no---*+uo+duo--o/++o

7 is a stack-based esolang of my invention. It has no built-in String or Array support, and you can't even push a specified number to the stack (with a few exceptions), so everything has to be done by hand. Here's what each operator does:

  • 4 sets variable b to 4. This can only be done at the beginning of the program. 7 is the default value, hence the name.
  • Arithmetic +-*/ works as you would expect, but operates between the top item and b. (This is changable, but this program doesn't change it.)
  • n and d increment and decrement the top item by 1, respectively.
  • : duplicates the top item.
  • o outputs the top item, while u outputs and pops the top item.

This program outputs the ASCII values of the proper characters. There are a bunch more operators which have a bunch more jobs, but I won't go into detail right now. I'm planning to publish it as soon as I have enough time.

\$\endgroup\$
0
7
\$\begingroup\$

ferNANDo, 111 109 bytes

7 7
3
5 5
6 5
4 3 3
0 5 3 0 7 3 0 0
0 5 7 0 0 5 0 4
0 6 5 2 4 6 2 3
0 6 6 0 7 7 2 3
0 6 6 2 5 4 7 4
2 2
3 5
3

The above loops three times, printing five characters each time, trailing with \r\n, which I am considering to be a single newline. The general setup I use to loop three times is the following:

7 7
3
5 5
6 5
4 3 3
1 6 6
0 0 7 7 0 0 0 0
0 0 7 7 0 0 0 1
0 0 7 7 0 0 0 2
0 0 7 7 0 0 0 3
0 0 7 7 0 0 0 4
0 0 7 7 0 0 0 5
0 0 7 7 0 0 0 6
0 0 7 7 0 0 0 7
0 0 0 0 7 0 7 0
2 2
3 5
3

producing:

00001111
00110011
01010101

which I think makes the variable names 0-7 somewhat evident. In this arrangement the value 1 is not needed, saving 6 bytes.

\$\endgroup\$
1 2 3
4
5
34

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.