405
\$\begingroup\$

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

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

The Rules

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

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

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

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

For inspiration, check the Hello World Collection.

The Catalogue

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

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

## Language Name, N bytes

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

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

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

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

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

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

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

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

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

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

746 Answers 746

1
\$\begingroup\$

HTML & JS (w/ jQuery), 85 bytes

<b><script src="//code.jquery.com/jquery.min.js"><script>$("b").html("Hello, World!")
\$\endgroup\$
1
\$\begingroup\$

Caker, 294 bytes

ωΩθΩθθΩθΩθθθΘΩθθΩθθΩθΩθΩθΘθθΩθΩθθΩθθΘΩθθΩθΩθθΩθθΘΩθθΩθΩθθθθΘθΩθΩθθΩθθΘΩθΩθθθθθΘΩθΩθΩθΩθΩθθθΘθθΩθΩθθθθΘθθθΩθθΩθΩθΘΩθθΩθΩθθΩθθΘΩθθΩθθΩθΩθθΘΩθΩθθθθΩθΘ

Looks like alot of zeros...

\$\endgroup\$
1
\$\begingroup\$

Joy, 24 bytes

"Hello, World!"putchars.
\$\endgroup\$
  • 1
    \$\begingroup\$ You forgot the exclamation mark! \$\endgroup\$ – kirbyfan64sos Nov 21 '15 at 4:36
1
\$\begingroup\$

Beatnik, 246 bytes

If pizza zas zas zas zas zas zas my my zas if do key jo my zas if a my jo zas if kid my zas jo jo if za my jo zas if zapper my jo zas if had my jo zas zas my my zas if zas my jo my zas if za my jo zas if zap my jo zas if hip my jo jo if hip my jo

I know, someone else already posted a shorter Beatnik answer using invalid words, but this one uses only valid scrabble words.

\$\endgroup\$
1
\$\begingroup\$

D, 55 53 52 bytes

import std.stdio;void main(){"Hello, World!".write;}
\$\endgroup\$
  • 1
    \$\begingroup\$ You can save 2 bytes, by removing \n \$\endgroup\$ – Khaled.K Apr 30 '17 at 23:08
  • 1
    \$\begingroup\$ Capitalization is important. (i.e. change world to World). And won't "Hello, World!".write work? \$\endgroup\$ – Zacharý May 9 '17 at 0:46
1
\$\begingroup\$

JoshScript, 596 bytes

JOSHJoshJoshJoshJoshJoshJoshJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOshjoshjoshjoshjoshjoshjoshjoshjoshjoshjoshjoshjoshjoshjoshjoshjoshjoshjoshjoshjoshjoshjoshJoshJOSHJOshJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOshJOshJOSHJOSHJOSHJOshjosHjoshjoshjoshjoshjoshjoshjoshjoshjoshjoshjoshJOshjosHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOshjoshjoshjoshjoshjoshjoshjoshjoshjoshjoshJoshJoshjoshJOshJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOshJOSHJOSHJOSHJOshjoshjoshjoshjoshjoshjoshJOshjoshjoshjoshjoshjoshjoshjoshjoshJOshjosHjosHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOSHJOsh

JoshScript is an esoteric language that is made up entirely of joshes.

JoshScript is pretty easy to learn, below is the usage of JoshScript v1.01

JOSH increases the value by 1

josh decreases the value by 1

Josh multiplies the value by 2

josH divides the value by 2 and rounds down to the nearest integer

JOsh outputs the current value

joSH takes input and sets the value to the ascii repr. of the char

im not josh-obsessed i promise

\$\endgroup\$
1
\$\begingroup\$

PATH, 113 bytes

/++}+++++++}+++++}<$+++++++<
\+}++}++++++{{{{{-^}++.}+++.+++++++..+++.}++.}++++.}+++.{{{.+++.------.--------.}}+.

Try it online!

\$\endgroup\$
1
\$\begingroup\$

BrainFlump, 362 bytes

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++.+++++++:..+++.-------------------------------------------------------------------.------------.+++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++++++++.+++.;.--------.-------------------------------------------------------------------.

Try it online!

Should be shorter once we fix loops, but that's it for now.

\$\endgroup\$
1
\$\begingroup\$

Nhohnhehr, 181 bytes

+-----------+
|$010010000\|
|1100101011\|
|0110001101\|
|1000110111\|
|1001011000\|
|0100000010\|
|1011101101\|
|1110111001\|
|0011011000\|
|1100100001\|
|00001  @  \|
+-----------+

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Bitwise, 149 bytes

MOV 1 &1 &1
OUT &72 1
OUT &101 1
OUT &108 1
OUT &108 1
OUT &111 1
OUT &44 1
OUT &32 1
OUT &87 1
OUT &111 1
OUT &114 1
OUT &108 1
OUT &100 1
OUT &33 1

Pretty simple - just prints integer literals (&x) as ASCII characters. MOV 1 &1 &1 sets the 1st register to 1, so that each line can save 1 byte (using 1 instead of &1). The second variable to OUT is not optional. If the second variable (register/frame register/literal) is true, the character will be printed, otherwise it will not.

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Archway2, 182 bytes

                   \
 /
  >++>+++>+++>+<<<<-/>+>+>->+<<<<<-\>>.>---.+++++++..+++.>>++++.------------.<-.<.+++.------.--------.>>+.
  \    \
\++++>
++++++++/                         /

Try it online!

This program was derived from the Hello, World! program that I wrote for TIO. I realized that the code not inside the sub-loops can be aligned with the code inside the sub-loops removing some redundant direction changing. Unrolling the loop consisting of only a < to <<<< saves many bytes by not requiring the spaces to support the positioning of the reflectors. Flipping the main loop to go around the bottom of the program instead of the top allows the first few instructions of the main loop to be put on its own line while still being reachable from the start of the program. This lets us move the sub-loop closer to the edge of the program saving bytes.

\$\endgroup\$
1
\$\begingroup\$

Symbolic Python, 200 bytes

Managed to cut down 16 bytes from my original example on the wiki. Note that the unprintable on line two is \xc2\x8d.

This can definitely be shorter, but it took me long enough. I'll come back to it another time.

__=-~(_==_)
__=`_`[~__]+`_>_`[__::__]+`''`[-__::~__**__]
_=_==_
___='%'+__[-_]
__,_=___+__[-~_]+__[_]*-~_+__[_>_]+', '+___+__[_>_]+`_`[_]+__[-~_-_]+__[~_]+'!',-~-~_
___=_*_<<_
_=__%(___,___+_*-~-~_)

Try it online!

\$\endgroup\$
  • 1
    \$\begingroup\$ Cool, but JSF*ck is better. \$\endgroup\$ – Cyoce Oct 25 '17 at 23:07
1
\$\begingroup\$

Python 1, 20 bytes

print"Hello, World!"

Try it online!

\$\endgroup\$
  • \$\begingroup\$ This is a duplicate of a previous answer... I'll find it \$\endgroup\$ – Beta Decay May 30 '17 at 19:51
  • 1
    \$\begingroup\$ @BetaDecay codegolf.stackexchange.com/a/55432 and codegolf.stackexchange.com/a/103839 \$\endgroup\$ – ETHproductions May 30 '17 at 19:52
  • 5
    \$\begingroup\$ To any delete-voters, this is a valid answer in a language that hasn't yet been used. It is no longer a duplicate to the two pointed out by ETHproductions. It may not be particularly interesting, but that is no reason to delete this answer. \$\endgroup\$ – caird coinheringaahing Nov 12 '17 at 21:32
1
\$\begingroup\$

Excel VBA, 15 Bytes

Anonymous VBE immediate window function that takes no input and outputs Hello, World! to the VBE immediate window.

?"Hello, World!
\$\endgroup\$
1
\$\begingroup\$

Quetzalcoatl 17 15 bytes

"Hello, World!"

EDIT

I completely redesigned the language. The program pushes "Hello, World!" to stack, and implicitly prints.


P.S. I wrote Quetzalcoatl.

\$\endgroup\$
  • \$\begingroup\$ So you added ::. Does printing with slicing like this a=[1];::a[::] still work? \$\endgroup\$ – mbomb007 Feb 24 '16 at 18:16
  • \$\begingroup\$ Yes it does. I specifically made sure it did. I just replace :: with print, and [print with [:: before I use exec. I am just assuming nobody makes arrays out of print statements, like [print 'a', print 'b']. \$\endgroup\$ – NoOneIsHere Feb 24 '16 at 18:31
  • \$\begingroup\$ What if :: is within a string or two? Like exec"exec'print \"::\" ' "? \$\endgroup\$ – mbomb007 Feb 24 '16 at 19:35
  • \$\begingroup\$ If the :: is in a string, you have to escape it like so: print "\::". \$\endgroup\$ – NoOneIsHere Feb 24 '16 at 20:40
  • \$\begingroup\$ I'd probably rather use Python just for the simplicity. It's more well-known. \$\endgroup\$ – mbomb007 Feb 24 '16 at 20:42
1
\$\begingroup\$

CRPL and its sister language PRPL, 21 bytes

Bit of an obscure language, but the official tutorial doesn't contain a Hello World program so this at least is worth something.

"Hello, world!" Trace

"Hello, world!" pushes the string Hello, world! to the stack, and Trace pops an item from the stack and add it to the trace log, the closest thing the language has to SDTOUT or a console.

Alas, for this language is too obscure for Dennis♦'s gadget; however, I have written the following interpreter in JS with all the complexity needed for this demo. I may one day make it support more.

var code = '"Hello, world!" Trace';
var stack = [];
var vars = Object.create(null);

var literals = [];
code = code.replace(/"(.*?)"/g, (m, $1) => 'lit' + [literals.length, literals.push($1)][0]).split(/\s/);

for (var token of code) {
    if (token.match(/^lit(\d+)$/)) {
        stack.push(literals[token.slice(3)]);
    } else if (token.match(/^-?\d+.?\d*/)) {
        stack.push(+token);
    } else if (token.startsWith('<-')) {
        stack.push(vars[token.slice(2)]);
    } else if (token.startsWith('->')) {
        vars['v' + token.slice(2)] = stack.pop();
    } else {
        switch(token) {
            case 'Trace5':
                console.log(stack.pop());
            case 'Trace4':
                console.log(stack.pop());
            case 'Trace3':
                console.log(stack.pop());
            case 'Trace2':
                console.log(stack.pop());
            case 'Trace':
                console.log(stack.pop());
                break;
            default:
                throw new Error(token + 'is not implemented.');
        }
    }
}

\$\endgroup\$
  • \$\begingroup\$ No language is too obscure, you just have to ask for it on talk.tryitonline.net lol \$\endgroup\$ – ASCII-only Apr 11 '18 at 6:34
1
\$\begingroup\$

Verbosity, 382 bytes

Include<Integer>
Include<MetaFunctions>
Include<Output>
Include<String>
Integer:DefineVariable<o;1>
Output:DefineVariable<P;0>
String:DefineVariable<s;"Hello, World!">
String:RedefineVariable<s;String:RemoveCharactersFromStart<s;o>>
String:RedefineVariable<s;String:TakeFirstCharacters<s;o>>
Output:DisplayAsText<P;s>
DefineMain<> [
MetaFunctions:ExecuteScript<MetaFunctions@FILE>
]

Try it online!

Ungolfed

Include<Integer>
Include<MetaFunctions>
Include<Output>
Include<String>

Integer:DefineVariable<one; 1>
Output:DefineVariable<STDOUT; 0>
String:DefineVariable<string; "Hello, World!">

String:RedefineVariable<string; String:RemoveCharactersFromStart<string; one>>
String:RedefineVariable<string; String:TakeFirstCharacters<string; one>>

Output:DisplayAsText<STDOUT; string>

DefineMain<> [
	MetaFunctions:ExecuteScript<MetaFunctions@FILE>
]

Try it online!

I proudly present yet another language: Verbosity. Who needs to be good at code golfs, when you have a language like this?

\$\endgroup\$
  • \$\begingroup\$ I'm somewhat impressed at how it manages to error out on all my attempts to "obviously" shorten it. \$\endgroup\$ – Ørjan Johansen Dec 6 '17 at 1:21
1
\$\begingroup\$

face, 41 bytes

(Hello, World!
)\$*m%*7%+%%%,c'$,ioow%$%o

Explanation:

(...)   comment, skipped over by interpreter but used to embed string in source
\$*     assign $ to a pointer to the source code and * to a pointer to the IP
m%*     malloc space for %, a variable which will be used to store the length
7%+%%%  set % to 14 in a roundabout way (% = 7, % += %), the length of the string
,c'$,i  step into char mode to increment $, setting the start of the string
oo      set o to stdout
w%$%o   fwrite(str, 14, stdout), throwing the return value into %

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Ace, 1 byte

H

Try it online!

This is a golfing language I am currently in the process of making, so I thought I'd post it here. It's based on Aceto. I wasn't quite satisfied with what Aceto had to offer but I really liked using it so I decided I'd make my own language and include more builtins and NOT RUN THE IP ON A HILBERT CURVE. It currently has ~30 commands and I am improving it every day. I plan to get it officially on TIO by August 2018

\$\endgroup\$
1
\$\begingroup\$

Clean, 30 bytes

module m
Start="Hello, World!"

Try it online!

TIO link is 3 bytes longer to match TIOs file name: main.icl

\$\endgroup\$
1
\$\begingroup\$

shortC, 26 21 19 16 bytes

AR"Hello, World!

Just to showcase the language.

\$\endgroup\$
1
\$\begingroup\$

Dreaderef, 31 bytes

This file contains unprintables. Here is a reversible hexdump created with xxd:

00000000: 2206 4806 6506 6c06 6c06 6f06 2c06 2006  ".H.e.l.l.o.,. .
00000010: 5706 6f06 7206 6c06 6406 2106 5c6e 22    W.o.r.l.d.!.\n"

Try it online!

How does it work?

The reason this file is so unreadable is because it makes use of string literals to golf the code. The preprocessor expands string literals into their respective character values. The actual numbers this represents are:

6 72 6 101 6 108 6 108 6 111 6 44 6 32 6 87 6 111 6 114 6 108 6 100 6 33 6 10

6 is the command associated with chro (char output). So this code looks like this:

chro 72
chro 101
chro 108
chro 108
chro 111
chro 44
chro 32
chro 87
chro 111
chro 114
chro 108
chro 100
chro 33
chro 10
\$\endgroup\$
1
\$\begingroup\$

Rust, 34 bytes

fn main(){print!("Hello, World!")}

Short, Sweet, and simple.

I do not believe it's possible to make this program any smaller. If someone does, congratulations.

\$\endgroup\$
  • 1
    \$\begingroup\$ This has already been done, and with less bytes (actually, it's the exact same submission, but you miscounted here). \$\endgroup\$ – Esolanging Fruit Feb 2 '18 at 16:32
  • \$\begingroup\$ Nice to know. I'm new enough that I don't know if a search function exists for searching the answers (If one does, i can't find it) \$\endgroup\$ – moonheart08 Feb 2 '18 at 16:51
  • \$\begingroup\$ Some challenges, including this one, have a Javascript leaderboard snippet included in the question. (When there isn't, I don't know how to search well either.) \$\endgroup\$ – Ørjan Johansen Feb 2 '18 at 17:29
  • 2
    \$\begingroup\$ @ØrjanJohansen Searching for "Rust" answers on this question seems to work. \$\endgroup\$ – Esolanging Fruit Feb 2 '18 at 19:38
1
\$\begingroup\$

R16K1S60 Assembly, 56 Bytes

a:
mov bx, .b
.l:
mov ax, [bx]
send 4, ax
add bx, 1
cmp bx, .c
jne .l
.h:
hlt
jmp .h

.b: dw "Hello, World!"
.c: dw 14

Writes output to screen peripheral the R16K1S60 in ASCII. Runs on The Powder Toy save 2012356. (See link in header for info)

Note: How exactly should this be scored? I'm assuming just score the size of the ASM.

\$\endgroup\$
  • \$\begingroup\$ The link is a 404. I'd score the length of the resulting machine code, if that's a thing. \$\endgroup\$ – NieDzejkob Feb 8 '18 at 15:35
  • \$\begingroup\$ I'll try and get the length. I'll also fix the link. \$\endgroup\$ – moonheart08 Feb 8 '18 at 15:36
  • \$\begingroup\$ Code is 56 bytes compiled. I'll fix the byte count. However, i'm afraid a hexdump is beyond my reach at the moment, i don't know how the R16K1S60 encodes instructions on FILT, only that it uses 16 of the 48 available bits for it's word. \$\endgroup\$ – moonheart08 Feb 8 '18 at 15:40
1
\$\begingroup\$

Momema, 63 bytes

0-9*072*0101*0108*0108*0111*044*032*087*0111*0114*0108*0100*033

Try it online!

This is a golfed version of the Hello World program given by TIO. The only difference is that we store the value -9 (the cell which is memory-mapped for character-based I/O) in cell 0, and then use *0 (the value of cell 0) instead of -9 everywhere. This wouldn't save bytes except that Momema will parse a leading 0 on a string literal as a separate number, so you can write e.g. *0108 instead of -9 108. This saves a byte for every write.

As hinted above, the program consists of a series of writes of various codepoints to -9 (the address which is memory-mapped to perform character-based I/O). In ungolfed form, it looks like:

0   -9
*0  72
*0  101
*0  108
*0  108
*0  111
*0  44
*0  32
*0  87
*0  111
*0  114
*0  108
*0  100
*0  33
\$\endgroup\$
1
\$\begingroup\$

Crayon, 16 Bytes

"Hello, World!"q

Try it online!

\$\endgroup\$
  • 2
    \$\begingroup\$ Welcome to PPCG! \$\endgroup\$ – Martin Ender Feb 12 '18 at 12:07
1
\$\begingroup\$

Felix, 21 bytes

print"Hello, World!";

Try it online!

Somebody linked to this language on PPCG and I thought it was interesting. In the interest of getting to know the language, I thought I'd write some programs in it.

The Felix docs all use print$ x instead of print x because print is a procedure and not a keyword, so use of the Haskell-style low-precedence application operator $ allows a slightly more natural syntax (compare print (1 + foo(5)); with print$ 1 + foo(5);. I'm not sure I agree completely with this, but it's just a convention and as I'm on PPCG I can break it without feeling guilty.

print is Felix's function to output something, with no trailing newline.

\$\endgroup\$
1
\$\begingroup\$

rk, 22 + 2 (-e) = 24 bytes

print: "Hello, World!"

Requires the -e flag (remove necessity for rk:start). Try it online!

\$\endgroup\$
1
\$\begingroup\$

Stax, 8 bytes

èï┬▀↨╩4G

Run and debug online!

Explanation

èï┬▀↨╩4G is the packed form of the ASCII Stax code `jaH1"jS3!, which is in turn a compressed string literal of Hello, World! with the ending backtick omitted.

\$\endgroup\$
1
\$\begingroup\$

Brat, 17 bytes

p "Hello, World!"

Try it online!

\$\endgroup\$

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.