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 = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

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

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

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

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

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

\$\endgroup\$
21
  • 4
    \$\begingroup\$ @isaacg No it doesn't. I think there would be some interesting languages where it's not obvious whether primality testing is possible. \$\endgroup\$ 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\$
    – DELETE_ME
    Commented May 20, 2018 at 10:20

986 Answers 986

1
4 5
6
7 8
33
6
\$\begingroup\$

V, 14 bytes

iHello, World!

Try it online! This enters insert mode, then inserts Hello, World! into the field.

\$\endgroup\$
6
\$\begingroup\$

Parenthetic, 766 698 630 bytes

((()()())(()())((()())((()()())(()()()()))((()(())(())())((()(()))((()()(()))(()()())((())()()()()()()()()()()()()()))((()()(()))((())()()()()()())((())()()()()()))(()()()())))))((()(()))((()())((())()()())((())()()()))((()())((())()()()()())((())()()()()()()))((()())((())()()()()()())((())))((()())((())()()()()()())((())))((()())((())()()()()()())((())()()()))((()())((())())((())()))((()())((()))((())()()))((()())((())()()()())((())()()()()()))((()())((())()()()()()())((())()()()))((()())((())()()()()()())((())()()()()()()))((()())((())()()()()()())((())))((()())((())()()()()())((())()()()()()))((()())((()))((())()()())))

Try it online!

Still got a lot to golf. This version uses a single definition

(define f (lambda (a b) (char (+ (* a 13) 30 b))))

In other words, each char is encoded by two numbers a and b, for which 30 + 13*a + b is calculated (e.g. H = 73 = 30 + 3*13 + 3) .

\$\endgroup\$
3
  • \$\begingroup\$ nice work ... I thought it could be done better \$\endgroup\$
    – MickyT
    Commented Sep 4, 2015 at 1:01
  • \$\begingroup\$ 608 bytes using (define f (lambda (a b) (char (- (* 6 19) (* a 13) b)))) \$\endgroup\$
    – Leaky Nun
    Commented Aug 23, 2017 at 11:00
  • \$\begingroup\$ 604 bytes after golfing Leaky Nun's answer slightly \$\endgroup\$
    – Sherlock9
    Commented Aug 23, 2017 at 13:07
6
\$\begingroup\$

Casio Basic, 15 Bytes

"Hello, World!"

I think it explaines itself well enough...

\$\endgroup\$
3
  • \$\begingroup\$ Hello, and welcome to PPCG! This is a good answer; the downvote was an automatic Community downvote (AFAIK), and I cancelled it with an upvote. \$\endgroup\$ Commented May 30, 2017 at 20:16
  • \$\begingroup\$ Thanks and sorry that I messed up the formatting, I'm not really used to yet... \$\endgroup\$
    – ADDB
    Commented May 30, 2017 at 20:17
  • \$\begingroup\$ Perfectly OK! Just use four spaces before code, and a pound sign (#) or two before your header. \$\endgroup\$ Commented May 30, 2017 at 20:18
6
\$\begingroup\$

Pyramid Scheme, 857 bytes

  ^      ^      ^     ^      ^      ^      ^      ^      ^      ^      ^      ^      ^
 / \    / \    / \   / \    / \    / \    / \    / \    / \    / \    / \    / \    / \
/out\  /out\  /out\ /out\  /out\  /out\  /out\  /out\  /out\  /out\  /out\  /out\  /out\
-----^ -----^ -----^----- ^----- ^----- ^----- ^----- ^----- ^----- ^----- ^----- ^-----
    / \    / \    / \    / \    / \    / \    / \    / \    / \    / \    / \    / \
   /chr\  /chr\  /chr\  /chr\  /chr\  /chr\  /chr\  /chr\  /chr\  /chr\  /chr\  /chr\
  ^----- ^----- ^----- ^----- ^----- ^----- ^----- ^----- ^----- ^----- ^----- ^-----
 / \    / \    / \    / \    / \    / \    / \    / \    / \    / \    / \    / \
/72 \  /101\  /108\  /111\  /44 \  /32 \  /87 \  /111\  /114\  /108\  /100\  /33 \
-----  -----  -----  -----  -----  -----  -----  -----  -----  -----  -----  -----

Try it online!

Wow. At least it's kinda clear how this works...

\$\endgroup\$
6
\$\begingroup\$

Windows Portable Executable (PE), 1175 bytes

By using the following Assembly code instead of C code (which inevitable imports unecessary libraries and whatnot), we can cut down the executable size from 261591 bytes (compiled C answer) to a measily 1536 bytes.

extern ExitProcess, GetStdHandle, WriteConsoleA

section .n
    msg db "Hello, World!",10

; <entry point>
Start:
    ; GetStdHandle(in A1)
    push -11           ; A1 - STD_OUTPUT_HANDLE
    call GetStdHandle  ; Puts in eax

    ; WriteConsole(in A1, in A2, in A3, out A4, reserved A5 )
    push 0             ; A5 - Don't care (reserved argument)
                       ; A4 - Don't care ("number of chars written")
    push 14            ; A3 - Length ("number of chars to write")
    push msg           ; A2 - String (buffer pointer)
    push eax           ; A1 - Console output handle (from GetStdHandle)
    call WriteConsoleA

    ; ExitProcess(in A1)
    push 0             ; A1 - Exit code
    call ExitProcess

However, that is still way too large. So I installed HxD, a hex editor, and went on to try and remove unecessary parts.

Apparently, Windows' executables are filled with padding (hex indication) for no apparent reason. So I removed the tailing block of zeroes at the end of the file, messed around a bit, and managed to cut it down to 1175 bytes. Here's the pastebin hexdump of the executable.

Unfortunately, at my every attempt to remove the other paddings (0x1A8-0x1FF, 0x22B-0x3FF), the program would simply not run. I've been doing this for a few days to no success. Thus, I'm posting this beaten, at the still staggering 1KB of size.

I am sure this can be golfed even further, so if anyone manages to cut down the size, feel free to edit this answer or perhaps even post another one.


As a bonus, this executable also works on DOS.

\$\endgroup\$
2
  • \$\begingroup\$ If anyone wants to try golfing this down some more, they may find this answer on SO and the material it references helpful. \$\endgroup\$
    – 3D1T0R
    Commented May 29, 2018 at 19:53
  • 1
    \$\begingroup\$ github.com/pts/pts-tinype Some smaller Hello World .exes, not mine. I couldn't get the 268-byte ones to run at all, and the 402-byte one would only run with my antivirus shut off. \$\endgroup\$
    – Nnnes
    Commented Jul 23, 2018 at 11:19
6
\$\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\$
6
\$\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\$
7
  • \$\begingroup\$ It's not complex, just insanely difficult :o \$\endgroup\$
    – hyper-neutrino
    Commented Jun 15, 2017 at 0:45
  • \$\begingroup\$ @HyperNeutrino It's rather complex. Wait for the explanation :P \$\endgroup\$
    – MD XF
    Commented Jun 15, 2017 at 0:46
  • \$\begingroup\$ you should change the title on this \$\endgroup\$ Commented Jun 15, 2017 at 1:32
  • \$\begingroup\$ Also that is not postfix \$\endgroup\$ Commented Jun 15, 2017 at 1:32
  • \$\begingroup\$ @DestructibleLemon oh duh \$\endgroup\$
    – MD XF
    Commented Jun 15, 2017 at 1:38
6
\$\begingroup\$

Integral, 13 bytes

÷Hello, W╗ld!

Try it!

Sadly, Integral cannot yet compress capital letters, so it could not do much compression.

÷ means start compressed string.

Ignoring punctuation and capitalization yields

Integral, 9 bytes

÷▓llo═╗ld

Try it!

See also: Showcase

\$\endgroup\$
13
  • 1
    \$\begingroup\$ Can you put Integral on GitHub? \$\endgroup\$
    – user96495
    Commented Aug 3, 2020 at 0:38
  • \$\begingroup\$ Also, how do loops work? I tried using e but it froze the interpreter. \$\endgroup\$
    – lyxal
    Commented Aug 3, 2020 at 0:38
  • \$\begingroup\$ @Lyxal You would push the string to eval, then push the number of times to loop. Example: ⌡[Code to eval]⌡;[Encoded number of times];e \$\endgroup\$
    – nph
    Commented Aug 3, 2020 at 12:59
  • 1
    \$\begingroup\$ @petStorm GitHub repository. For some reason the code is not working. For now keep using the old interpreter. \$\endgroup\$
    – nph
    Commented Aug 3, 2020 at 13:19
  • 1
    \$\begingroup\$ Anyway, I created a GitHub pages online interpreter. \$\endgroup\$
    – user96495
    Commented Aug 3, 2020 at 13:53
6
\$\begingroup\$

Length, 1071 bytes

Somebody once told me the
world is
gonna roll m
e. I ain't the sharpest t
o
ol in the\
shed. She was lookin
kinda dumb w
ith her finger a
nd her thumb in the shape
of an L on her forehead. Well
the years\
start coming
and they don't s
top coming... fed to the\
rules a
nd I hit t
he ground ru
nning. Didnt
make sense not t
o live for fun.\
Your brain gets smart, bu
t y
our head g
ets dumb. So muc
h to do, so much to see,\
so what's w
rong with taking the back
stre
ets? You never know\
if you don't
go. You neve
r shine if you d
on't glow. Hey now, your'
e an all sta
r, get your
game on, go play
. Hey now, y
our'e a ro
ckstar, get the show on,\
g
et paid. Al
l that glitt
ers is gold. Onl
y shooting stars break th
e mould. It's a cool pla
ce and the
y say it get
s colder. You're
bundled up now, wait till
you
get older.
But the medi
a men beg to dif
fer, judging by the hole\
in the
satellite p
icture. The\
ice we skate is\
getting pretty thin. The\
water's\
getting war
m, so you might\
as well swim. My world's\
on fire, how about yours? Thats t
he way I like it

There's an interpreter, but there's no permalink

Length is a newly created esolang by esolang.org user Nailuj29, so I thought I'd give it a go and write a HW program hopefully shorter than the example one. Spoiler: this is 42 bytes shorter. The commands are decoded based on the number of characters in each line.

And yes, I did use the lyrics to All Star by Smash Mouth.

Explained

Assembly-like representation

push 8
dup
push 1
add
mul
dup
outa
push 29
add
dup
outa
push 7
add
dup
dup
outa
outa
push 3
add
outa
push 11
push 4
mul
dup
dup
outa
push 12
sub
outa
dup
add
push 1
sub
dup
outa
push 24
add
dup
outa
push 3
add
dup
outa
push 6
sub
dup
outa
push 8
sub
outa
push 33
outa

debug logs

1
push
----------
[8]
3
dup
----------
[8,8]
4
push
----------
[8,8,1]
6
add
----------
[8,9]
7
mul
----------
[72]
8
dup
----------
[72,72]
9
outa:::::::::
H----------
[72]
10
push
----------
[72,29]
12
add
----------
[101]
13
dup
----------
[101,101]
14
outa:::::::::
e----------
[101]
15
push
----------
[101,7]
17
add
----------
[108]
18
dup
----------
[108,108]
19
dup
----------
[108,108,108]
20
outa:::::::::
l----------
[108,108]
21
outa:::::::::
l----------
[108]
22
push
----------
[108,3]
24
add
----------
[111]
25
outa:::::::::
o----------
[]
26
push
----------
[11]
28
push
----------
[11,4]
30
mul
----------
[44]
31
dup
----------
[44,44]
32
dup
----------
[44,44,44]
33
outa:::::::::
,----------
[44,44]
34
push
----------
[44,44,12]
36
sub
----------
[44,32]
37
outa:::::::::
 ----------
[44]
38
dup
----------
[44,44]
39
add
----------
[88]
40
push
----------
[88,1]
42
sub
----------
[87]
43
dup
----------
[87,87]
44
outa:::::::::
W----------
[87]
45
push
----------
[87,24]
47
add
----------
[111]
48
dup
----------
[111,111]
49
outa:::::::::
o----------
[111]
50
push
----------
[111,3]
52
add
----------
[114]
53
dup
----------
[114,114]
54
outa:::::::::
r----------
[114]
55
push
----------
[114,6]
57
sub
----------
[108]
58
dup
----------
[108,108]
59
outa:::::::::
l----------
[108]
60
push
----------
[108,8]
62
sub
----------
[100]
63
outa:::::::::
d----------
[]
64
push
----------
[33]
66
outa:::::::::
!----------
[]
\$\endgroup\$
3
  • \$\begingroup\$ Any reason you used that particular song? \$\endgroup\$
    – user
    Commented Jan 13, 2021 at 0:31
  • 3
    \$\begingroup\$ @user simply because it's one of my favourite memes. All the languages requires is that the characters be present: I could have made this a boring submission with random letters. Instead, I made it somewhat entertaining. \$\endgroup\$
    – lyxal
    Commented Jan 13, 2021 at 0:33
  • 1
    \$\begingroup\$ Great job! I'm glad to see people using Length. \$\endgroup\$
    – Nailuj29
    Commented Jan 20, 2021 at 14:35
6
\$\begingroup\$

Windows Portable Executable 32 bit, 268 bytes

xxd:

00000000: 4d5a 0000 5045 0000 4c01 0100 0000 0000  MZ..PE..L.......
00000010: 0000 0000 0000 0000 7000 0301 0b01 0000  ........p.......
00000020: 0000 0000 0000 0000 0000 0000 b400 0000  ................
00000030: 0000 0000 0000 0000 0000 4000 0400 0000  ..........@.....
00000040: 0400 0000 0000 0000 0000 0000 0400 0000  ................
00000050: 0000 0000 0004 0000 0100 0000 0000 0000  ................
00000060: 0300 0000 0000 0000 0000 0000 0000 0000  ................
00000070: 0000 0000 0000 0000 0200 0000 0000 0000  ................
00000080: 0000 0000 e600 0000 0000 0000 2e74 6578  .............tex
00000090: 7400 0000 4600 0000 b400 0000 4600 0000  t...F.......F...
000000a0: b400 0000 0000 0000 0000 0000 0000 0000  ................
000000b0: 0000 0000 68c5 0040 00ff 15da 0040 00ff  ....h..@.....@..
000000c0: 15de 0040 0048 656c 6c6f 2c20 576f 726c  [email protected], Worl
000000d0: 6421 0063 7274 646c 6c00 bb01 0080 6701  d!.crtdll.....g.
000000e0: 0080 0000 0000 0000 0000 0000 0000 0000  ................
000000f0: 0000 d300 0000 da00 0000 0000 0000 0000  ................
00000100: 0000 0000 0000 0000 0000 0000            ............

source:

; nasm

BITS 32
base equ 0x400000

;
; DOS header
;
; The only two fields that matter are e_magic and e_lfanew

mzhdr:
    dw "MZ"       ; DOS e_magic
    dw 0

;
; NT headers
;

    dd "PE"       ; PE signature

;
; NT file header
;

filehdr:
    dw 0x014C            ; Machine (Intel 386)
    dw 1                 ; NumberOfSections
    dd 0                 ; TimeDateStamp UNUSED
    dd 0                 ; PointerToSymbolTable UNUSED
    dd 0                 ; NumberOfSymbols UNUSED
    dw opthdrsize        ; SizeOfOptionalHeader
    dw 0x103             ; Characteristics

;
; NT optional header
;

opthdr:
    dw 0x10B                    ; Magic (PE32)
    db 0                        ; MajorLinkerVersion UNUSED
    db 0                        ; MinorLinkerVersion UNUSED
    dd 0                        ; SizeOfCode UNUSED
    dd 0                        ; SizeOfInitializedData UNUSED
    dd 0                        ; SizeOfUninitializedData UNUSED
    dd start                    ; AddressOfEntryPoint
    dd 0                        ; BaseOfCode UNUSED
    dd 0                        ; BaseOfData UNUSED
    dd base                     ; ImageBase
    dd 4        ; DOS e_lfanew  ; SectionAlignment
    dd 4                        ; FileAlignment
    dw 0                        ; MajorOperatingSystemVersion UNUSED
    dw 0                        ; MinorOperatingSystemVersion UNUSED
    dw 0                        ; MajorImageVersion UNUSED
    dw 0                        ; MinorImageVersion UNUSED
    dw 4                        ; MajorSubsystemVersion
    dw 0                        ; MinorSubsystemVersion UNUSED
    dd 0                        ; Win32VersionValue UNUSED
    dd 1024                     ; SizeOfImage
    dd 1                        ; SizeOfHeaders          nonzero for Windows XP
    dd 0                        ; CheckSum UNUSED
    dw 3                        ; Subsystem (Console)
    dw 0                        ; DllCharacteristics UNUSED
    dd 0                        ; SizeOfStackReserve
    dd 0                        ; SizeOfStackCommit
    dd 0                        ; SizeOfHeapReserve
    dd 0                        ; SizeOfHeapCommit UNUSED
    dd 0                        ; LoaderFlags UNUSED
    dd 2                        ; NumberOfRvaAndSizes    for Windows 10; UNUSED in Windows XP

;
; Data directories (part of optional header)
;
    dd 0, 0                     ; Export Table UNUSED
    dd idata, 0                 ; Import Table

opthdrsize equ $ - opthdr

;
; Code section header
;

    db ".text", 0, 0, 0         ; Name
    dd codesize                 ; VirtualSize
    dd code                     ; VirtualAddress
    dd codesize                 ; SizeOfRawData
    dd code                     ; PointerToRawData
    dd 0                        ; PointerToRelocations UNUSED
    dd 0                        ; PointerToLinenumbers UNUSED
    dw 0                        ; NumberOfRelocations UNUSED
    dw 0                        ; NumberOfLinenumbers UNUSED
    dd 0                        ; Characteristics UNUSED

;
; Code section data
;

align 4, db 0

code:

;
; Entry point
;

start:
    push base + msg
    call [base + puts]
    call [base + exit]

msg:
    db "Hello, World!",0

crt:
    db "crtdll",0

;
; Import address table (array of IMAGE_THUNK_DATA structures)
;

iat:
puts:   dd 0x800001BB           ; Import puts by ordinal
exit:   dd 0x80000167           ; Import exit by ordinal
        dd 0                    ; terminator

;
; Import table (array of IMAGE_IMPORT_DESCRIPTOR structures)
;

idata:
    dd 0                        ; OriginalFirstThunk UNUSED
    dd 0                        ; TimeDateStamp UNUSED
    dd 0                        ; ForwarderChain UNUSED
    dd crt                      ; Name
    dd iat                      ; FirstThunk

    ; terminator
;    times 5 dd 0 ; too big, padding serves as terminator

codesize equ $ - code

;
; Padding for Windows 10
;
    times 268 - ($-$$) db 0

Previous PE answer: 1175 bytes.

This program was tested on Windows 10 2004 64-bit and Windows XP SP3.

The answer is based on this article, which creates the smallest PE file on Windows XP. I took the smallest file that works on Windows 10 from tinype.zip, which is tiny.296, and added imports using tiny.import.209. Other useful articles: one two.

Quirks:

Windows 10:

  • 268 byte size limit (link)
  • imports must be in a section (link), that's why codesize includes imports

Windows XP:

  • ignores NumberOfRvaAndSizes, it's not a problem because Debug Directory size happens to be 0 (Characteristics field of .text section header) (link)
  • SizeOfHeaders must be nonzero

I think 268 = 4 + 264, where 4 is the minimal offset of NT headers from the start of the file and 264 is the minimal distance between the start of NT headers and end of file. 264 is probably sizeof(IMAGE_NT_HEADERS32)+16 or sizeof(IMAGE_NT_HEADERS64). Because Windows 10 imposes hard limit on minimal PE size, there is no need to cram section header, code and imports into NT headers.

Of the four CRT libraries that are available on both XP and 10 (crtdll.dll, msvcrt.dll, msvcrt20.dll, msvcrt40.dll), I use crtdll.dll because it has a shorter name and has not been updated since 1995, so (it feels like) it's safe to import by ordinals from it. There is no big problem to import by names, but then those names must be inside headers, which is a bit messier.

The program sometimes hangs if puts is imported and ret is used to exit the program (this is true for both crtdll and msvcrt), so I use exit.

\$\endgroup\$
6
\$\begingroup\$

文言 / wenyan‑lang, 55 bytes

吾有一言。曰「「Hello, World!」」。書之。

Try it Online! (Online interpreter/IDE, I don't think there's a way to share code directly but just copy and paste into the editor and press Run)

For the "Hello, World!" in Classical Chinese example wenyan-lang themselves give (60 bytes):

吾有一言。曰「「問天地好在。」」。書之。
\$\endgroup\$
4
  • 2
    \$\begingroup\$ Welcome to Code Golf! Nice first answer. Looks like the link in the header might go to the wrong place. \$\endgroup\$ Commented Aug 3, 2021 at 5:02
  • 1
    \$\begingroup\$ Welcome! 吾有一言曰"Hello, World!"書之 works for 36 bytes. \$\endgroup\$
    – Dingus
    Commented Aug 3, 2021 at 6:03
  • \$\begingroup\$ @Dingus True, punctuation is indeed optional in wenyan-lang. \$\endgroup\$ Commented Aug 3, 2021 at 9:13
  • \$\begingroup\$ @RedwolfPrograms Thanks, I fixed it! \$\endgroup\$ Commented Aug 3, 2021 at 9:14
6
\$\begingroup\$

Haifuckqueue, 59 39 bytes

good job to @emanresu A for being epic gamer (shaved off a stanza)

you can only make improvements of 20 bytes at a time because of the haiku 5 7 5 rules lol

{H}$1
{lo, W}
p{l}p
{e}$7
{orld!}
$5ooo

Explanation:

{H}$1    -- overwrite top item on stack with "H" and pop that one item and print it
{lo, W}  -- overwrite top 5 with "lo, W"
p{l}p    -- push 0 to the top of the stack and overwrite it with "l" and push another 0
{e}$7    -- Overwrite the pushed zero with an "e" and print top 7 ("ello, W")
{orld!}  -- Push "orld!"
$5ooo    -- pop and print top 5 and pad with `o` command (xor top 2 items and put result in 3) for haiku 5 7 5 rules

Try it online!

\$\endgroup\$
6
  • 3
    \$\begingroup\$ You probably want to add a timeout on the server - It's currently printing millions upon millions of A to STDOUT with no sign of stopping anytime soon. \$\endgroup\$
    – emanresu A
    Commented Nov 23, 2021 at 9:41
  • \$\begingroup\$ Golfed off a stanza! \$\endgroup\$
    – emanresu A
    Commented Nov 24, 2021 at 18:59
  • \$\begingroup\$ i can't seem to reproduce the million print thing but i think i added a working timeout now of 5 seconds \$\endgroup\$
    – scpchicken
    Commented Nov 25, 2021 at 22:46
  • \$\begingroup\$ bruh hacks @emanresu \$\endgroup\$
    – scpchicken
    Commented Nov 25, 2021 at 22:47
  • \$\begingroup\$ i guess you mean if you try to use the goto line number thing it will go forever \$\endgroup\$
    – scpchicken
    Commented Nov 25, 2021 at 22:59
6
\$\begingroup\$

10IPL, 67 bytes

00010000 00100000 00100000 00100000 00010000 00100000 00100000 00100000 00110000 00010010 00100010 00100010 00010010 00100010 00010010 00100010 00100010 01000001 00010000 00110000 00010100 00100100 00100100 00100100 00010100 01000010 00110000 00110000 00010000 00010000 00010000 00110000 00110010 00010110 00100110 00100110 00100110 00100110 01100011 00100110 00110110 00010100 00010100 00010100 00100100 01010000 00110100 00110000 00010000 00010000 00010000 00110000 00010100 00010100 00010100 00010100 00010100 01010100 00110100 00011010 00101010 00101010 00101010 01010101 00110100 00010110 00110110

Try it online!

Program:

inr r0
rtr r0
rtr r0
rtr r0
inr r0
rtr r0
rtr r0
rtr r0

prt r0

inr r1
rtr r1
rtr r1
inr r1
rtr r1
inr r1
rtr r1
rtr r1
xor r0, r1
inr r0

prt r0

inr r2
rtr r2
rtr r2
rtr r2
inr r2
xor r0, r2

prt r0
prt r0

inr r0
inr r0
inr r0

prt r0

prt r1

inr r3
rtr r3
rtr r3
rtr r3
rtr r3
xor r4, r3
rtr r3

prt r3

inr r2
inr r2
inr r2
rtr r2
xor r2, r0

prt r2

prt r0

inr r0
inr r0
inr r0

prt r0

inr r2
inr r2
inr r2
inr r2
inr r2
xor r2, r4

prt r2

inr r5
rtr r5
rtr r5
rtr r5
xor r2, r5

prt r2

inr r3
prt r3

What is 10IPL?

10IPL, short for 10 Instruction Programming Language, is a simple compiled language I made for use in a computer I'm building in Minecraft. I made an online interpreter for it (with a few extra features), since I think it's a neat language.

How does this work?

This program doesn't have anything fancy, it just uses three of 10IPL's instructions (Increment, Rotate, and XOR) to put numbers in registers, then prints them.

10IPL has four general purpose registers, r0 to r3. It also has r4 (or rp0) and r5 (or rp1), which are intended to hold pointers. I use these as normal registers to save having to waste bytes clearing the ones I've already used, since this program never needs to access memory.

\$\endgroup\$
6
\$\begingroup\$

TI-BASIC, 22 bytes

"Hello, World!

Note that the lowercase letters are 2 bytes each.

\$\endgroup\$
8
  • 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
    Commented Aug 28, 2015 at 16:06
  • \$\begingroup\$ @Ypnypn I'll take your word on it :) \$\endgroup\$ Commented Aug 28, 2015 at 18:45
  • \$\begingroup\$ The colon definitely counts! It's like the C/C++ semicolon, except prefix instead of postfix. If you didn't know, you can enter multiple expressions on a single line by seperating them with a colon. Even if not that, the post asked for a full program, so it has to be there anyways. \$\endgroup\$
    – Itay123
    Commented Mar 14, 2022 at 14:51
  • \$\begingroup\$ The lowercase letters can be entered on a TI-84. \$\endgroup\$
    – Wheat Wizard
    Commented Mar 14, 2022 at 15:45
  • 1
    \$\begingroup\$ @Itay123 I rolled back your changes because they were mostly incorrect. If you look at the edit history of this question, you will see that the original included a colon. However, most of the readers from 6 years ago preferred it to not be counted. Because of that and the question's age, I would prefer to not re-introduce the colon into the answer. \$\endgroup\$ Commented Mar 15, 2022 at 16:28
6
\$\begingroup\$

C# 9+, 38 bytes

System.Console.Write("Hello, World!");

As of C# 9, the compiler directly supports top-level statements in a single file.
This means that the infamous boilerplate of class Program { static void Main(string[] args) {...} } will be inferred at compile-time, and the top-level statements in the file will be directly inserted into the Main method.

As a result of this, C# is now able to achieve a complete Hello World program in just 38 bytes!

\$\endgroup\$
6
\$\begingroup\$

Carbon, 62 bytes

package c api;fn Main()->i32{Print("Hello, World!");return 0;}

Try it Online!

Thanks to @Steffan for fixing this

Carbon is a new language by Google, supposed to be a successor to C++. Pretty boilerplatey language, even longer than Java.

\$\endgroup\$
2
  • \$\begingroup\$ This doens't work, Console.Print is invalid. You can remove import Console; and use Print instead of Console.Print. \$\endgroup\$
    – naffetS
    Commented Aug 11, 2022 at 19:00
  • \$\begingroup\$ You can test here: carbon.compiler-explorer.com \$\endgroup\$
    – naffetS
    Commented Aug 11, 2022 at 19:07
6
\$\begingroup\$

PA-RISC 1.1 machine language on HP-UX 10.20, 53 48 bytes

00:  eb 20 00 20  bl 18,r25     # load address of string to %r25
04:  34 1a 00 02  ldi 1,r26     # branch delay slot, fd=1 to %r26
08:  00 00 00 48                # "Hello, World!"
0c:  65 6c 6c 6f
10:  2c 20 57 6f
14:  72 6c 64 21
18:  34 16 00 08  ldi 4,r22     # select write() syscall
1c:  20 20 08 01  ldil -40000000,r1
20:  e4 20 e0 08  ble 4(sr7,r1) # HP-UX syscall
24:  34 18 00 1a  ldi d,r24     # branch delay slot, length of string to %r24
28:  e8 1f 1f dd  b 1c          # goto 0x1c
2c:  34 16 00 02  ldi 1,r22     # branch delay slot, select exit() syscall

(UNTESTED) For Linux, you may have to change the syscall instruction to ble 0x100(%sr2, %r0) and may be able to remove ldil -40000000,r1

To try this on a PA-RISC machine or emulator, compile and run the following C program.

int f[]={0xeb200020,0x341a0002,'H','ello',', Wo','rld!',0x34160008,
         0x20200801,0xe420e008,0x3418001a,0xe81f1fdd,0x34160002};
int main(){
  ((int(*)())f)();
}
\$\endgroup\$
6
\$\begingroup\$

CLC-INTERCAL, 221 bytes.

DO;1<-#13DO;1SUB#1<-#29DO;1SUB#2<-#1100DO;1SUB#3<-#249DO;1SUB#4<-#255DO;1SUB#5<-#250DO;1SUB#6<-#677DO;1SUB#7<-#373DO;1SUB#8<-#4160DO;1SUB#9<-#570DO;1SUB#10<-#2572DO;1SUB#11<-#225DO;1SUB#12<-#247DO;1SUB#13<-#348DOREADOUT;1

How I generated the code above:

#!/usr/bin/env perl

# Usage: perl $0 STRING
# Generates a code that stores given STRING
# to ;1 array in CLC-INTERCAL's binary IO model
# so it can be output by DOREADOUT;1, 
# without spaces.

my $line = shift;
my @values = unpack("C*", $line);
    my $ptr = 0;
    my @val = ();
    my $io = 172;
    for my $datum (@values) {
        my $chr = $datum;
        my $chr0 = $chr;
        my $bits0 = 0;
        my $bits1 = 0;
        for (my $i = 0; $i < 8; $i++) {
            if ($io & 0x80) {
                $bits0 <<= 1;
                $bits0 |= 1 if $chr & 0x80;
            } else {
                $bits1 <<= 1;
                $bits1 |= 1 if ! ($chr & 0x80);
            }
            $chr <<= 1;
            $io <<= 1;
        }
        $chr = int(rand 0xffff) + 1;
        for (my $i = 0; $i < 8; $i++) {
            $chr <<= 2;
            $chr |= 2 if $bits0 & 0x80;
            $chr |= 1 if $bits1 & 0x80;
            $bits0 <<= 1;
            $bits1 <<= 1;
        }
        $datum = $chr;
        $io = $chr0;
    }
print "DO;1<-#" . @values;
for my$i(0..$#values) {
   my $clcii = $i + 1;
   my $x = $values[$i] & 0xffff;
   print 'DO,1SUB#' . $clcii . '<-#' . $x if $x;
}

There is other "Hello, World!" program that uses a tail array, but it has 278 bytes when I do these:

  • Remove GIVE UP statement
  • Replace PLEASE with DO, as politeness doesn't matter in CLC-INTERCAL
  • Remove every space and LF.

Therefore I had to use binary I/O instead to shorten the program.

I think this is the only site that you can try CLC-INTERCAL online.

Edit. As of 1.-94.-2, politeness is not checked, unlike INTERCAL-72 and CLC-INTERCAL.

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

Forth, 17 bytes

.( Hello, World!)
\$\endgroup\$
6
  • \$\begingroup\$ ." Hello World! is one byte shorter. \$\endgroup\$
    – lynn
    Commented Aug 28, 2015 at 20:27
  • 1
    \$\begingroup\$ ." may only be used within a function declaration. ." : error(-14): use only during compilation \$\endgroup\$
    – mbomb007
    Commented Aug 28, 2015 at 20:47
  • \$\begingroup\$ Why the space in .( Hello,? \$\endgroup\$ Commented Jun 16, 2016 at 14:56
  • \$\begingroup\$ @EʀɪᴋᴛʜᴇGᴏʟғᴇʀ Forth requires spaces between tokens. The ending ) is the exception to the rule. \$\endgroup\$
    – mbomb007
    Commented Jun 16, 2016 at 14:56
  • \$\begingroup\$ @mbomb007 It's unfair that ." is only in functions. \$\endgroup\$ Commented Jun 16, 2016 at 15:03
5
\$\begingroup\$

Batch File, 19 Bytes

@echo Hello, World!

Short and to the point. You'd think you could golf off the @ at the beginning, but if you do you get the literal program echo'd out before the string is printed. This is why you'll see @echo off at the beginning of near every .bat file around.

Example without the @

C:\Tools\Scripts>.\hello-world.bat

C:\Tools\Scripts>echo Hello, World!
Hello, World!
\$\endgroup\$
8
  • \$\begingroup\$ Isn't the language itself just called "Batch"? \$\endgroup\$
    – mbomb007
    Commented Aug 28, 2015 at 13:54
  • 1
    \$\begingroup\$ @mbomb007 Kinda, sorta, maybe, not really. Batch files are just collections of lines that are executed by the associated command-line interpreter (usually COMMAND.COM but not necessarily, especially in newer Windows releases). It technically has some additional commands, like the infamous GOTO, but it's not in and of itself a language. \$\endgroup\$ Commented Aug 28, 2015 at 14:11
  • \$\begingroup\$ If you leave off the the echo you get an infinite amount of hello world!'s \$\endgroup\$ Commented Aug 28, 2015 at 14:21
  • \$\begingroup\$ @User112638726 No, you should get something like 'Hello' is not recognized as an internal or external command, operable program or batch file. If you get something else, you must be using a different version of the interpreter than I am. \$\endgroup\$ Commented Aug 28, 2015 at 14:28
  • 3
    \$\begingroup\$ @MrPaulch if the filename is significant it has to be added to the byte coutn \$\endgroup\$ Commented Aug 30, 2015 at 23:01
5
\$\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\$
5
\$\begingroup\$

Bash, 18 bytes

echo Hello, World!

This works when invoked as a full program or with history expansion disabled (default for scripts).

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

Julia, 22 bytes

print("Hello, World!")

Short and sweet.

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

D, 51 bytes

import std.stdio;void main(){puts="Hello, World!";}

In D, a=b is sometimes equivalent to a(b), allowing us to shave off one more byte than you might expect.

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

Unlambda, 36 bytes

`.!`.d`.l`.r``.W`. `.,``.l`c`.H.e.oi

Unlambda is a minimal functional programming language based on combinatory logic. It uses prefix notation; `fx is an application of f to x. Specifically, .c is a primitive that takes some v, prints the character c as a side-effect, and returns v. Thus, the usual program would be to take i, apply .H to it, apply .e to it, etc., giving you `.!`.d`.l...

This 36-byte solution is due to irori on anarchy golf. It uses the primitive c, which I think is kind of like call/cc, to avoid having to write .o and .l twice. I have no idea how it precisely works. The sort-of equivalent Lisp syntax would be:

(print-!
  (print-d
    (print-l
      (print-r
        ((print-W
           (print-space
             (print-comma
               ((print-l
                  (call-cc (print-h print-e)))
                print-o))))
         id)))))
\$\endgroup\$
0
5
\$\begingroup\$

Beatnik, 148 Bytes

It could probably be done better, but this is one of the first times I used a stack based language.

Beatnik determines commands and values based in the scrabble score for the words, but it (thankfully) doesn't check them against a dictionary.

K QQQQQQQG ZD XO K QQJA KD ZD XO K KG KD ZD ZD ZD XO XO K B KD ZD XO K QQQQF ZD ZD XO K QQQD XO K A Z KD XO ZD XO K B KD XO ZD XO K J Z XO K QQQB XO

Python interpreter can be found here

A breakdown of what I've done

K QQQQQQQG  # push 72         72
ZD          # duplicate       72 72
XO          # output H        72            
K QQJA      # push 29         29 72
KD          # add             101
ZD          # duplicate       101 101
XO          # output e        101           
K KG        # push 7          7 101
KD          # add             108
ZD          # duplicate       108 108
ZD          # duplicate       108 108 108
ZD          # duplicate       108 108 108 108
XO          # output l        108 108 108   
XO          # output l        108 108       
K B         # push 3          3 108 108
KD          # add             111 108
ZD          # duplicate       111 111 108
XO          # output o        111 108       
K QQQQF     # push 44         44 111 108    
ZD          # duplicate       44 44 111 108
ZD          # duplicate       44 44 44 111 108
XO          # output ,        44 44 111 108
K QQQD      # push 32         32 44 44 111 108    
XO          # output <space>  44 44 111 108              
K A         # push 1          1 44 44 111 108
Z           # subtract        43 44 111 108
KD          # add             87 111 108
XO          # output W        111 108    
ZD          # duplicate       111 111 108
XO          # output o        111 108       
K B         # push 3          3 111 108
KD          # add             114 108
XO          # output r        108           
ZD          # duplicate       108 108
XO          # output l        108           
K J         # push 8          8 108
Z           # subtract        100           
XO          # output d                      
K QQQB      # push 33         33
XO          # output                        
\$\endgroup\$
2
  • \$\begingroup\$ Can you add Scrabble scores to the explanation? \$\endgroup\$ Commented Jun 5, 2017 at 4:34
  • \$\begingroup\$ The version using valid scrabble words is only 100 bytes longer. \$\endgroup\$ Commented Aug 2, 2017 at 0:44
5
\$\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\$
4
  • \$\begingroup\$ mughwI' vItu' 'oHbe' majQa'. \$\endgroup\$
    – mbomb007
    Commented Sep 1, 2015 at 14:48
  • \$\begingroup\$ @mbomb007 Qo', jIHvaD pIch, bing pIch \$\endgroup\$
    – Beta Decay
    Commented Sep 1, 2015 at 14:51
  • \$\begingroup\$ What language is this? \$\endgroup\$ Commented Sep 28, 2015 at 1:00
  • 1
    \$\begingroup\$ @LegionMammal978 Klingon :) \$\endgroup\$
    – Beta Decay
    Commented Sep 28, 2015 at 5:52
5
\$\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\$
5
\$\begingroup\$

goruby, 6 bytes

h:H,:W

Apart from the method_missing override, goruby also defines Kernel#h which accepts 3 parameters: the first letter of _ello (default H), the first letter of _orld (default w), and the final character (default !).

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Nice, I didn't know about the parameters it takes :) \$\endgroup\$
    – lynn
    Commented Sep 3, 2015 at 2:00
5
\$\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\$
1
4 5
6
7 8
33

Your Answer

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

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