467
\$\begingroup\$

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

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

The Rules

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

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

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

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

For inspiration, check the Hello World Collection.

The Catalogue

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

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

## Language Name, N bytes

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

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

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

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

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

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

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

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

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

\$\endgroup\$
21
  • 3
    \$\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 quit because SE is EVIL 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
  • 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\$ – Martin Ender Aug 29 '15 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 May 20 '18 at 10:20

830 Answers 830

1
7 8
9
10 11
28
4
\$\begingroup\$

Ada, 68 bytes (-15)

Noticed there wasn't a plain Ada answer yet, only one with GNAT, so I made one:

with Text_IO;procedure H is
begin
Text_IO.Put("Hello, World!");end;

Thanks to 3D1T0R and breadbox for improving this!

Try it online!

\$\endgroup\$
5
  • \$\begingroup\$ I'm not all that familiar with Ada, but took a swing at 'golf'ing this down a bit. Please evaluate: ideone.com/JjmhIt 75 bytes. \$\endgroup\$ – 3D1T0R May 29 '18 at 19:31
  • 1
    \$\begingroup\$ Also note that the Ada. can be dropped (both places) to save 8 bytes. \$\endgroup\$ – breadbox May 29 '18 at 21:20
  • 1
    \$\begingroup\$ Wow, somebody replied to this over a year later! You can combine 3D1T0R's golf with breadbox's tip to golf it down quite a bit. \$\endgroup\$ – python-b5 May 30 '18 at 20:25
  • \$\begingroup\$ @breadbox: I could have sworn I tried that, but apparently not. I kind of doubt this can be golfed much more. \$\endgroup\$ – 3D1T0R May 31 '18 at 21:22
  • \$\begingroup\$ TIO link pls \$\endgroup\$ – ASCII-only Dec 26 '18 at 1:02
4
\$\begingroup\$

Keg, 15 8 bytes

«H%c¡|,!

Try it online!

Wow. It's been a while since I posted this. And boy oh boy how Keg has changed.

Explained

« #Start a special compressed string
H% #String compression code (SCC) for "Hello"
c¡ #SCC for "World"
|,! #Join "Hello" and "World" with a `,` and `!` to create "Hello, World!"
« #Close the special compressed string and implicitly print

Old Program

Hello\, World\!

Keg is a newly created stack-based, golfing language, which focuses on only having symbols as functions and keywords. As such, alphanumeric characters are pushed to the stack as letters (even spaces are pushed, meaning that they aren't NOPs).

Symbols that would normally be commands can be escaped using \'s.

\$\endgroup\$
4
\$\begingroup\$

Poetic, 324 bytes

the i/o case of HELLO
a good i/o drill is:say a HELLO
i said HELLO,saying it in Poetic
i code in Poetic,a good way to write a poem
a special piece for you
a special piece in machine writing for you
i already think i do pretty well writing for the machine poem
Poetic program syntax is nice
a perfect sorta poem and a program

Try it online!

This is nothing original, it's a straight port of the brilliant brainfuck answer from @KSab...but it turns out that it's the shortest representation of Hello, World! that I can find in Poetic. If anyone can golf this, please let me know; I'm definitely interested if someone can beat this solution!

\$\endgroup\$
4
\$\begingroup\$

Intcode, 201 bytes

72,4,0,-1,1101,1,100,3,4,3,1101,100,8,3,4,3,4,3,1101,100,11,3,4,3,1101,40,4,3,4,3,1101,30,2,3,4,3,1101,80,7,3,4,3,1101,100,11,3,4,3,1101,100,14,3,4,3,1101,100,8,3,4,3,1101,98,2,3,4,3,1101,30,3,3,4,3,99

And this kids is why we don't golf using languages made up for programming competitions.

\$\endgroup\$
4
  • \$\begingroup\$ mmm undefined behavior \$\endgroup\$ – Unrelated String Dec 5 '19 at 6:31
  • \$\begingroup\$ Invalid opcodes are just NOPs in my interpreter \$\endgroup\$ – lyxal Dec 5 '19 at 6:33
  • \$\begingroup\$ @UnrelatedString I mean, they haven't said what to do with undefined ops \$\endgroup\$ – lyxal Dec 5 '19 at 6:34
  • \$\begingroup\$ Outgolfed \$\endgroup\$ – pppery Dec 27 '19 at 2:19
4
\$\begingroup\$

Plain English 901 308 bytes:

To run:
Start up.
Put "Hello, World!" in a b buffer.
Call "kernel32.dll" "GetStdHandle" with -11 returning a h number.
Call "kernel32.dll" "WriteFile" with the h
and the b's first and the b's length
and a r number's whereabouts and 0 returning the r.
Call "kernel32.dll" "CloseHandle" with the h.
Shut down.

ungolfed, with comments and error traps:

To run:
  Start up.
  Put "Hello, World!" in a buffer.
  Write the buffer to stdout.
  Shut down.

To write a buffer to stdout:
  Clear the i/o error.
  Get stdout returning a standard handle.
  If the i/o error is not blank, exit.
  Call "kernel32.dll" "WriteFile" with the standard handle
    and the buffer's first and the buffer's length
    and a number's whereabouts and 0 returning the number.
  Call "kernel32.dll" "CloseHandle" with the standard handle.
  If the number is not 0, exit.
  Put "Error writing to the standard error stream." into the i/o error.

To get stdout returning a standard handle:
  \ std_input_handle = -10; std_output_handle = -11
  Call "kernel32.dll" "GetStdHandle"
    with -11 [std_output_handle]
    returning the standard handle.
  If the standard handle is -1 [invalid_handle_value],
    put "Error opening the standard output stream." into the i/o error; exit.

The Plain English IDE is available at github.com/Folds/english. The IDE runs on Windows. It compiles to 32-bit x86 code.

Write a buffer to stdout and Get stdout returning a standard handle seem like good candidates for adding to Plain English's library. Similar routines already exist for stderr.

\$\endgroup\$
5
  • \$\begingroup\$ Seems like a very interesting language, but very verbose. Wow! \$\endgroup\$ – Neil A. Jun 28 '17 at 6:35
  • \$\begingroup\$ Is there a character I am missing? It shows up as 307/899 bytes for me, respectively \$\endgroup\$ – Neil A. Jun 28 '17 at 6:37
  • \$\begingroup\$ @NeilA. - Your counts are probably correct. I estimated the byte counts by adding up the (1-based) indexes of the character positions after the last character on each line. It is likely that this process resulted in an extra character being counted after the last line. This process also assumes that the lines can be separated using one byte (such as a space or line feed) instead of the actual two-byte CRLF that is used when the editor saves the file. But since Plain English is designed to successfully compile the file if the CRLFs were replaced by spaces, the latter issue is not a problem. \$\endgroup\$ – Jasper Jun 28 '17 at 15:45
  • \$\begingroup\$ @NeilA. -- My first stab at the problem was much shorter (about 76 bytes), but it launched a complete CGI environment and output to that environment's stdout. This version outputs in the stdout that the user starts in. If I make Plain English treat stdout as nicely as it treats stderr, this version can be shortened to about 88 bytes. \$\endgroup\$ – Jasper Jun 28 '17 at 15:55
  • \$\begingroup\$ @programmer5000 -- According to the rules of this challenge, "The program must not write anything to STDERR." \$\endgroup\$ – Jasper Jul 19 '17 at 15:28
4
\$\begingroup\$

naz, 64 bytes

9a8m1o3d4m5a1o7a2o3a1o3d7a1o9s3s1o3m9s1o9a9a6a1o3a1o6s1o8s1o3d1o

naz is my new language where every command is given by a number and a letter. Programs operate on a single register whose value can be between -127 and 127, inclusive.

This program uses the instructions for add, subtract, multiply, and divide to set the register to the ASCII value of each character in the string Hello, World!, then outputs that character with the o instruction. In the case of the Ls in Hello, once the register is set to the correct value, 2o is used to output twice instead of just once.

\$\endgroup\$
1
  • 3
    \$\begingroup\$ Welcome to the site :) \$\endgroup\$ – FlipTack Jan 1 '20 at 11:57
4
\$\begingroup\$

International Phonetic Esoteric Language, 16 bytes

"Hello, World!"o
"Hello, World!"  (push "Hello, World!")
               o (pop and print)
\$\endgroup\$
4
\$\begingroup\$

No, 1185 bytes

NOOOOOOOOOOOOOOO?Noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo!Nooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo!Noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo!Noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo!Nooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo!Noooooooooooooooooooooooooooooooooooooooooooo!Noooooooooooooooooooooooooooooooo!Nooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo!Nooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo!Noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo!Noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo!Noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo!Nooooooooooooooooooooooooooooooooo
NOOOOOOOO?yes

Try it online!

No is a line based language, meaning that execution starts on the last line and the other lines are referenced throughout the program. Each line consists of the following:

  • A command, in the format of N followed by a number of Os. The number of Os determines which command is meant
  • One or more arguments, separated from the command with a ? and from each other with a !. The arguments can be one of four options:
    • N followed by \$n\$ os. This represents a character with charcode \$n\$
    • n followed by \$n\$ os. This represents an integer \$n\$
    • \$m\$ ns followed by \$n\$ .s and \$p\$ Os. This represents a floating point number with integer part \$m\$ and a fraction part consisting of \$n\$ \$0\$s followed by \$p\$. For example, nnn.O is \$3.01\$
    • ye followed by \$n\$ ss. This references the result found by running line \$n\$, 1-indexed.

This Hello, World program works by first running the last line:

NOOOOOOOO?yes

8 Os means that this is the output command, so this line outputs the value of line 1, the super long one. Line 1 works by using the „string builder“ command (NOOOOOOOOOOOOOOO or 15 Os) which takes a list of characters and returns them joined as a string. In this case, the characters form the String Hello, World! and so use the charcodes of those letters in order to return characters according to the 1st type of argument as specified above.

\$\endgroup\$
6
  • \$\begingroup\$ "Don't ask. Just read the GitHub page." I can't, it's a 404. There's not even an archive. So I ask: WHAT?!? \$\endgroup\$ – Fabian Röling Jul 14 '20 at 10:13
  • 1
    \$\begingroup\$ @FabianRöling Thanks for letting me know! This answer‘s actually out of date, so I‘ve updated it, including the link to the Github page \$\endgroup\$ – caird coinheringaahing Jul 14 '20 at 10:20
  • \$\begingroup\$ I guess I could now first learn Python, then analyse the source code of the interpreter, then based on that analyse your source code… But maybe you can explain it easier? :) \$\endgroup\$ – Fabian Röling Jul 14 '20 at 11:09
  • \$\begingroup\$ @FabianRöling Yeah sure, I‘ll edit in an explanation now \$\endgroup\$ – caird coinheringaahing Jul 14 '20 at 11:09
  • \$\begingroup\$ The program sounds like a person being outgolfed. \$\endgroup\$ – null Aug 3 '20 at 1:14
4
\$\begingroup\$

Tetr4phobi4, 454 bytes

4OUR
fuor
fuor
4OUR
4OUR
4444
FO44
4OUR
4OUR
4OUR
4OUR
4OUR
fuor
4OUR
4OUR
4OUR
4OUR
4OUR
fuor
4OUR
four
4444
fuor
4OUR
4OUR
4OUR
4OUR
4OUR
4OUR
4OUR
four
4444
4444
fuor
4OUR
4OUR
4OUR
four
4444
FO44
4OUR
4OUR
4OUR
fuor
FOU4
4444
ffff
4OUR
4OUR
fuor
4444
FO44
4OUR
4OUR
4OUR
4OUR
4OUR
fuor
4OUR
4OUR
fuor
FOU4
four
4444
4OUR
4OUR
4OUR
4OUR
4OUR
4OUR
4444
4OUR
fuor
FOU4
four
4444
FOU4
FOU4
fuor
4OUR
4OUR
four
4444
FOU4
FOU4
4444
44UR
fuor
4OUR
four
4444

Ungolfed Code:

{44} H -> 72
4OUR$$$$fuor$$$$fuor$$$$4OUR$$$$4OUR      {44} CELL[1] + 4 * 4 * 4 + 4 + 4
4444                                      {44} Print CELL[1]
FO44                                      {44} Next Cell

{44} e -> 101
4OUR$$$$4OUR$$$$4OUR$$$$4OUR$$$$4OUR      {44} CELL[2] + 4 + 4 + 4 + 4 + 4
fuor$$$$4OUR$$$$4OUR$$$$4OUR$$$$4OUR      {44} CELL[2] * 4 + 4 + 4 + 4 + 4
4OUR$$$$fuor$$$$4OUR$$$$four              {44} CELL[2] + 4 * 4 + 4 / 4
4444                                      {44} Print CELL[2]

{44} l -> 108
fuor$$$$4OUR$$$$4OUR$$$$4OUR$$$$4OUR      {44} CELL[2] * 4 + 4 + 4 + 4 + 4
4OUR$$$$4OUR$$$$4OUR$$$$four              {44} CELL[2] + 4 + 4 + 4 / 4
4444$$$$4444                              {44} Print CELL[2] twice

{44} o -> 111
fuor$$$$4OUR$$$$4OUR$$$$4OUR$$$$four      {44} CELL[2] * 4 + 4 + 4 + 4 / 4
4444                                      {44} Print CELL[2]
FO44                                      {44} Next Cell

{44} , -> 44
4OUR$$$$4OUR$$$$4OUR$$$$fuor$$$$FOU4      {44} CELL[3] + 4 + 4 + 4 * 4 - 4
4444                                      {44} Print CELL[3]

{44} Whitespace -> 32
ffff                                      {44} Reset CELL[3]
4OUR$$$$4OUR$$$$fuor                      {44} CELL[3] + 4 + 4 * 4
4444                                      {44} Print CELL[3]
FO44                                      {44} Next Cell

{44} W -> 87
4OUR$$$$4OUR$$$$4OUR$$$$4OUR$$$$4OUR      {44} CELL[4] + 4 + 4 + 4 + 4 + 4
fuor$$$$4OUR$$$$4OUR$$$$fuor$$$$FOU4      {44} CELL[4] * 4 + 4 + 4 * 4 - 4
four                                      {44} CELL[4] / 4
4444                                      {44} Print CELL[4]

{44} o -> 111
4OUR$$$$4OUR$$$$4OUR$$$$4OUR$$$$4OUR      {44} CELL[4] + 4 + 4 + 4 + 4 + 4
4OUR                                      {44} CELL[4] + 4
4444                                      {44} Print CELL[4]

{44} r -> 114
4OUR$$$$fuor$$$$FOU4$$$$four              {44} CELL[4] + 4 * 4 - 4 / 4
4444                                      {44} Print CELL[4]

{44} l -> 108
FOU4$$$$FOU4$$$$fuor$$$$4OUR$$$$4OUR      {44} CELL[4] - 4 - 4 * 4 + 4 + 4
four                                      {44} CELL[4] / 4
4444                                      {44} Print CELL[4]

{44} d -> 100
FOU4$$$$FOU4                              {44} CELL[4] - 4 - 4
4444                                      {44} Print CELL[4]
44UR                                      {44} Prev Cell

{44} ! -> 33
fuor$$$$4OUR$$$$four                      {44} CELL[3] * 4 + 4 / 4
4444                                      {44} Print CELL[3]

Try it online!

\$\endgroup\$
3
\$\begingroup\$

Wheat, 32 Bytes

Wheat is an esolang that is based on outputting and inputting. Only what has been output on a previous cycle can be input on the current one. The buffers last only one cycle; if the data of previous cycle is not read on current cycle, on the next cycle it can not be accessed, it will all be erased, replaced by the output of the current cycle (if any, otherwise the empty string is used).

output "Hello, World!"
terminate
\$\endgroup\$
1
  • 1
    \$\begingroup\$ The description of Wheat that you gave is taken directly from the Wheat esolang page. Care to cite? \$\endgroup\$ – Esolanging Fruit Jan 21 '18 at 6:41
3
\$\begingroup\$

Gibberish, 17 Bytes

Surprisingly, the shortest answer I could make is not gibberish at all.

[Hello, World!]eo
\$\endgroup\$
3
\$\begingroup\$

golflua, 16 bytes

w"Hello, World!"
\$\endgroup\$
3
\$\begingroup\$

Rust, 34 bytes

fn main(){print!("Hello, World!")}
\$\endgroup\$
3
\$\begingroup\$

CJam, 15 bytes

"Hello, World!"

Try it online

\$\endgroup\$
3
\$\begingroup\$

XSM, 28 bytes

<print>Hello, World!</print>
\$\endgroup\$
3
  • \$\begingroup\$ This is an actual XML programming language? Wow. That's... different! \$\endgroup\$ – galexite Aug 28 '15 at 17:09
  • 1
    \$\begingroup\$ Damn it, I was hoping I could write my own... Now someone's already gone and made it :P \$\endgroup\$ – Beta Decay Aug 29 '15 at 7:12
  • \$\begingroup\$ @BetaDecay There is also xplusplus.sourceforge.net and o-xml.org \$\endgroup\$ – Jerry Jeremiah Aug 30 '15 at 23:15
3
\$\begingroup\$

GolfScript, 15 bytes

"Hello, World!"
\$\endgroup\$
3
\$\begingroup\$

///, 13

Hello, World!

can't get much simpler than this

\$\endgroup\$
3
\$\begingroup\$

Underload, 16 bytes

(Hello, World!)S

Underload is the Brainfuck of stack-based languages. (x) pushes the string x to the stack, and S prints the value on top of the stack.

\$\endgroup\$
3
\$\begingroup\$

Rail, 27 bytes

$'main'
 -[Hello, World!]o#

Rail is a 2D language where the instruction pointer is a train that runs on, well, rails. Execution begins from the main function, starting from the $ and initially moving southeast.

The first command encountered is -, which makes the train turn so that it's moving eastward. Then we push a string, output with o and terminate with #.

\$\endgroup\$
3
\$\begingroup\$

bc, 16 bytes

"Hello, World!"

(bc requires a trailing newline - hence 16 instead of 15)

\$\endgroup\$
3
\$\begingroup\$

Sinclair BASIC, 16 bytes

PRINT "Hello, World!"

Note: PRINT on the Sinclair Spectrum is written with a single keystroke (p) and takes a single byte. The code above works on the "command line".

You can try it online at http://torinak.com/qaop. Keystrokes for that emulator: p shift-' shift-h e l l o , space shift-w o r l d ctrl-1 shift-'. Don't press shift-1 as that seems to delete the whole line.

Depending on your definition of a "full program", this may or may not be acceptable. Especially for bigger programs, you would need to use line numbers, type the whole program and then use the RUN command (keystroke r). In that case, prepend a 1 to the above code (for 1 extra byte).

\$\endgroup\$
0
3
\$\begingroup\$

Idris, 36 bytes

main:IO();main=putStr"Hello, World!"

Idris is sort of like Haskell, but top-level definitions need a type signature.

\$\endgroup\$
1
  • \$\begingroup\$ Also, it has dependent types and is a way better language xD \$\endgroup\$ – univalence Nov 6 '18 at 17:34
3
\$\begingroup\$

CoffeeScript, 21 bytes

alert "Hello, World!"

or console.log "Hello, World!", if that's closer to STDOUT for your tastes.

\$\endgroup\$
3
\$\begingroup\$

pb, 80 bytes

b[72]>b[101]>b[108]>b[108]>b[111]>b[44]>>b[87]>b[111]>b[114]>b[108]>b[100]>b[33]

Super naive. I tried to golf it down by keeping 108 (the character code for "l") in T, either by doing t[108] at the beginning of the program or t[B] after the first time it was printed, but each attempt ended up exactly the same length.

Note that pb doesn't require you to write b[32]. Any blank spaces on the canvas (with at least one non-blank space to the right of it) are automatically printed to the terminal as a space.

\$\endgroup\$
3
\$\begingroup\$

Fueue, 47 bytes

72 101 108 108 111 44 32 87 111 114 108 100 33H
\$\endgroup\$
3
\$\begingroup\$

99, 283 bytes

999 9 9
99 99999999 999 9
99
99 99999 9 999 9
99
99 99 999 999999
99
99
99 9999999 9999 999 9
99
99 99 9999999 9 999 9 999 9 999 9
99
99 99 999999 9 999999 9
99
9999
99 99999 999 999999 999 9
99
99 9999999 9999 9 999 9
99
99 99 999999 9
99
99 99 999999 999 9
99
99 99999 9999999 9
99

This was handcrafted so it is very likely suboptimal. Someone should write a metagolfer...

The following table has been quite useful writing 99 code by hand:

Variable  /9%128    Can print?

9              1 
99            11    !
999          111 
9999          87    !
99999        103 
999999         7    !
9999999       71 
99999999      71    !

All further rep-digits of 9 also yield 71 when taken modulo 128 (after dividing by 9).

\$\endgroup\$
2
  • \$\begingroup\$ All further rep-digits of 9 also yield 71 when taken modulo 128. you can't just drop these math facts like they're nothing.now i'm going to be amazed all day \$\endgroup\$ – undergroundmonorail Aug 30 '15 at 14:04
  • \$\begingroup\$ @undergroundmonorail Note that it's actually the rep-digits of 1 which do this, because the variable is divided by 9 before taking the modulo. And the reason this works is that (710 % 128) happens to be 70. \$\endgroup\$ – Martin Ender Aug 30 '15 at 14:09
3
\$\begingroup\$

KEMURI, 65 bytes

`^^^^"^^'"'^'"'"^^`^^'^''^"^^^^^^''^'"''"^^`^^^^^'"^^'^'^''^'^'^|

There's a KEMURI to C compiler available here if you'd like to test.

KEMURI is stack-based, and has the following 6 instructions:

~    Pop byte and push its NOT
^    Pop two bytes and push their XOR
"    Duplicate top of stack
'    Rotate top three of stack (top becomes third)
`    Push the ASCII values of "Hello, world!"
|    Output stack as ASCII

Note that ` pushes "Hello, world!" with a lowercase w. This means that the shortest "Hello, world!" program is

`|

but that doesn't mean that the best "Hello, World!" program, with an uppercase w, will be particularly short.

To aid our search for the best "Hello, World!", here are a couple of observations:

  • | empties the stack, so we will only need it exactly once, as the very last character in the program.
  • ~ is useless, since NOT will flip the most significant bit to 1, which no printable ASCII character needs.
  • We will never need to duplicate with " if the top two stack elements are the same, since:
    • Rotating three identical elements is a no-op.
    • The only way to reduce the stack size is with ^ XOR. XOR of two identical elements just introduces a 0 and XOR 0 is a no-op.
    • "Hello, World!" contains neither a triple letter nor ASCII 0.

This means that we only need to look at the four instructions ^"'`. To piece together the "Hello, World!", I looked at programs which contain a single `, at the very start. This gives a bunch of "jigsaw pieces" which we can fit together to form the whole message. There's no guarantee that this approach is optimal, but the search space is pretty big, so any better solution will probably need to be a bit more intelligent.

The pieces I managed to obtain were (<sp> is trailing space):

World!   `^^^^^"^^^|
orld!    `^^^^^^^"^^|
rld!     `^^^^^^^^"^^|
ld!      `^^^^^^^^^"^^|
d!       `"^^^^^^^^^^^^|
World!   `^^^^^"^'"'^'^|
<sp>     `^"^^^^^^^^^^^^|
!        `^^^^^^^^^^^"^^|
H        `^^^^^^^^^^'^"^^|
,        `^^^^^^^^^^''"^^^|
d        `^^^^^^^^^^''^"^^|
o        `^^^^''^"^^^^^^^^|
e        `"^^^^^^'"^^^^^^^^|
W        `^"^^^^^^'"^^^^^^^|
l        `^^"^^^^'"^^^^^^^^|
, World! `^^^^"^^'"'^'"'"^^|
ld       `^^^^^^^^^"^^''"^^|
ll       `^^"^^^^'"^^^^^^^^"|
r        `^^^^^^'"^^^^'^"^^^|
rl       `^^^^^^'"^^^^''"^^''^|
He       `^^^^^'"^^'^'^''^'^'^|
el       `^^"^^^^^^^^''"^^''"^^|
o,       `^^'^"^^^^"'^'^'^'^'^'^|
Wo       `^^^^"^^^'"^^'^''^''^''^|
,<sp>    `^^^^^'^'^'^''^''^'"'^'^|
lo       `^^^^^^^"^^'"^^''"^^''"^^|
or       `^^^^^^'^"^^''"^^''"^^''^|
llo      `^^'^''^"^^^^^^''^'"''"^^|
ell      `^^"^^^^^^^^''"^^'"''"^^''|
 W       `^"^^^^^^''^''^''^''^''^"'^|

The program at the top of the post was formed by combining the He, llo and , World! pieces.

\$\endgroup\$
3
\$\begingroup\$

Aheui, 177 bytes

밣밢따빠빠빠맣밤밢따다빠빠빠밠타맣맣맣받다맣밠밤따타맣밤밣따맣받발따다빠맣밦밤따다빠빠맣받다맣받타빠맣밣타빠맣받나맣희

Aheui is Befunge, but with Hangul. Test this here.

\$\endgroup\$
3
\$\begingroup\$

MicroSoft Windows HTA - 13 bytes

Hello, World!

MicroSoft Windows HTA occupies a niche between HTML and applications, where you get the simplicity and ease of HTML, with the direct access to the system API of applications, including file and system calls.

When I was first introduced to it, I wondered how I ever got along without it. I used it to make really easy intuitive interfaces for complex command line utilities.

Sadly, it's fallen by the wayside and you hardly hear about it anymore. One thing I remember about the official documentation was that they boasted how a bare Hello, World! is a legal hypertext application.

\$\endgroup\$
3
\$\begingroup\$

Swift, 22 Bytes

Before Version 2.0 (24 Bytes)

println("Hello, World!")

After Version 2.0 (22 Bytes)

print("Hello, World!")

Includes trailing newline

Top level code in the main file gets executed automatically. In playgrounds, anything at top level gets executed as well.

In version 2.0 beta 6 this is also possible:

print("Hello,", "World!")

which will print all the items provided, separated by a space, terminated by a newline. This is equal to the following (which is probably the longest Swift version of a non-ridiculous "Hello, World!" program):

print("Hello,", "World!", separator: " ", terminator: "\n")

Since version 2.0 beta 6, Swift is one of the few languages that can have a vararg parameter at any position (not just the end), due to named parameters.

\$\endgroup\$
0
1
7 8
9
10 11
28

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.