467
\$\begingroup\$

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

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

The Rules

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

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

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

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

For inspiration, check the Hello World Collection.

The Catalogue

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

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

## Language Name, N bytes

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

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

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

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

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

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

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

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

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

\$\endgroup\$
21
  • 3
    \$\begingroup\$ @isaacg No it doesn't. I think there would be some interesting languages where it's not obvious whether primality testing is possible. \$\endgroup\$ – Martin Ender Aug 28 '15 at 13:56
  • 6
    \$\begingroup\$ If the same program, such as "Hello, World!", is the shortest in many different and unrelated languages, should it be posted separately? \$\endgroup\$ – aditsu quit because SE is EVIL Aug 28 '15 at 15:33
  • 2
    \$\begingroup\$ @mbomb007 Well it's hidden by default because the three code blocks take up a lot of space. I could minify them so that they are a single line each, but I'd rather keep the code maintainable in case bugs come up. \$\endgroup\$ – Martin Ender Aug 28 '15 at 19:34
  • 8
    \$\begingroup\$ @ETHproductions "Unlike our usual rules, feel free to use a language (or language version) even if it's newer than this challenge." Publishing the language and an implementation before posting it would definitely be helpful though. \$\endgroup\$ – Martin Ender Aug 29 '15 at 23:01
  • 2
    \$\begingroup\$ @MartinEnder ... Almost. If two BF solutions have the same size, the one with smaller lexicographical order will take smaller number of bytes in Unary. Of course the smallest Unary solution translated to BF is guaranteed to be smallest. \$\endgroup\$ – user202729 May 20 '18 at 10:20

834 Answers 834

1
5 6
7
8 9
28
5
\$\begingroup\$

Jasmin, 251 219 165 bytes

Jasmin is an assembler for the Java Virtual Machine. It takes ASCII descriptions of Java classes, written in a simple assembler-like syntax using the Java Virtual Machine instruction set. It converts them into binary Java class files, suitable for loading by a Java runtime system.

.class H
.super sun/misc/MessageUtils
.method public static main([Ljava/lang/String;)V
ldc "Hello, World!"
invokestatic H/out(Ljava/lang/String;)V
return
.end method

Compile with java -jar jasmin.jar H.j. Execute byte code with java H.

This program is based off the "Hello, World!" program by pearce at SJSU. Golfing mainly entailed removing comments and unnecessary white space (this was true four years ago but, I have since made substantial changes). Something interesting I noted while golfing it is that a class file doesn't have to include a constructor. When a normal Java program doesn't have a constructor, a default is provided but. When there is no constructor in Jasmin, the resulting class file doesn't have one either. This would probably result in issues when trying to instantiate the class but, for the purpose of executing the main method, it works fine.


4 Years Later Golfs

  1. I found out about the static method sun.misc.MessageUtils.out from this answer. Using this instead of System.out.print saves quite a few bytes because calling instance methods is rather expensive in Jasmin.
  2. Extending sun.misc.MessageUtils saves even more bytes on that invokestatic because I can write H instead of the fully qualified class name. Omitting the .super line is not an option in Jasmin so, the other option would be extending a class with a short fully qualified name (e.g. java/io/File.

Non-competing golfs

  1. You can omit return if you invoke the class with java -noverify. This causes the JVM to segfault after printing "Hello, Word!". (-7 bytes)

  2. I think I should be able to use a static initializer instead of a main method if I execute the class file with Java6 but, I can't get this to work. It would be done by replacing the header for main with .method public static <clinit>()V.(potentially -15 bytes)

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

Cascade, 23 bytes

}ro
"""
l,H
d e
!Wl
"ol

Try it online!

This is about as compressed as it is possible to get. The } instruction is the put instruction, but it doesn't really matter what it does since we're just using it to execute the three of the instructions below it, all of which are ".

First we execute the left, which wraps around to be the rightmost column, printing Hello. Then right (which is the center column), printing , Wor. Finally directly below in the left column, we print ld!, terminating the string literal early rather than wrapping, to avoid printing the } as well.

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

Cood, 378 bytes

I want 72 of this
Im very hungry
More 29 of this
Im very hungry
More 7 of this
Im very hungry
Im very hungry
More 3 of this
Im very hungry
Less 67 of this
Im very hungry
Less 12 of this
Im very hungry
More 55 of this
Im very hungry
More 24 of this
Im very hungry
More 3 of this
Im very hungry
Less 6 of this
Im very hungry
Less 8 of this
Im very hungry
Less 67 of this
Im hungry

Try it online!

\$\endgroup\$
4
  • \$\begingroup\$ 378 bytes: Try it online! \$\endgroup\$ – the default. Apr 11 '20 at 9:47
  • \$\begingroup\$ I do not even use the TIO front page most of the time: I simply type in something like tio.run/#cood \$\endgroup\$ – the default. Apr 11 '20 at 10:47
  • \$\begingroup\$ Ahh, I see. I don't know why it doesn't appear on the front page though. \$\endgroup\$ – user92069 Apr 11 '20 at 10:48
  • \$\begingroup\$ It appears for me when I type Cood in the search bar. \$\endgroup\$ – the default. Apr 11 '20 at 10:52
5
\$\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 Aug 3 '20 at 0:38
  • \$\begingroup\$ Also, how do loops work? I tried using e but it froze the interpreter. \$\endgroup\$ – lyxal Aug 3 '20 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 Aug 3 '20 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 Aug 3 '20 at 13:19
  • 1
    \$\begingroup\$ Anyway, I created a GitHub pages online interpreter. \$\endgroup\$ – user96495 Aug 3 '20 at 13:53
5
\$\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 Jan 13 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 Jan 13 at 0:33
  • 1
    \$\begingroup\$ Great job! I'm glad to see people using Length. \$\endgroup\$ – Nailuj29 Jan 20 at 14:35
4
\$\begingroup\$

unc, 38 bytes

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

LOLCODE, 22 bytes

VISIBLE"Hello, World!"

Works in interpreters that don't require the presence of HAI and KTHXBYE.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Agh! Posted a minute before me :P \$\endgroup\$ – Kade Aug 28 '15 at 13:57
  • \$\begingroup\$ @Shebang Gotta go fast! \$\endgroup\$ – Fatalize Aug 28 '15 at 13:57
  • \$\begingroup\$ damn I'm a few days to late :( \$\endgroup\$ – Alex Carlsen Sep 1 '15 at 11:54
  • 2
    \$\begingroup\$ And I pronounce this code, Ungolfable! \$\endgroup\$ – Erik the Outgolfer Jun 4 '16 at 13:01
4
\$\begingroup\$

Nim, 20 19 bytes

echo"Hello, World!"

Saved one byte thanks to sp3000!

\$\endgroup\$
2
  • \$\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\$

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\$
4
  • 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\$
3
  • \$\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\$ – James 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\$
2
  • 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\$

3var, 65 bytes

iiisa-<*>P/>is+iP>PPm-iiiPi<O/<m/>+<O+d<+<O+><kkkOP->siskkkOP</>P

Here's a 3var program found by brute force. Note that this might not be optimal since I assume that we'll only ever need numbers in the range 0-150, for efficiency reasons. I'll probably address this in a later edit.

3var is a Deadfish variant which has, well, three variables A, B and R. The relevant commands are:

Command              A           B           other
-----------------------------------------------------------
Increment            i           a
Decrement            d           k
Square               s           m
Output as char       P           O
Copy from R          >           <
Set R = A+B                                  +
Set R = A-B                                  -
Set R = A*B                                  *
Set R = A div B                              /

And here's a trace:

Line           A     B     R     Output
----------------------------------------------------------------
iiisa-         9     1     8
<*             9     8     72
>P             72    8     72    H
/>             9     8     72    H
is+            100   8     108   H
iP             101   8     108   He
>PP            108   8     108   Hell
m-             108   64    44    Hell
iiiP           111   64    44    Hello
i<O            112   44    44    Hello,
/<m            112   4     2     Hello,
/>             28    4     28    Hello,
+<O            28    32    32    Hello, 
+d<            27    60    60    Hello, 
+<O            27    87    87    Hello, W
+><            114   114   114   Hello, W
kkkOP          114   111   114   Hello, Wor
->             3     111   3     Hello, Wor
siskkkOP       100   108   3     Hello, World
</             100   3     33    Hello, World
>P             33    3     33    Hello, World!
\$\endgroup\$
1
  • \$\begingroup\$ @LegionMammal978 Do you mean esolang wiki? The site seems fine to me... \$\endgroup\$ – Sp3000 Sep 28 '15 at 2:39
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\$
4
  • \$\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
  • 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\$

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\$

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\$
2
  • \$\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\$
3
  • \$\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\$
3
  • \$\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
4
\$\begingroup\$

Scratch, 15 bytes

Script
(scoring used)
Makes the sprite say "Hello, World!" Can't get much simpler than that.

\$\endgroup\$
4
  • \$\begingroup\$ You already welcomed me in Output the Current Time \$\endgroup\$ – weatherman115 May 20 '16 at 15:25
  • \$\begingroup\$ Sorry, the review link said you were new. \$\endgroup\$ – NoOneIsHere May 20 '16 at 15:35
  • \$\begingroup\$ Is this different from codegolf.stackexchange.com/a/76182/6691 ? \$\endgroup\$ – b_jonas Apr 17 '17 at 13:31
  • \$\begingroup\$ Well, this is awkward. \$\endgroup\$ – weatherman115 Apr 17 '17 at 18:06
4
\$\begingroup\$

Go, 64 61 bytes

3 bytes thanks to George Gibson

package main
import."fmt"
func main(){Print("Hello, World!")}

Go requires an import to print to standard output, unfortunately. No trailing newline.

\$\endgroup\$
5
  • \$\begingroup\$ package main;fund main(){print("Hello, world!")} \$\endgroup\$ – Eric Lagergren Sep 6 '15 at 16:53
  • 1
    \$\begingroup\$ @eric_lagergren That prints to STDERR, not STDOUT. See here \$\endgroup\$ – isaacg Sep 6 '15 at 22:04
  • \$\begingroup\$ Oh gotcha. Never looked it up because I never use it. Thanks. \$\endgroup\$ – Eric Lagergren Sep 6 '15 at 22:06
  • \$\begingroup\$ Save 3 bytes by importing fmt into the global namespace with import."fmt" then just call Print("Hello, World!"). \$\endgroup\$ – George Gibson Jun 5 '16 at 9:45
  • \$\begingroup\$ @GeorgeGibson Thanks, that's a nice trick. \$\endgroup\$ – isaacg Jun 5 '16 at 17:24
4
\$\begingroup\$

Your Mom, 14 bytes

'Hello, World!

Explanation

'...
'... - Push the string. The ending ' is not needed at the end of program
     - Implicit output
\$\endgroup\$
4
\$\begingroup\$

Emojicode, 37 bytes

🏁🍇😀🔤Hello, World!🔤🍉
\$\endgroup\$
4
\$\begingroup\$

Golfuck, 39 bytes

jrseeqzjzzzsvDsj*aaa*r"s*hB(FsxahB(z*sh

Credit to primo, this is his answer, but in Golfuck.

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

Addict, 248 bytes

Addict is my new Turing-tarpit esolang, based on PRINDEAL.

a A
 i 1
 i 1
 d
a B
 A 1
 A 1
 d
a C
 B 1
 B 1
 d
a D
 C 1
 C 1
 d
a E
 D 1
 D 1
 d
E H
E H
C H
c H
E e
E e
E e
B e
i e
c e
E l
E l
E l
C l
B l
c l
c l
E o
E o
E o
D o
d o
c o
E c
C c
B c
c c
E s
c s
D H
d H
c H
c o
A o
i o
c o
c l
d e
c e
i s
c s

Test it online here!

Primer on addict

  • All memory is stored in variables. Variables can hold only non-negative integers; all variables start out at 0.
  • Addict has 4 built-in commands: decrement, increment, print a charcode, and take a charcode from input.
  • You can define your own commands with alias. This has very strict syntax:

a commandname
 command1
 command2
 command3

This creates a new command called commandname. Whenever commandname is called, the following process happens:

  • command1 is called.
  • If command1 succeeded, command2 is run.
  • If command1 failed, command3 is run.

See the GitHub repo for more information about Addict.


Act I

The first part of the program defines five commands: A, B, C, D, and E. Each one has this format:

a A
 i 1
 i 1
 d

This defines a command A which adds two to the input through the following process:

  • increment the 1st input.
  • If this succeeded, increment again. (i always succeeds unless it has no argument.)
  • Otherwise, decrement nothing. (This never gets run for the above reason.)

The next command defined is B, which adds 4 to the input:

a B
 A 1
 A 1
 d
  • Run A on the 1st input. (Always succeeds.)
  • If this succeeded, run A again. (Always gets run.)
  • Otherwise, decrement nothing. (Never gets run.)

Through the same process, C adds 8, D adds 16, and E adds 32.

Act II

The rest of the program is devoted to outputting Hello, World! in as few bytes as possible. The charcodes we need to output are 72 101 108 108 111 44 32 87 111 114 108 100 33, in that order. The shortest method I have found to output them all is to use six variables:

  • H to output 72 and 87
  • e to output 101 and 100
  • l to output 108
  • o to output 111 and 114
  • c to output 44
  • s to output 32 and 33

Here's a table of commands, and the values of the variables after each command:

Command  Output   H   e   l   o   c   s
E H              32   0   0   0   0   0
E H              64   0   0   0   0   0
C H              72   0   0   0   0   0
c H      H       72   0   0   0   0   0
E e              72  32   0   0   0   0
E e              72  64   0   0   0   0
E e              72  96   0   0   0   0
B e              72 100   0   0   0   0
i e              72 101   0   0   0   0
c e      e       72 101   0   0   0   0
E l              72 101  32   0   0   0
E l              72 101  64   0   0   0
E l              72 101  96   0   0   0
C l              72 101 104   0   0   0
B l              72 101 108   0   0   0
c l      l       72 101 108   0   0   0
c l      l       72 101 108   0   0   0
E o              72 101 108  32   0   0
E o              72 101 108  64   0   0
E o              72 101 108  96   0   0
D o              72 101 108 112   0   0
d o              72 101 108 111   0   0
c o      o       72 101 108 111   0   0
E c              72 101 108 111  32   0
C c              72 101 108 111  40   0
B c              72 101 108 111  44   0
c c      ,       72 101 108 111  44   0
E s              72 101 108 111  44  32
c s      (space) 72 101 108 111  44  32
D H              88 101 108 111  44  32
d H              87 101 108 111  44  32
c H      W       87 101 108 111  44  32
c o      o       87 101 108 111  44  32
A o              87 101 108 113  44  32
i o              87 101 108 114  44  32
c o      r       87 101 108 114  44  32
c l      l       87 101 108 114  44  32
d e              87 100 108 114  44  32
c e      d       87 100 108 114  44  32
i s              87 100 108 114  44  33
c s      !       87 100 108 114  44  33

If you can find any way to golf this program, please let me know!

\$\endgroup\$
6
  • \$\begingroup\$ Wow, this is a great language. Nice work! \$\endgroup\$ – Conor O'Brien Sep 27 '16 at 18:58
  • \$\begingroup\$ Seeing that 108, 111 and 114 are part of the output, maybe an alias to add 3 might help? \$\endgroup\$ – Martin Ender Sep 27 '16 at 18:58
  • \$\begingroup\$ @MartinEnder Thanks for the suggestion. An alias to add N will cost at least 17 bytes, so it'd need to save at least 5 lines (4 bytes each) to be worth it. (I originally had an alias F to add 64, but I only used it 4 times, so getting rid of it saved 1 byte.) \$\endgroup\$ – ETHproductions Sep 27 '16 at 19:01
  • \$\begingroup\$ @ConorO'Brien Thanks, I'm glad you like it! After spending a few months designing it, writing sample programs, and wishing I had time to code it, it took me about 4 hours to code: by far my shortest start-to-finish esolang implementation. ;) \$\endgroup\$ – ETHproductions Sep 27 '16 at 19:08
  • \$\begingroup\$ @Martin Using aliases for adding 2 3 6 12 24 48 seems to be about 7 bytes longer, but perhaps there's a different optimal set of aliases. I might write a brute-forcer when I have time. \$\endgroup\$ – ETHproductions Sep 29 '16 at 1:59
1
5 6
7
8 9
28

Your Answer

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

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