404
\$\begingroup\$

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

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

The Rules

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

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

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

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

For inspiration, check the Hello World Collection.

The Catalogue

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

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

## Language Name, N bytes

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

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

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

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

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

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

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

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

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

\$\endgroup\$
  • 1
    \$\begingroup\$ Must the language meet our usual requirements for what a programming language is, or are we operating by kolmogorov complexity rules? \$\endgroup\$ – isaacg Aug 28 '15 at 13:54
  • 2
    \$\begingroup\$ @isaacg No it doesn't. I think there would be some interesting languages where it's not obvious whether primality testing is possible. \$\endgroup\$ – Martin Ender Aug 28 '15 at 13:56
  • 6
    \$\begingroup\$ If the same program, such as "Hello, World!", is the shortest in many different and unrelated languages, should it be posted separately? \$\endgroup\$ – aditsu Aug 28 '15 at 15:33
  • 2
    \$\begingroup\$ @mbomb007 Well it's hidden by default because the three code blocks take up a lot of space. I could minify them so that they are a single line each, but I'd rather keep the code maintainable in case bugs come up. \$\endgroup\$ – Martin Ender Aug 28 '15 at 19:34
  • 7
    \$\begingroup\$ @ETHproductions "Unlike our usual rules, feel free to use a language (or language version) even if it's newer than this challenge." Publishing the language and an implementation before posting it would definitely be helpful though. \$\endgroup\$ – Martin Ender Aug 29 '15 at 23:01

742 Answers 742

5
\$\begingroup\$

Sad-Flak, 199+3 bytes = 202 bytes

3 bytes for the -A arg. This lang uses a "codepage", where ≤≥ are one byte each (that is, I have a thing that replaces ` and ~ with those chars and runs it)

32
({}≤()≥)
(≤()≥)
99
({}≤()≥)
((<>[≤()≥]))
7
({}≤()≥)
((<>))≤()≥
5
({}≤()≥)
(≤()≥)
109
({}≤()≥)
(<>)(≤()≥)
85
({}≤()≥)
(≤()≥)
30
({}≤()≥)
(≤()≥)
42
({}≤()≥)
({≤()≥})(({()}))({()})(())
70
({}≤()≥)
≤≥

Try it online!

Explanation:

The main idea behind this is that the way Sad-Flak works, you can easily get it to repeat a line a constant number of times.

in Sad-Flak, there is a line pointer. The line pointer starts at the beginning

-> 32
   ({}≤()≥)
   (≤()≥)
   99
   ({}≤()≥)
   ((<>[≤()≥]))
   7
   ({}≤()≥)
   ((<>))≤()≥
   5
   ({}≤()≥)
   (≤()≥)
   109
   ({}≤()≥)
   (<>)(≤()≥)
   85
   ({}≤()≥)
   (≤()≥)
   30
   ({}≤()≥)
   (≤()≥)
   42
   ({}≤()≥)
   ({≤()≥})(({()}))({()})(())
   70
   ({}≤()≥)
   ≤≥

however, the 32 is not actually a command. it is a simple way to express 32 blank lines. I could expand them for the demonstration, but then it would be unreadable. anyway.

So, the line pointer points at the first of 32 blank lines. When the line pointer points at a non-blank line, it will execute that line. when the line pointer points at a blank line, it will execute the first non-blank line after that line. that means we execute ({}≤()≥). What does this line do? This lang is a brainflak derivative, btw, so some of the brackets do the same thing, but not all

(        push...
 {}      pop off the main stack and evaluate to that value, plus
   ≤     jump by the amount inside, evaluate to that value for the purpose of other commands
    ()   1
      ≥
       )

so, this pops off the stack, adds one to it while jumping one forward, then pushes back on the stack. What is jumping? why are we jumping in the middle of a line?

Jumping in Sad-Flak is rather different to most other langs. Jumping does not take immediate effect, but rather moves the line pointer. when the line pointer is moved, nothing happens until the current line is finished executing. when it is finished, we see which line the line pointer points at, and execute that. If the line pointer didn't get moved, the same line gets executed again, and again, until it gets moved. however, all lines in this program either are blank, or they jump or halt. So, this line moves the line pointer one forward and increments top of stack.

What is the line pointer pointing at now? it's still on a blank line, so it does the same thing again, and again, until it gets to the line that it keeps executing

   32
-> ({}≤()≥)
   (≤()≥)
   99
   ({}≤()≥)
   ((<>[≤()≥]))
   7
   ({}≤()≥)
   ((<>))≤()≥
   5
   ({}≤()≥)
   (≤()≥)
   109
   ({}≤()≥)
   (<>)(≤()≥)
   85
   ({}≤()≥)
   (≤()≥)
   30
   ({}≤()≥)
   (≤()≥)
   42
   ({}≤()≥)
   ({≤()≥})(({()}))({()})(())
   70
   ({}≤()≥)
   ≤≥

Then, it executes it one last time, before moving to the next line. this end up with the charcode of ! on the stack (32 blanks + 1 actual line)

   32
   ({}≤()≥)
-> (≤()≥)
   99
   ({}≤()≥)
   ((<>[≤()≥]))
   7
   ({}≤()≥)
   ((<>))≤()≥
   5
   ({}≤()≥)
   (≤()≥)
   109
   ({}≤()≥)
   (<>)(≤()≥)
   85
   ({}≤()≥)
   (≤()≥)
   30
   ({}≤()≥)
   (≤()≥)
   42
   ({}≤()≥)
   ({≤()≥})(({()}))({()})(())
   70
   ({}≤()≥)
   ≤≥

this line ((≤()≥)) pushes a new 1 to the stack, and moves the line pointer one forward, onto a new blank line, to do basically the same thing as it did before. however it puts charcode of e. and also the next line is this: ((<>[≤()≥])). What is this complex line? well:

((        push twice...
  <>      value popped from stack, and pushed onto the offstack for later retrieval
    [     minus ...
     ≤    (jump but eval to the argument still)
      ()  1
        ≥
         ]
          ))

so, this pops the e off the stack, and replaces it with two ds, while leaving an e on the off stack for later retrieval, and also jumping the line pointer to the next line. we have two, because one will be changed into l, because it saves bytes from pushing a 1 and incrementing it up to the next letter. we don't do this for all of them because it also cost bytes popping and pushing back onto the stack, as well as fitting the jump in there.

from now on, I'm skipping the blank lines and the increment top of stack lines, because this explanation is long enough already.

after adding 8 to yield l

((          push twice...
  <>        a value popped from stack, also pushed to offstack
    ))
      ≤     jump ...
       ()   1
         ≥

add 6 to yield r: this one again: (≤()≥) new value at 111 (o):

(           push...
 <>         popped value, also pushed to offstack.
   )
    (       push...
     ≤      (jump and eval to same as...)
      ()    1
        ≥
         )

so this pushes to the off stack while keeping it on the stack, and pushing another 1 on the stack.

new 87 (W): this again: (≤()≥)

new 32 (space): same again: (≤()≥)

new 44 (,): ({≤()≥})(({()}))({()})(()) woah, what is that? put simply, it is just pushing onto the main stack what we pushed on to the offstack, then a 1 to make into a H:

(             push...
 {            pop from the off stack, evaluate to that multiplied by...
  ≤           jump and eval to...
   ()         1
     ≥
      }
       )         this pushes o

        ((         push twice...
          {        multiply an offstack popped value by...
           ()      1
             }
              ))     this pushes l twice

                (        push...   
                 {       offstack popped value times...
                  ()     1 
                    }
                     )      this pushes e

                      (    push...
                       ()  1
                         )

new 72 (H): ≤≥: this is the halt command and it stops the program

That pushed !dlroW ,olleH char codes, which then gets printed, but backwards because it is a stack. "Hello, World!"

\$\endgroup\$
5
\$\begingroup\$

Cubically, 124 123 111 99 78 bytes

-11 bytes thanks to TehPers, -12 thanks to language updates, -21 thanks to user202729

RU+432@6+50-4@6+3-4@6@6+1-00@6-331@6-00@6+4110@6+0000@6+1-00@6-0@6-2+4@6-331@6

Generated via this amazing algorithm.

There is a good explanation of Cubically in this question.

Cubically, the Rubik's Cube Programming Language, is the most complex language I have ever written, or dealt with, for that matter. It entirely comprises of operations on a single 3x3 Rubik's Cube in its memory, and one extra value, the "notepad".

The only way to perform mathematical operations is to take values from a certain cube face and add/subtract/multiply/divide it with the scratch pad value, replacing said value.

For example, performing /0 divides the notepad value by the sum of all integers on the 0-indexed face, or the first face.

The cube starts out initialized like this:

   000
   000
   000
111222333444
111222333444
111222333444
   555
   555
   555

Performing a 90-degree clockwise turn on the right face will make the cube look like this:

   002
   002
   002
111225333044
111225333044
111225333044
   554
   554
   554

Version from TehPers:

Here's a run-down of how the program works: (Note that I have replaced @6 with @ in the code, but changing each instance in the rest of this answer would be too tedious and I need to get back to real life.)

  • +53 adds the DOWN face and RIGHT faces into the notepad, in this case, 45 and then 27. This results in 72, the ASCII code for H.
  • @6 prints the notepad value as ASCII.
  • :2 sets the notepad to the value of the FRONT face (18).
  • /1 divides the notepad by the LEFT face (9), resulting in 2.
  • +551 Adds the DOWN face (45) twice, then the LEFT face (9). As you can see, without rotating the cube, the faces will contain a total value equal to 9 times the index. For example, face index 5 has a value of 45, face index 1 has a value of 9, and so forth. After rotating the cube, this no longer applies.
  • @6 again prints the notepad value, or e.
  • :5 sets the notepad to the value of the DOWN face (45).
  • +52 adds the DOWN face (45) and the FRONT face (18) to the notepad.
  • @66 prints the current notepad value as a character twice. At this point Hell has been printed, which should be good enough for this language. :P
  • :3/1 sets the notepad to the value of the RIGHT face (27), then divides the notepad by the value of the LEFT face (9), resulting in 3. Do you see the pattern yet?
  • +552 adds 108 to the notepad, or 9*(5+5+2). Remember, if you rotate the cube, then the faces will not necessarily be multiples of 9!
  • @6 prints the notepad value as a character, finishing the word "Hello".
  • From this point there is nothing interesting. The program follows the pattern of setting the notepad value to whatever c % 9 is (where c is the target character), then adding multiples of 9 to the notepad get to the target character. The faces are not rotated, so this isn't exactly the best showcase program for Cubically, but it's certainly simpler than what could be accomplished with rotating the faces. There may be a shorter way to write this program using rotations, though.

Original (written by hand >.<)

+53@6+1F2L2+0@6L2F2U3R3F1L1+2@66L3F3R1U1B3+0@6:4U1R1+00@6-000@6+50000@6+000000@6+2-000000@6-5+4000@6-00@6/0+00@6:0+0/0+00@6

The above Hello World program uses arbitrary turns that I fiddled with until they got some desired values. Eventually, I got the top face to add up to 4 and made do with that.

Here's a run-down of how the program works:

  • +5+3 adds the DOWN face and RIGHT faces into the notepad, in this case, 45 and then 27. This results in 72, the ASCII code for H.
  • @6 prints the notepad value as ASCII.
  • +1 adds the LEFT face to the notepad value, resulting in 81.
  • F2 turns the FRONT face to look like this.
  • L2 turns the LEFT face to look like this.
  • +0 adds the UP face to the notepad, resulting in 101.
  • @6 prints memory as ASCII e.
  • L2F2U3R3F1L1 turns the cube to look like this.
  • +2 adds the FRONT face to the notepad, resulting in 108. @66 prints as ASCII twice ll. At this point Hell has been printed, which should be good enough for this language. :P
  • L3F3R1U1B3 turns the cube to look like this.
  • +0 adds the UP face to the notepad (resulting in 111), @6 prints it as ASCII o.
  • :4 sets the notepad to the BACK face 36.
  • U1R1 turns the cube to look like this. The cube is not turned again 'cause this was about as good of a setup I could get.
  • +0+0 adds the UP face to the notepad twice, resulting in 44.
  • @6 prints as ASCII ,.
  • -000 subtracts 12 from the notepad (32). @6 prints as ASCII .
  • From this point there is nothing interesting except messing with the existing faces, particularly the top face (which has a convenient value 4), to print the remaining characters.
\$\endgroup\$
  • \$\begingroup\$ It's not complex, just insanely difficult :o \$\endgroup\$ – HyperNeutrino Jun 15 '17 at 0:45
  • \$\begingroup\$ @HyperNeutrino It's rather complex. Wait for the explanation :P \$\endgroup\$ – MD XF Jun 15 '17 at 0:46
  • \$\begingroup\$ you should change the title on this \$\endgroup\$ – Destructible Lemon Jun 15 '17 at 1:32
  • \$\begingroup\$ Also that is not postfix \$\endgroup\$ – Destructible Lemon Jun 15 '17 at 1:32
  • \$\begingroup\$ @DestructibleLemon oh duh \$\endgroup\$ – MD XF Jun 15 '17 at 1:38
5
+50
\$\begingroup\$

Pain-Flak, 152 bytes

)))))}{}{)))}{))(}{((((])][][][([(])()()([((]][[()()()(])}{][][)][(][([())(]][][][][][[))(]][[)][][)][][][][))(}{}{))))(}{)}{)}{))()()()((((((((((((}><{

This is a trivial modification of @HeebyJeebyMan's “Hello, World!” in Brain-Flak. They also discovered a slightly different solution with the same length shortly before I golfed mine down to this byte count.

Try it online!

How it works

Pain-Flak is transpiled to Brain-Flak as follows.

  • Let the Pain-Flak source code be S.
  • Transliterate S, replacing all opening brackets with their closing counterparts and viceversa. Call the result T.
  • Reverse S character by character. Call the result R.
  • The Brain-Flak source code is T || R, where || symbolizes concatenation.

For the Pain-Flak program in this answer, transpilation yields the following Brain-Flak program.

((((({}{}((({}((){}))))[([][][])])[()()()]))[[]])()()()[({}[][]([])[])])(()[[][][][][]](()[[]]([][]([][][][]((){}{}((((){}({}({}(()()()())))))))))))
{<>}
{<>}
(((((((((((()()()()){}){}){}()))){}{}())[][][][])[][])[[]]())[[][][][][]]())([([]([])[][]{})]()()()([[]](([()()()]([([][][])](((({}()){}))){}{})))))

Newlines have been inserted for "readability". The programs works as follows.

  • Line 1 pushes garbage on the first stack.

  • {<>} on line 2 switches stacks until the top of the stack is non-zero.

    This switches to the second stack.

  • {<>} does the same. Since the top of the second stack is 0, we stay on the second stack.

  • Line 4 is just @HeebyJeebyMan's “Hello, World!” in Brain-Flak, which never switches stacks and is, therefore, unaffected by the garbage on the first stack.

\$\endgroup\$
  • \$\begingroup\$ You care if i use the pain-flak description for my readme? \$\endgroup\$ – Christopher Jan 21 '18 at 0:17
  • \$\begingroup\$ @Christopher2EZ4RTZ Go ahead. :) \$\endgroup\$ – Dennis Jan 21 '18 at 0:19
5
\$\begingroup\$

Brain-Flak, 144 138 bytes

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

Try it online!

The product of my code from the Text to Brain-Flak challenge. Beats the previous answer by 4 bytes! Wheat Wizard has since updated to beat mine by 2. And my code has produced a 140 byte solution (which I've golfed a further 2 bytes off).

Explanation coming as soon as I understand it myself...

How It Works:

Note that Brain-Flak is a stack based language which outputs the stack on exit. This means the text has to pushed to the stack in reverse.

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

This first part pushes "World!". This part is actually near identical to Wheat Wizard's answer, and has the same byte count.

( Pushing "W"
 ( "o"
  ( "r"
   ( "l"
    ( "d"
     ( "!"
      (((((
           (()()) Push 2
          {}) Pop the 2 to push 4
         {}) Pop the 4 to push 8
        {}) Pop the 8 to push 16
       {}()) Pop the 16 and create a 1 to push 33 ("!")
      )){}{}()) Create two copies of 33 and pop them to push 99 and a 1 to push 100 ("d")
      ([][]) Push the stack height (2) twice to the stack
     {}) Pop the 4 and push 8 + 100 = 108, ("l")
    [][] Add the stack height (3) twice to the current value
   ) Push 108 + 3*2 = 114 ("r")
  [[]]() Add negative stack height (4) and 1 to the current value
 ) Push 114 + (-4) + 1 = 111 ("o")
[ Subtract
 (
  (()[]) Push stack height (5) + 1
 {}) Pop the 6 to create 12
 {} Pop the 12 to create 24
]) Push 111 - 24 = 87 ("W")

This part pushes "ello, "

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

( "e"
 [()[]] Save negative stack height (6) and 1 for later (-7)
 ( "l"
  ( "l"
   [] Save stack height (6) for later
   ( "o"
    [] Save stack height (6) again
    (( ","
      [][] Save stack height (6) twice (12)
      ( " "
       [] Save stack height (6)
       (()[][]){} Push 1 + stack height (6)*2 = 13 and double it = 26
      ) 26 + 6 = 32 (" ")
     ) 32 + 12 = 44 (",")
    )[]{}[] Add the stack height (9), pop the 44 and add the stack height again (8)
   ) 44 + 9 + 44 + 8 + 6 (saved) = 111 ("o")
  [[]] Subtract stack height (9)
 )) Push 111 - 9 + 6 (saved) = 108 ("l") twice
) Push 107 - 7 = 100 ("e")

And finally (([][][]){}) pushes "H" by adding the stack height (12) three times and doubling it.

\$\endgroup\$
5
\$\begingroup\$

Mind, 26 bytes

The program is encoded in Shift_JIS:

メインは
"Hello, World!"
表示

It means something like:

MAIN is:
"Hello, World!"
display

As you can see, Mind is a Japanese programming language. It's based on Forth, which turns out to suit Japanese's SOV word order rather well!

\$\endgroup\$
5
\$\begingroup\$

Inform 7 + C by G, 36 bytes

Include C by G.Z:say "Hello, World!"

This code requires at least version 1/150829 of the code golfing extension.

\$\endgroup\$
  • 3
    \$\begingroup\$ I got rid of my old version. \$\endgroup\$ – Lynn Aug 29 '15 at 5:20
  • \$\begingroup\$ Please change the language name to "Inform 7 + C by G", since you're using a library \$\endgroup\$ – ASCII-only Apr 20 '18 at 1:22
  • \$\begingroup\$ @ASCII-only As the cost of the library is included I don't think that's necessary. \$\endgroup\$ – curiousdannii Apr 20 '18 at 1:34
  • \$\begingroup\$ @curiousdannii nope, it's still necessary (at least for libraries that don't come with the standard distribution) \$\endgroup\$ – ASCII-only Apr 20 '18 at 2:48
5
\$\begingroup\$

Whirl, 955 733 bytes

-~200 bytes using implicit modulo when output magic - I haven't checked anywhere close to all the simple possibilities, so this might be very suboptimal.

It might be possible to use memory/the operations wheel value as extra storage to make things shorter, but all approaches I've tried using those are not golfier than the naive one

1100001110010001111100110000000000000100000100000100000110000010000100100010001000000000000111110001111000111110001111000000000000011110000011100100011001111110001110011111000000000000000000000000000100100110000001111110001110011111000000000001001000100010000000000001111100000111110001001000110001000111110000011110000000000000000010001001100111111000100111110011000000000000000000000000010000011000000000110010001100010000000000011111000001111000000000000000000111110001111000111110001111000001001001100111111000111001111100000000000100100111001111110001111001111100000000000000000000000111100000111001000111001111110001111001111100000000000000000000000000000001111000001110010010001000000000000000000000000111110000011111000100100

Try it online!

Readable:

1 _
: ; _ + _ + _ + _ : _ + _ : _ * _ + _ : .
      + _ + _ + _ + : - _ + _ + _ + _ - _ : . _ :
      + _ + _ + _ + _ + _ + _ + _ : . _ . _ :
      + _ + _ + _ : .
      + _ + _ + _ + : + _ : .
      * _ - _ + _ + _ + _ + _ : . _
: ; _ + _ + _ + _ + _ + _ + _ : _ * _ * _ : .
      * _ * _ * _ - _ + _ + _ + _ + _ + : - _ + _ : . _ :
      + _ + _ + _ : . - :
      + _ + _ + _ + _ + _ + _ - _ : . - :
      + _ + _ + _ + _ + _ + _ + _ + _ - _ : .
      + _ + _ + _ + _ + _ + _ + : + _ : .

Every command switches operation wheels, starting from the operation wheel. Note that the cost depends on the current and previous command of the wheel, which is why there are so many no-ops.

Each character is on its own line, except for the two ls in a row. Some constructs used here are:

  • : ; - load the 1 from operation value into math value
  • _ + - add memory to math value - this can be used for e.g. repeated additions to emulate multiplications
  • _ * - square. This is used for H since 72 = 8 * 8 + 8
  • : . _ - store math value to memory, output, switch back to math wheel

Lines ending with : indicate the 1 from the operation wheel is being loaded, but the math value is not being overwritten. This is useful when consecutive characters are close in character codes.

Operation wheel commands

  • 1 - set (operation) value to 1
  • : - store value into memory. In this program it's always 1
  • . - output chr(memory)

Math wheel commands

  • + - add memory to (math) value - this is different to operation value
  • * - multiply memory with value
  • - - negate value - this is the only way to subtract
  • ; - load memory into value
  • : - store value into memory

See the language page for descriptions of unused commands

Try it online!

\$\endgroup\$
  • \$\begingroup\$ :| this is shorter than the all-caps no-punctuation one here (official website). is everyone bad at golfing or do i just have no life? also i have absolutely no clue how to contact the author \$\endgroup\$ – ASCII-only May 6 '18 at 5:08
5
\$\begingroup\$

Logo (programming language) - 20 bytes

PRINT [Hello, World!]

Or even more exciting version:

to helloworld
 hideturtle
 fd 20 left 180
 fd 40 left 180
 fd 20 right 90
 fd 20 left 90
 fd 20 left 180
 fd 40 left 90
 fd 20 left 90
 fd 20 right 90
 fd 20 right 90
 fd 10 right 90
 fd 20 left 90
 fd 10 left 90
 fd 30 left 90
 fd 40 left 180
 fd 40 left 90
 fd 20 left 90
 fd 40 left 180
 fd 40 left 90
 fd 40 left 90
 fd 20 left 90
 fd 20 left 90
 fd 20 left 90
 fd 60 left 90
 fd 40 left 180
 fd 40 left 90
 fd 20 left 90
 fd 20 left 180
 fd 20 left 90
 fd 20 left 90
 fd 40 left 180
 fd 40 left 90
 fd 40 left 90
 fd 20 left 90
 fd 20 left 90
 fd 20 left 90
 fd 40 left 90
 fd 20 right 90
 fd 20 right 90
 fd 5  left 90  
 fd 5  left 90  
 fd 25 left 180
 fd 40 left 90
 fd 40 left 90
 fd 20 left 90
 fd 20 left 90
 fd 20 left 90
 fd 20 left 90
 fd 40 left 180
 fd 40
end

lt 90 pu fd 200 pd rt 90 helloworld 

Output:

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Welcome to PPCG! This is code golf, so you should make sure that your answer is as short as possible. I don't know Logo, but it seems the HELLO is an arbitrary identifier, so you can probably shorten it and maybe it's also possible to get rid of some of that whitespace? Also, please use the required spelling Hello, World! and include the byte count of the code in your answer so that people can easily see its score. \$\endgroup\$ – Martin Ender Apr 10 '18 at 15:04
  • \$\begingroup\$ First-timer here. Cool, thanks. \$\endgroup\$ – Artur Kędzior Apr 10 '18 at 15:09
  • 2
    \$\begingroup\$ Hmm. I think you should stop drawing in between letters \$\endgroup\$ – ASCII-only May 18 '18 at 10:02
4
\$\begingroup\$

unc, 38 bytes

ZNVa[]<<chgf[L'uRYYb~ JbeYQ#']:if 5:>>
\$\endgroup\$
4
\$\begingroup\$

Scala, 22 bytes

print("Hello, World!")

scala can run "scala scripts" which are not full program. you can save the above to a file and execute in the shell scala file.scala, and it will execute (shortcut without saving a file: scala -e 'print("Hello, World!")').

a full ordinary scala program that prints hello world:

object H extends App{print("Hello, World!")}
\$\endgroup\$
4
\$\begingroup\$

Nim, 20 19 bytes

echo"Hello, World!"

Saved one byte thanks to sp3000!

\$\endgroup\$
  • \$\begingroup\$ You can drop the space in between for the first one, I think :) \$\endgroup\$ – Sp3000 Aug 28 '15 at 15:09
  • \$\begingroup\$ Indeed, saved me one byte! \$\endgroup\$ – kvill Aug 28 '15 at 15:18
4
\$\begingroup\$

Emily, 22 bytes

println"Hello, World!"

This is a nice little language I stumbled upon recently.

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

Applescript, 15 bytes

"Hello, World!"

Normally a fairly verbose language, for this one this is all that is required.

\$\endgroup\$
  • 1
    \$\begingroup\$ It's nice to see these verbose languages -- Applescript, PHP, PowerShell, etc. -- getting the better of lots of other languages for once. :) \$\endgroup\$ – AdmBorkBork Aug 28 '15 at 15:53
  • \$\begingroup\$ @TimmyD That doesn't mean that they are good languages. It's just that they are better at some things. \$\endgroup\$ – georgeunix Aug 28 '15 at 16:53
  • 1
    \$\begingroup\$ @georgeunix Oh, without a doubt. Every language has its pluses and minuses. There are plenty of things I'd change about PowerShell, but there's nothing else I'd rather use to script and config Exchange. Even if it had commands and functionality to do so, I don't think I could use Pyth or CJam or whatnot on a day-to-day basis instead. I was just meaning "It's nice to see non-golfing languages toward the top of the lowest-byte-count list for a change." \$\endgroup\$ – AdmBorkBork Aug 28 '15 at 17:06
  • \$\begingroup\$ I understand @TimmyD \$\endgroup\$ – georgeunix Aug 28 '15 at 17:07
4
\$\begingroup\$

VBScript, 28 Bytes

WScript.Echo "Hello, World!"

This (should be) the shortest that prints to STDOUT (i.e., the command prompt window), when executed via command prompt wscript .\hello-world.vbs or cscript //nologo .\hello-world.vbs (the //nologo is necessary to prevent copyright info from being displayed). If you just double-click it, you'll get a pop-up message box instead, similar to the shorter example, below, at 22 bytes:

MsgBox "Hello, World!"

When executed, this second option will output a pop-up message box displaying the text inside the quotes. Since it's not technically STDOUT, and we do have a legitimate way to display STDOUT, we'll count the longer version instead.

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

Ook!, 949 Bytes

Just translated one of the Brainfuck answers here.

Ook! Ook! Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook.
Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook?
Ook. Ook. Ook. Ook? Ook! Ook! Ook! Ook! Ook! Ook!
Ook! Ook! Ook. Ook? Ook! Ook! Ook! Ook! Ook! Ook?
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook.
Ook! Ook! Ook? Ook! Ook! Ook! Ook? Ook. Ook. Ook.
Ook? Ook! Ook. Ook? Ook. Ook? Ook! Ook! Ook! Ook!
Ook! Ook! Ook! Ook! Ook! Ook. Ook. Ook? Ook. Ook.
Ook. Ook. Ook. Ook. Ook! Ook. Ook. Ook? Ook! Ook!
Ook! Ook. Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook! Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook! Ook.
Ook? Ook. Ook! Ook. Ook? Ook. Ook! Ook. Ook? Ook.
Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook.
Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook!
Ook! Ook! Ook! Ook. Ook? Ook. Ook! Ook! Ook! Ook.
Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook! Ook.
\$\endgroup\$
  • 2
    \$\begingroup\$ I always smile when I see this language. \$\endgroup\$ – AdmBorkBork Aug 28 '15 at 16:36
  • 2
    \$\begingroup\$ This might be a case of "If your language of choice is a trivial variant of another (potentially more popular) language...". The shortest Ook! program will always be the translation of the shortest BF program (because each BF character is converted to the same length in Ook). So if Ook has a separate answer it needs to be updated every time someone finds a new shortest Brainfuck solution. (Ultimately, it's your call though if Ook should remain separate.) \$\endgroup\$ – Martin Ender Aug 28 '15 at 17:06
  • 3
    \$\begingroup\$ I love reading the "Code" in a manner as if two people were talking to each other :) \$\endgroup\$ – MrPaulch Aug 29 '15 at 11:12
  • \$\begingroup\$ @MrPaulch I agree. The fact that first O is capitalized makes it sound like a fast Oh, okay with vocalized differences for punctuation in my mind. \$\endgroup\$ – mbomb007 Sep 1 '15 at 15:04
4
\$\begingroup\$

Octave, 19 bytes

disp"Hello, World!"
\$\endgroup\$
4
\$\begingroup\$

Vim, 17 bytes

iHello, World!{ESC}ZZ

Where {ESC} is a raw escape byte \x1b.

This will switch to insert mode (i), write Hello, World!, leave it (ESC), and save+quit (ZZ). An environment like vimgolf or anarchy golf has to do the output part for you, as Vim is, of course, just a text editor.

\$\endgroup\$
  • \$\begingroup\$ @LegionMammal978 the other seems to be Vimscript mislabelled as Vim. \$\endgroup\$ – primo Feb 26 '16 at 18:33
  • 3
    \$\begingroup\$ I think generally the standard is that vim solutions don't have to save and quit, they can just display the text onscreen at the end. (That's what mine have all done). This would allow you to take 3 bytes off. \$\endgroup\$ – DJMcMayhem Jun 29 '16 at 17:33
  • \$\begingroup\$ Way longer and wrong output, but more interesting: :h_4<CR>/"H<CR>ly2wZZp \$\endgroup\$ – BlackCap Oct 12 '17 at 19:22
4
\$\begingroup\$

TI-BASIC, 22 bytes

"Hello, World!

Note that the lowercase letters are 2 bytes each.

\$\endgroup\$
  • 4
    \$\begingroup\$ I don't think the initial : is really part of the program, so I think this has a score of 22. \$\endgroup\$ – Ypnypn Aug 28 '15 at 16:06
  • \$\begingroup\$ @Ypnypn I'll take your word on it :) \$\endgroup\$ – TheNumberOne Aug 28 '15 at 18:45
4
\$\begingroup\$

PARI/GP, 22 bytes

print("Hello, World!")
\$\endgroup\$
4
\$\begingroup\$

4, 117 bytes

3.6000160103602136033260433605446067260787008070200908000120902111120111011015065095105105115055035075115125105085044

How it works

Generating characters with a code point below 100 is straightforward.

I've managed to create the others (derol) with three assignments and five additions/subtractions, which I believe is optimal.

3.            Begin the program.
  6 00 01     Set cell[ 0] to 1.
  6 01 03     Set cell[ 1] to 3.
  6 02 13     Set cell[ 2] to 13.
  6 03 32     Set cell[ 3] to 32 = ' '.
  6 04 33     Set cell[ 4] to 33 = '!'.
  6 05 44     Set cell[ 5] to 44 = ','.
  6 06 72     Set cell[ 6] to 72 = 'H'.
  6 07 87     Set cell[ 7] to 87 = 'W'.
  0 08 07 02  Set cell[ 8] to cell[ 7] + cell[2] =  87 + 13 = 100 = 'd'.
  0 09 08 00  Set cell[ 9] to cell[ 8] + cell[0] = 100 +  1 = 101 = 'e'.
  0 12 09 02  Set cell[12] to cell[ 9] + cell[2] = 101 + 13 = 114 = 'r'.
  1 11 12 01  Set cell[11] to cell[12] - cell[1] = 114 -  3 = 111 = 'o'.
  1 10 11 01  Set cell[10] to cell[11] + cell[1] = 111 -  3 = 108 = 'l'.
  5 06        Print cell[ 6] = 'H'.
  5 09        Print cell[ 9] = 'e'.
  5 10        Print cell[10] = 'l'.
  5 10        Print cell[10] = 'l'.
  5 11        Print cell[11] = 'o'.
  5 05        Print cell[ 5] = ','.
  5 03        Print cell[ 3] = ' '.
  5 07        Print cell[ 7] = 'W'.
  5 11        Print cell[11] = 'o'.
  5 12        Print cell[12] = 'r'.
  5 10        Print cell[10] = 'l'.
  5 08        Print cell[ 8] = 'd'.
  5 04        Print cell[ 4] = '!'.
4             End the program.
\$\endgroup\$
4
\$\begingroup\$

Var'aQ, 20 bytes

"Hello, World!" cha'

Var'aQ nIv rur Hol. 'oH rut lo' jIH ngaj-ghItlh.

Note: ghu'vam laH mugh jIH vaj DaneH'a'.

\$\endgroup\$
  • \$\begingroup\$ mughwI' vItu' 'oHbe' majQa'. \$\endgroup\$ – mbomb007 Sep 1 '15 at 14:48
  • \$\begingroup\$ @mbomb007 Qo', jIHvaD pIch, bing pIch \$\endgroup\$ – Beta Decay Sep 1 '15 at 14:51
  • \$\begingroup\$ What language is this? \$\endgroup\$ – LegionMammal978 Sep 28 '15 at 1:00
  • 1
    \$\begingroup\$ @LegionMammal978 Klingon :) \$\endgroup\$ – Beta Decay Sep 28 '15 at 5:52
4
\$\begingroup\$

Q, 16 bytes

1"Hello, World!"

Just Y to go and we have the alphabet :)

Bit of a late update, but thanks to Mauris, we now have at least one language for every letter of the alphabet :D

Thanks @AaronDavies

\$\endgroup\$
  • 1
    \$\begingroup\$ Not quite the requested output. I think you want 1"Hello, World!"; (doesn't include the trailing newline; to add one, change the 1 to a -1). Note, also valid for k. \$\endgroup\$ – Aaron Davies Aug 29 '15 at 23:19
4
\$\begingroup\$

123, 282 267 bytes

22221121121112112222222211211112111211211222222221121121133121121312121122222222111211213
31211213122222222111211332113312112222221112112331123322222221111211111211222221111211211
22222222112111112112112112222222111112112112112222213312112131222222221121113321133121121

The newlines are only for cosmetic purposes. I'm fairly sure that this is not optimal.

Here is a slightly more readable (and also runnable) version:

H 22221121121112112
e 2222222112111121112112112
l 22222221121121133121121312
l 12112
o 22222221112112133121121312
, 2222222111211332113312112
  2222211121123311233
W 222222211112111112112
o 222211112112112
r 2222222112111112112112112
l 222222111112112112112
d 2222133121121312
! 2222222112111332113312112
1

I started out by constructing an optimal linear code (i.e. one which doesn't use 3s which allow for loop). That is quite simple: for each character, determine which bytes to flip from the last one. Move to the right-most character that has to be flipped (with a series of 2s), then move back to the left with 1 for each byte that has to be flipped and 121 for each byte that shouldn't be flipped. Finally move to the writing index -2 and print the character with 21. Repeat. At the very end, move to index -1 with a trailing 1 in order for the program to terminate.

This jumble of 1s and 2s was generated with this CJam script, which you can run online here:

0c"Hello, World!"+2ew::^{
_{2b8Ue[1a/W<1a*_,'2*'1@W%{'1"121"?}/"12"}{;"12112"}?
}/
'1

Then I removed some repetition of ones and twos by inserting loops by hand. 3 works as follows: if the instruction pointer is to the left of index 0, skip the 3. Otherwise, jump to the previous 3 if the current bit is 1 or jump ahead to the next 3 if the bit is 0. So simple loops, repeating a code segment x can be constructed as 33x33 or 33x3 (depending on whether the termination condition is "current bit is zero" or "moved to a negative index"). Then I started enumerating some relevant simple loops and when they are applicable. I've been using these loops only when moving back through the bits to change one character code to the next. If we can use a loop here depends both on the current state of a bit a and the target state b. I'll be denoting this combined state of each position as [a b]. Now here are the relevant loops and the required position patterns in a regex-like syntax:

121:    (^|[0 0]|[0 1]) ([1 1])+ [0 0]
112:    (^|[1 1]) ([0 0])+ ([0 1]|[1 1])
211:    ([0 0]|[0 1]) ([1 1])+ [0 0] ([0 0]|[1 1])
121121: ([0 0]|[0 1]) ([1 1] ([1 1]|[0 0]))+ [0 0]

Listing out the combined states for each character, we can annotate the potential loops and how many bytes they'll save (each ___ annotates the character above; sometimes multiple loops are possible):

H [[0 0] [0 1] [0 0] [0 0] [0 1] [0 0] [0 0] [0 0]]
e [[0 0] [1 1] [0 1] [0 0] [1 0] [0 1] [0 0] [0 1]]
l [[0 0] [1 1] [1 1] [0 0] [0 1] [1 1] [0 0] [1 0]]
        __________________121 -2
  ________________________121121 -3
l [[0 0] [1 1] [1 1] [0 0] [1 1] [1 1] [0 0] [0 0]]
o [[0 0] [1 1] [1 1] [0 0] [1 1] [1 1] [0 1] [0 1]]
        __________________121 -2
              __________________211 -2
  ________________________121121 -3
, [[0 0] [1 0] [1 1] [0 0] [1 1] [1 1] [1 0] [1 0]]
        ________________________211 -2
  [[0 0] [0 0] [1 1] [0 0] [1 0] [1 0] [0 0] [0 0]]
  ____________112 -2
W [[0 0] [0 1] [1 0] [0 1] [0 0] [0 1] [0 1] [0 1]]
o [[0 0] [1 1] [0 1] [1 0] [0 1] [1 1] [1 1] [1 1]]
r [[0 0] [1 1] [1 1] [0 1] [1 0] [1 0] [1 1] [1 0]]
l [[0 0] [1 1] [1 1] [1 0] [0 1] [0 1] [1 0] [0 0]]
d [[0 0] [1 1] [1 1] [0 0] [1 0] [1 1] [0 0] [0 0]]
        __________________121 -2
  ________________________121121 -3
! [[0 0] [1 0] [1 1] [0 0] [0 0] [1 0] [0 0] [0 1]]
        ________________________211 -2

Now I just picked the most profitable loop in each case and inserted it into the code.

I'm fairly certain that one could find a couple more loops that I've overlooked. But I also think that it's possible to find a significantly shorter solution that isn't based on anything a human would come up with. So far I have no idea how to efficiently search for such a solution automatically though, so I'll leave it at that for now.

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

Piet, 132 codels

On a 4x33 grid. On the last few commands I had to stretch to reach the end, meaning it could be golfed a little more (it probably fits on a 4x31 grid). Here it is, with codel size 10:

Piet code

I made it in a rectangular space to minimize the number of time I needed to flip the pointer. The stack is based on numbers 36 and 108 that are constantly being duplicated or rolled to produce the new letters.

Made and tested on PietDev.

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

Turing Machine Code, 132 bytes

As usual, I'm using the table syntax defined here.

0 * H r q
q * e r w
w * l r e
e * l r r
r * o r t
t * , r y
y * _ r u
u * W r i
i * o r o
o * r r p
p * l r a
a * d r s
s * ! r halt

If the above link isn't working (sometimes it works for me, other times the page refuses to load) you may also test this using this java implementation.

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

Gol><>, 16 bytes

"!dlroW ,olleH"H

Try it online.

I've really enjoyed golfing in ><>, but unfortunately I've found that ><> lacks several features, e.g. STDIN integer input, which prevent it from being competitive in challenges it otherwise would be. Gol><> is designed to (hopefully) be an easier-to-use variation of ><>. I worked on it earlier in the year, around when the language showcase was happening, but took a break and only picked it up again recently. It's starting to stabilise, so I thought it'd be a good time to post a first answer.

Similarly to ><>, " is a string parsing operator which pushes chars one at a time until it reaches a closing ". H then halts the program, outputting the stack until it is empty.

Even without H, Gol><> can still output the stack in a relatively short way. l pushes the length of the stack, o outputs a char from the stack and R pops a number n, repeating the next instruction n times. Thus, an equivalent program would be

"!dlroW ,olleH"lRo;

where ; terminates the program with no output.

\$\endgroup\$
  • \$\begingroup\$ Another solution would be S"Hello, World!". \$\endgroup\$ – LegionMammal978 Nov 9 '15 at 12:39
  • \$\begingroup\$ @LegionMammal978 Indeed :) (although you'll need a ; at the end or it'll print forever) \$\endgroup\$ – Sp3000 Nov 9 '15 at 12:43
4
\$\begingroup\$

Vitsy, 18 16 bytes

"!dlroW ,olleH"Z

"!dlroW ,olleH"     Push Hello, World! to the stack.
               Z    Push the entire stack to STDOUT - equivalent to l\O

Output:

Hello, World!

Z is new syntax - it was not made for this question.

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

Purple, 62 bytes

AA1AA1AA1bA1b1Bo1bb1bbibb1Bi1b     
 ! d l r o W   , o l l e H

Purple in a Nutshell:

Purple is a self-modifying language in the same sense that self-modifying brainfuck is: The code is executed from the same array that contains data, which is infinite and otherwise initialized with zeroes. It has one instruction with three arguments: subtract the third argument from the second and store it in the first. It has two registers, a and b, which can be dereferenced as A and B to get the contents of that memory address. It also has i, the instruction pointer, o which represents the outside world (i.e., stdout in the first argument, stdin in either of the other two), and the literal 1, which cannot be the first argument.

It is as hard to read and write as it looks.

This Program:

It may seem strange that I'm entering a program that is almost more not-code than code in a contest for "shortest program", but it would be REALLY DIFFICULT to do it in less. The reason is that, when doing loops in Purple, it requires the least effort to jump to memory location 3 (because you just set i to 0), but this means you have exactly one instruction to initialize the loop. This means we need to set A to the location of the first character to be printed in a single instruction. Otherwise, we'd have to do a lot of extra work to jump somewhere else at the end of each loop. But since a starts out at zero, the only positive value we can set it to in a single instruction is 64. (i.e. the contents of the zeroth cell--the "A" itself, which is ASCII 65, minus one.)

Obviously, we're going to want to iterate backwards over the string since

  • Iterating forwards means we have to put the string AFTER position 64, thereby making the program longer.
  • It takes one fewer instruction to decrement the pointer than to increment it.

And we can shave bytes off the end of the program by decrementing the pointer before we print. In fact, we have enough space between the cell 64 and the end of the program to decrement twice between each address to be printed. Thus, the first character we need to print can be at character 62, hence, exactly 62 bytes long.

Here's The Nitty:

AA1               Set the first cell to 64
AA1AA1            This is the entry point for the loop. M[0]=M[0]-2
bA1               Point b the cell to the left of what cell 0 points to.
b1B               Set b to one more than the opposite of the character there.
o1b               Output the character M[0] pointed to (one more than the opp. of b)
b1b               Set b to the just output character.
bib               Subtract the just output character from the IP (24)
                  Until we hit the newline (ascii 10), this yields a negative.
b1B               Set b to 1 minus what b was pointing to.
                  Negative addresses are initialized to zero, so until we hit the newline
                  this will set b to 1. When we hit the newline, b will be pointing to
                  the 11th character ("1"), and this will set it to -48.
i1b               Set the instruction pointer to 1-b. 
                  Until the newline, this sets i=0, jumping back the beginning of the loop.
                  After the newline, this sets i=49, where it finds the 
                  non-instruction "W  ", and Purple halts without error in such a case.

The rest of the program is the string itself and arbitrary padding to position the characters in the right place.

EDIT: Figured out how to save 30 bytes on this program, and updated all explanations to match the new version.

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

TeaScript, 12 bytes

(using ISO/IEC 8859 character encoding)

D`HÁM, Wld!

Compresses Hello, World!, decompresses with D (æ) function

\$\endgroup\$
  • \$\begingroup\$ This is 12 bytes, I think; there should be an unprintable in Wl. \$\endgroup\$ – ETHproductions Jan 8 '16 at 2:58
  • \$\begingroup\$ @ETHproductions you're right, whoops. I guess SE kills unprintables \$\endgroup\$ – Downgoat Jan 8 '16 at 2:58
  • 2
    \$\begingroup\$ Perhaps a hexdump would be useful (via xxd or similar). \$\endgroup\$ – primo Jan 8 '16 at 4:25
4
\$\begingroup\$

BTClang, 53 bytes

My newest invention! BTClang is short for Bitcoin language. Although it has nothing to do with bitcoins, it shares some similiarities with this language. Code:

4|$&2h
2|A%
3|Im!
3|%([F
2|!4P
2|"Cv
3|zJO
1|!M
2|!&r

Explanation:

First of all, each line of the code consists of a number, a pipe and a key. The process goes as following for the example 2|5C. We take the key (5C), and generate the SHA256-hash of it. We get this:

ad5d3cc03d8b60e308b22e27fe4bbccae6a83d5496bc5e2a36aeb76eae51aeb0

The number before the pipe says how many hexadecimal number we want to extract from the end of the hash. This number is 2, so we take two 2-digit hexadecimal numbers from the end of the hash.

We are left with ae and b0. Converting these to integers will result into 174 and 176. These will be processed with the formula n % 94 + 32, so when this is converted to a character, the character will always be a printable ASCII character with 31 < ord < 128. The hashtags are replaced with newlines.

174 % 94 + 32 = 112 (p)
176 % 94 + 32 = 114 (r)

And so on...

The final translation of the code is print("Hello, World!"), which is then evaluated as normal Python. Although this is a solution, I am pretty sure this can be golfed further. It just takes a lot of computational power...

(By the way, you can try to find sets of characters yourself with the BTClang_miner)

\$\endgroup\$
  • \$\begingroup\$ How do you choose which hexadecimal numbers? \$\endgroup\$ – Conor O'Brien Apr 8 '16 at 0:32
  • 1
    \$\begingroup\$ @CᴏɴᴏʀO'Bʀɪᴇɴ You mean from the hash? The numbers chosen are all taken from the end of the hash. So from ad5d3cc03d8b60e308b22e27fe4bbccae6a83d5496bc5e2a36aeb76eae51aeb0, the last two hexadecimal numbers are ae and b0. \$\endgroup\$ – Adnan Apr 8 '16 at 14:15
  • \$\begingroup\$ Oh, I'm an idiot. :| \$\endgroup\$ – Conor O'Brien Apr 8 '16 at 14:41

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.