404
\$\begingroup\$

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

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

The Rules

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

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

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

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

For inspiration, check the Hello World Collection.

The Catalogue

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

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

## Language Name, N bytes

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

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

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

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

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

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

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

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

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

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

742 Answers 742

8
\$\begingroup\$

beeswax, 15 bytes

Finally the first esolang I created is ready for use. I started working on beeswax as an esolang on a hexagonal grid parallel to Martin Büttner’s Hexagony, but he got finished his well before my language, as it took me quite a while to get everything right. So, here is the second esolang working on a hexagonal grid. ;)

A short hello world program is rather unspectacular, as the ` character toggles output to STDOUT.

So, here are the two short, but boring versions:

_`Hello, World!

or

*`Hello, World!

Or slightly less boring:

!dlroW ,olleH`*

_ creates instruction pointers in the horizontal axis, one moving to the right, one moving to the left.

* creates instruction pointers in all main axes, like demonstrated below.

A little more interesting, but 1 byte longer:

!lo olH`_`el,Wrd

And finally, an even more interesting version, if that’s possible:

r  l
 l o
  ``
ol`*`,d!
   ``
   e H
   W

And the same, using the beeswax prettyprint tool:

      r     l
       l   o
        ` `
   o l ` * ` , d !
        ` `
       e   H
      W

Both of which work because IPs execute their instructions in the reverse order they were created/pushed on the IP stack.

The neighborhood of every cell in a program (named honeycomb) looks like shown below. β marks a bee (instruction pointer), the numbers show the directions of the surrounding cells.

  2 — 1
 / \ / \
3 — β — 0
 \ / \ /
  4 — 5

This would be rather like a beautified version of the actual code, which is stored in a rectangular format like

21
3β0
 45

Each bee carries a stack with a fixed length of 3 values around (which isn’t used in the examples above), but they can push values on a global stack of unlimited size, or take values from it, for handling larger amounts of data. The global stack can only do basic stack operations like rotating values up and down. Only bees can do more complex operations like arithmetics or logic operations. All values are 64 bit unsigned integers.

Bees can also drop values to any place on the honeycomb and change its size or modify the source code this way, or they can pick up values from any place on the honeycomb. The contents of the global stack can be written to files, or file contents can be stored in the global stack.

More info, the full specification, an interpreter (with very basic debugging abilities) written in Julia, examples etc. can be cloned from my github page. Pretty much the same information is also available on the esolangs.org beeswax page.

\$\endgroup\$
8
\$\begingroup\$

05AB1E, 14 7* bytes

*14 bytes for the use of the trademarked Ÿ

Code:

”Ÿ™,‚ï!

Try it online!

Like Jelly, this uses a compression method using an English dictionary. How it works? Let's find out:

”       # Start a compressed string with all words titlecased
 Ÿ      # In Info.txt, you can see that this has index 24
  ™     # Index 19
        # These two indexes combined is 2419, in the dictionary you can see that the
          2419th word is hello
   ,    # Since this has no index, this will be interpreted as a normal character
    ‚ï  # Index 0118, which is the word "world". An extra space before this word is
        # implicitly added.
      ! # Regular exclamation mark
        # All the compressed words are automatically title cased.
          resulting in: "Hello, World!"

This uses CP-1252 encoding

Previous version:

"Hello, World!
\$\endgroup\$
  • 10
    \$\begingroup\$ Ÿ™, That's right, I just trademarked Ÿ. You cannot use it without doubling your code golf score :P \$\endgroup\$ – Conor O'Brien Feb 11 '16 at 23:37
  • 2
    \$\begingroup\$ @CᴏɴᴏʀO'Bʀɪᴇɴ Hahaha, fair enough then :p \$\endgroup\$ – Adnan Feb 12 '16 at 11:50
8
\$\begingroup\$

Flummery v3, 165 bytes

Flummery is a BF derivative, but not in the usual sense. It's a meta BF, if you will. There is a pointer, and there is a tape.

 [ < > + - ]
 ^

The > command moves the pointer right one, < moves the pointer left one, . is ., , is ,, and any other character is a no-op. After each character is read, the character pointed to is added to the transpiled code. (At the moment, you'll have to copy+paste the transpiled code into a BF interpreter.) Without further ado, here is the code:

>>>>;;;<<<;;>>>;;<<<;;;>><<<>>><<<>;>><>>;;;;<<>>;;<<>>;;<<>>;;<<<;;;;>>>><<<>>><<<<;;;>>>;;.;<<<;;>>;;;;;.<<;;;>>>;..;<<<;;.;;>>.<;.;;.<;;.;>>;;.<;.;;>>;.;<<<;;;;>>.

All in one textbox:

>>>>;;;<<<;;>>>;;<<<;;;>><<<>>><<<>;>><>>;;;;<<>>;;<<>>;;<<>>;;<<<;;;;>>>><<<>>><<<<;;;>>>;;.
;<<<;;>>;;;;;.<<;;;>>>;..;<<<;;.;;>>.<;.;;.<;;.;>>;;.<;.;;>>;.;<<<;;;;>>.

Or, in a readable fashion:

>>>>;;
;<<<;
;>>>;
;<<<;;
;>>
<<<
>>>
<<<
>
;>>
<
>>;;;
;<<
>>;
;<<
>>;
;<<
>>;
;<<<;;;
;>>>>
<<<
>>>
<<<<;;
;>>>;;
.
;<<<;
;>>;;;;;
.
<<;;
;>>>;
..
;<<<;;
.
;
;>>
.
<;
.
;;
.
<;;
.
;>>;;
.
<;
.
;;
>>;
.
;<<<;;;
;>>
.

Each line represents a single character added to the source code.

oh heavens what have I made

\$\endgroup\$
  • \$\begingroup\$ What do the ';' do? A combination of . and ,? \$\endgroup\$ – Rɪᴋᴇʀ Mar 14 '16 at 2:35
  • \$\begingroup\$ @RikerW any non > or < character is treated as "add the currently pointed at character to the result" \$\endgroup\$ – Conor O'Brien Mar 14 '16 at 2:36
  • \$\begingroup\$ Oh, okay. That makes sense. \$\endgroup\$ – Rɪᴋᴇʀ Mar 14 '16 at 2:41
  • \$\begingroup\$ I hate you so much. So, so much. So much. \$\endgroup\$ – Nic Hartley Apr 6 '16 at 21:29
  • \$\begingroup\$ @QPaysTaxes Thanks mate :) \$\endgroup\$ – Conor O'Brien Apr 6 '16 at 21:29
8
\$\begingroup\$

Brian & Chuck, 42 38 32 bytes

_#Jgnnq."Yqtnf#_{?
#{<{>-?>--.>?

Try it online!

Introducing my latest esolang, originally submitted for Create a programming language that only appears to be unusable.

Each of the two lines defines a Brainfuck-like program which operates on the other program's source code - the first program is called Brian and the second is called Chuck. That makes "Hello, World!" about as simple as it is in Self-modifying Brainfuck (compared to Brainfuck itself).

I said that looping was too expensive in B&C to be worthwhile for a simple "Hello, World!", but it turns out I was wrong. Now I'm much less convinced that the code is optimal as it stands...

Explanation

One note about the source code: when parsing it, the interpreter replaces all _ with null bytes to make it easier to insert zero cells into the tapes.

Notice that Jgnnq."Yqtnf# is Hello, World! shifted by two characters. Why is it shifted? Because the , in Hello, World! is a valid command which would set a cell on Chuck to -1. We could shift it by one character (either way), but then the , would turn into either + or - which are also valid commands. We could reverse those at the end of Brian but the code as above has the same byte count and it seems a bit neater: we shift them by two characters, such that . becomes , which is a no-op for Brian.

So, when the program begins, Brian ignores everything on the tape until {? which switches control to Chuck, starting on the second command.

{<{> on Chuck finds the first non-zero cell on Brian (initially the #, which is just a dummy no-op). We decrement it with -. If that didn't make the cell zero yet, ? switches control back to Brian. Brian again ignores all the "code" in Jgnnq."Ypynf#_ and resets the loop on Chuck with {?.

Once that first cell has been zeroed, ? is a no-op. >--. moves to the next cell, subtracts 2 (to correct the offset) and prints it. Then we check if there's another character left to print by moving one to the right with >. If this reaches the null byte after the string (the _ on Brian's tape), then ? is a no-op and the program terminates. If that isn't a null byte yet, we've got more printing to do, and start over by switching to Brian who resets the loop with {? once more.

\$\endgroup\$
  • 3
    \$\begingroup\$ Congratulations on posting the 300th answer to this question. [insert_celebrate_emoticon_here] \$\endgroup\$ – manatwork Nov 6 '15 at 14:31
8
\$\begingroup\$

USML, 9 bytes

S0h7cWs8h

Try it online!

Explanation:

S0h7cWs8h
S0h7       # Get characters 0-7 of h ("Hello, world!").
    cW     # Get the character "W"
      s8h  # Get the remaining characters, starting at character 8, of h.

This program is an interesting problem, as it has a command that outputs "Hello, world!" (and an empty program will also do this), but the capitalization is not correct. As a result, we need to take some substrings and add in the correct character.

\$\endgroup\$
  • 6
    \$\begingroup\$ This is probably the first interesting use of a HW-built-in I've seen in this challenge. \$\endgroup\$ – Martin Ender Apr 8 '17 at 22:15
8
\$\begingroup\$

Monkeys, 484 460 455 448 bytes

7 RIGHT
7 RIGHT
7 RIGHT
7 RIGHT
7 UP
5 DOWN
5 RIGHT
4 DOWN
7 TEACH
7 BOND
4 UP
7 BOND
7 TEACH
7 TEACH
6 YELL
4 TEACH
4 TEACH
7 FIGHT
5 TEACH
6 YELL
7 TEACH
7 TEACH
5 FIGHT
6 YELL
6 YELL
7 TEACH
5 FIGHT
6 YELL
7 EGO
4 TEACH
5 TEACH
6 YELL
4 FIGHT
7 TEACH
6 YELL
4 TEACH
4 TEACH
4 DOWN
7 TEACH
4 UP
4 TEACH
5 FIGHT
6 YELL
4 TEACH
7 TEACH
6 YELL
7 TEACH
5 FIGHT
6 YELL
7 FIGHT
5 FIGHT
5 FIGHT
6 YELL
7 FIGHT
7 FIGHT
6 YELL
7 EGO
7 TEACH
7 TEACH
6 YELL

Try it online!

How it works

Monkeys consists internally of a 10x10 grid containing 7 monkeys (and 14 bananas we won't use). The grid initially looks as follows.

..!1.!....
.......2!.
.........!
.3.!......
.......!..
.!....!...
..5.!4....
....6...!.
......!...
.7......!.

All monkeys initially have a value of 0. Moving a monkey UP, DOWN, LEFT, or RIGHT increments its value by 1, unless the target square is adjacent (horizontally, vertically, or diagonally) to another monkey.

In addition, any monkey can modify all adjacent monkeys' values with TEACH (adding the "teacher's" value to adjacent monkeys' values), FIGHT (subtracting), BOND (multiplying), and EGO (dividing).

First,

7 RIGHT
7 RIGHT
7 RIGHT
7 RIGHT
7 UP
5 DOWN
5 RIGHT

moves monkeys 5 and 7 to their final positions. This sets 5's value to 1 and 7's value to 4. The grid now looks as follows.

..!1.!....
.......2!.
.........!
.3.!......
.......!..
.!....!...
....!4....
...56...!.
.....7!...
.!......!.

Now,

4 DOWN
7 TEACH
7 BOND
4 UP

monkey 4 moves down (and is now adjacent to 7), monkey 7 adds its value (4) to monkeys 4 and 6, monkey 7 multiplies 4's and 6's values by 4, then 4 moves back to its place. The monkeys' values are now as follows.

 5:  1
 7:  4
 4: 16

 6: 16

From now on, we'll mostly use monkeys 5, 7, and 4 to add or subtract 1, 4, or 16 to/from monkey 6's value. Making monkey 6 YELL prints its value as a character.

If we represent monkey 6's value with v, the remainder of the program looks as follows in pseudo-code.

7 BOND   v *=  4 // v ==  64
7 TEACH  v +=  4 // v ==  68
7 TEACH  v +=  4 // v ==  72 == 'H'
6 YELL   putchar(v)
4 TEACH  v += 16 // v ==  88
4 TEACH  v += 16 // v == 104
7 FIGHT  v -=  4 // v == 100
5 TEACH  v +=  1 // v == 101 == 'e'
6 YELL   putchar(v)
7 TEACH  v +=  4 // v == 105
7 TEACH  v +=  4 // v == 109
5 FIGHT  v -=  1 // v == 108 == 'l'
6 YELL   putchar(v)
6 YELL   putchar(v)
7 TEACH  v +=  4 // v == 112
5 FIGHT  v -=  1 // v == 111 == 'o'
6 YELL   putchar(v)
7 EGO    v /=  4 // v ==  27
4 TEACH  v += 16 // v ==  43
5 TEACH  v +=  1 // v ==  44 == ','
6 YELL   putchar(v)
4 FIGHT  v -= 16 // v ==  28
7 TEACH  v +=  4 // v ==  32 == ' '
6 YELL   putchar(v)
4 TEACH  v += 16 // v ==  48
4 TEACH  v += 16 // v ==  64
4 DOWN   The next operation will affect monkey 4 as well.
7 TEACH  v +=  4 // v ==  68
4 UP     Monkey 4's value changed from 16 to 20.
4 TEACH  v += 20 // v ==  88
5 FIGHT  v -=  1 // v ==  87 == 'W'
6 YELL   putchar(v)
4 TEACH  v += 20 // v == 107
7 TEACH  v +=  4 // v == 111 == 'o'
6 YELL   putchar(v)
7 TEACH  v +=  4 // v == 115
5 FIGHT  v -=  1 // v == 114 == 'r'
6 YELL   putchar(v)
7 FIGHT  v -=  4 // v == 110
5 FIGHT  v -=  1 // v == 109
5 FIGHT  v -=  1 // v == 108
6 YELL   putchar(v)
7 FIGHT  v -=  4 // v == 104
7 FIGHT  v -=  4 // v == 100 == 'd'
6 YELL   putchar(v)
7 EGO    v /=  4 // v ==  25
7 TEACH  v +=  4 // v ==  29
7 TEACH  v +=  4 // v ==  33 == '!'
6 YELL   putchar(v)
\$\endgroup\$
7
\$\begingroup\$

Ruby, 18 19 bytes

puts"Hello, World!"

Output wasn't quite right. Thanks Martin

\$\endgroup\$
  • \$\begingroup\$ Why not p"Hello, World!"? It's only 15 bytes. \$\endgroup\$ – John Jan 29 '16 at 23:37
  • 1
    \$\begingroup\$ @John: p always always prints quotes around strings. \$\endgroup\$ – Mega Man Jul 18 '16 at 18:22
7
\$\begingroup\$

Yorick, 21 bytes

write,"Hello, World!"

Yorick is a fast programming language for scientific number-crunching and graph-potting. It's relatively unknown and doesn't distinguish itself too much from other languages like R, but this Y-language completes the alphabet. Whoo!

\$\endgroup\$
  • 3
    \$\begingroup\$ +1 for completing the alphabet. Also for answering like 20 times. \$\endgroup\$ – AdmBorkBork Aug 28 '15 at 19:02
7
\$\begingroup\$

Trigger, 40 bytes

HHHeeelll#lllooo,,,   WWWooorrrlllddd!!!

Trigger is pattern-based, so commands are symbol independent. Three of the same character outputs that character to STDOUT.

The # is to introduce a break in the middle so that the double l doesn't turn into a six-long pattern, which will not decompose as intended. A single char is a NOT operation, but it is irrelevant for our purposes.

\$\endgroup\$
  • \$\begingroup\$ Can you only go 1 letter at a time? Or could you say Hello, World!Hello, World!Hello, World! which would be 1 character shorter because it doesn't need the "#"? \$\endgroup\$ – Albert Renshaw Sep 29 '15 at 21:23
  • \$\begingroup\$ @AlbertRenshaw Trigger is based on patterns, and three of the same char in a row outputs. A pattern of AAB (e.g. llo) is a jump operation, and any other one-char pattern is NOT. So the example you give would be a lot of NOTs and jumps, rather than outputs. \$\endgroup\$ – Sp3000 Sep 29 '15 at 23:14
7
\$\begingroup\$

7, 45 bytes

(Important note: 7 is an unpublished esolang of my creation.)

4**++o/++d*no++doo:+do:/+no---*+uo+duo--o/++o

7 is a stack-based esolang of my invention. It has no built-in String or Array support, and you can't even push a specified number to the stack (with a few exceptions), so everything has to be done by hand. Here's what each operator does:

  • 4 sets variable b to 4. This can only be done at the beginning of the program. 7 is the default value, hence the name.
  • Arithmetic +-*/ works as you would expect, but operates between the top item and b. (This is changable, but this program doesn't change it.)
  • n and d increment and decrement the top item by 1, respectively.
  • : duplicates the top item.
  • o outputs the top item, while u outputs and pops the top item.

This program outputs the ASCII values of the proper characters. There are a bunch more operators which have a bunch more jobs, but I won't go into detail right now. I'm planning to publish it as soon as I have enough time.

\$\endgroup\$
7
\$\begingroup\$

ferNANDo, 111 109 bytes

7 7
3
5 5
6 5
4 3 3
0 5 3 0 7 3 0 0
0 5 7 0 0 5 0 4
0 6 5 2 4 6 2 3
0 6 6 0 7 7 2 3
0 6 6 2 5 4 7 4
2 2
3 5
3

The above loops three times, printing five characters each time, trailing with \r\n, which I am considering to be a single newline. The general setup I use to loop three times is the following:

7 7
3
5 5
6 5
4 3 3
1 6 6
0 0 7 7 0 0 0 0
0 0 7 7 0 0 0 1
0 0 7 7 0 0 0 2
0 0 7 7 0 0 0 3
0 0 7 7 0 0 0 4
0 0 7 7 0 0 0 5
0 0 7 7 0 0 0 6
0 0 7 7 0 0 0 7
0 0 0 0 7 0 7 0
2 2
3 5
3

producing:

00001111
00110011
01010101

which I think makes the variable names 0-7 somewhat evident. In this arrangement the value 1 is not needed, saving 6 bytes.

\$\endgroup\$
7
\$\begingroup\$

MATL, 15 bytes

'Hello, World!'

A string literal is pushed onto the stack. It gets implicitly printed at the end of the program.

\$\endgroup\$
  • 1
    \$\begingroup\$ Is it finished? Congratz! Looking forward to seeing it in use. I'll hopefully have the chance to check it out one day :-) \$\endgroup\$ – Stewie Griffin Dec 12 '15 at 17:09
  • 1
    \$\begingroup\$ @StewieGriffin Not sure if it's "finished"... let's just say "stable enough". It's in version 1.0.0. But yes, it's an official version now. Being an experienced Matlab user, I hope you'll find it interesting! \$\endgroup\$ – Luis Mendo Dec 12 '15 at 17:13
7
\$\begingroup\$

Binary-Encoded Golfical, 40+1 (-x flag)= 41 bytes

Can be transpiled back into the standard graphical version using the included Encoder utility, or run directly using the -x flag.

Hex dump:

01 90 01 00 48 18 00 65 18 00 6C 18 18 00 6F 18
00 2C 18 00 20 18 00 57 18 00 6F 18 00 72 18 00
6C 18 00 64 18 00 21 18

Original image:

enter image description here

Zoomed in by a factor of 16:

enter image description here

Explanation: Uses the active cell to store values, and prints them as characters

\$\endgroup\$
7
\$\begingroup\$

Pris, 107 bytes

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

Try it out here! And here's an explanation!

(][[[]]( ; 72
}]       ; out H
)]]]])   ; 32
{]       ; 72 -> reg
(]]][    ; r += 29
}]       ; out e
(]]      ; r += 7
}]       ; out l
{]]]     ; nop
}]       ; out l
(]       ; r += 3
}]       ; out o
{]       ; set r to 72
}]]]     ; nop
{{       ; change focus
}]]]     ; nop
{]       ; 32 -> reg
(][](    ; r += 12
}]       ; out ,
{]       ; set r to 32
}]       ; out " "
{        ; change focus
(]]]     ; r += 15
}]       ; out W
(]][     ; r += 13
{]       ; 100 -> reg
(][]     ; r += 11
}]       ; out o
(]       ; r += 3
}]       ; out r
{]       ; reg -> r
)        ; "nop"
{]       ; r -> reg
(]](     ; r += 8
}]       ; out l
{]       ; reg -> r
}]       ; out d
{{       ; change focus
}]       ; out !

Now aren't you ready to take on the world? Haha, here's some help. From the README:

Pris has six functional characters, but has more commands than that. Strings of symbols have different meanings according to their number.

A Pris program is comprised of a series of meta-commands, or keywords. A keyword is made of a series of one of any of the four main construction symbols ((, ), {, and }) and some modifier symbols ([ and ]). It must start with a constructoin symbol, and this denotes a change in meta-command. For example, the string (([[][()]])[) has two meta commands: (([[][( and )]])]).

[...]

There are two registers, designated LEFT and RIGHT. One of them is "focused" and the other is "unfocused".

In the above explanation, r is the focused register. reg is the external register for holding other values. It cannot be focused on, but only accessible using {{{, or {].

\$\endgroup\$
  • 3
    \$\begingroup\$ My only words are "O_o" \$\endgroup\$ – Downgoat Mar 15 '16 at 2:46
  • \$\begingroup\$ @Downgoat Then I have done my job. \$\endgroup\$ – Conor O'Brien Mar 15 '16 at 2:50
7
\$\begingroup\$

Bodyless HTTP response headers, 134 bytes

HTTP/1.1 200 OK
content-type: text/html
link: <data:text/css,body:after{content:"Hello, World!"}>; rel=stylesheet
content-length: 0

It is a valid http-response headers set. They have to be followed by 2 newlines \r\n\r\n. The response body is empty. Firefox can handle such response and shows an HTML page with Hello, World! text.

Line breaks are counted as 2 symbols, according to HTTP specification. The 2 trailing newlines are not counted as they do not belong to the headers themselves.

\$\endgroup\$
  • \$\begingroup\$ Does it work if you omit content-length and just close the connection? \$\endgroup\$ – jimmy23013 Sep 4 '15 at 8:04
  • \$\begingroup\$ @jimmy23013, I didn't check it. I expect your version to work, but it won't be a valid response as I understand. \$\endgroup\$ – Qwertiy Sep 4 '15 at 10:50
  • 1
    \$\begingroup\$ Is this a programming language? No, it's not. It can't represent natrual numbers in a mathematically useful way, it cannot represent tuples, it cannot check for primes, and it cannot add two natural numbers. see eg here I'm not sure if programming language-ness actually matters for this challenge; it's just a note. \$\endgroup\$ – cat Jun 28 '16 at 13:42
7
\$\begingroup\$

Sesos, 24 21 bytes

0000000: 2845ee adaa55 ddcabd 123596 b32b71 5f398a 23b577  (E...U....5..+q_9.#.w

Try it online! Check Debug to see the generated binary code.

I tried several less straightforward approaches – including a port of @primo's brainfuck answer – but they all turned out longer.

How it works

The binary file above has been generated by assembling the following SASM code.

add 72  ; Set cell 0 to 72.
put     ; Print 'H'.
fwd 1   ; Advance to cell 1.
add 101 ; Set cell 1 to 101.
put     ; Print 'e'.
add 7   ; Set cell 1 to 108.
put     ; Print 'l'.
put     ; Print 'l'.
add 3   ; Set cell 1 to 111.
put     ; Print 'o'.
fwd 1   ; Advance to cell 2.
add 44  ; Set cell 2 to 44.
put     ; Print ','.
sub 12  ; Set cell 2 to 32.
put     ; Print ' '.
rwd 2   ; Retrocede to cell 0.
add 15  ; Set cell 0 to 87.
put     ; Print 'W'.
fwd 1   ; Advance to cell 1.
put     ; Print 'o'.
add 3   ; Set cell 1 to 114.
put     ; Print 'r'.
sub 6   ; Set cell 1 to 108.
put     ; Print 'l'.
sub 8   ; Set cell 1 to 100.
put     ; Print 'd'.
fwd 1   ; Advance to cell 2.
add 1   ; Set cell 2 to 33.
put     ; Print '!'.
\$\endgroup\$
  • \$\begingroup\$ How does this end up being shorter than the trivial solution when assembled? codegolf.stackexchange.com/a/86567/34718 \$\endgroup\$ – mbomb007 Jul 25 '16 at 19:39
  • \$\begingroup\$ Because the arguments to add and sub are considerably smaller. Arguments are encoded in bijective binary, and each digit requires 3 bits. \$\endgroup\$ – Dennis Jul 25 '16 at 19:42
7
\$\begingroup\$

Haskell, 26 bytes

main=putStr"Hello, World!"

Try it online!

\$\endgroup\$
  • \$\begingroup\$ Putting one of the many compilers you downloaded for PLQ to good use I see. ;) \$\endgroup\$ – Alex A. Aug 28 '15 at 16:52
7
\$\begingroup\$

Retina, 14 bytes


Hello, World!

Try it online!

A program with two lines describes a single regex replacement. Here, we just replace the empty string (i.e. the input) with the desired output.

For one additional byte, we can make it work with non-empty input, by using a constant stage:

K`Hello, World!

Try it online!

\$\endgroup\$
7
\$\begingroup\$

Fueue,  44  42 41 40 bytes

Thanks to Ørjan Johansen for saving 2 bytes.

72:108)<101[44+-6:114)32[100 33H]87]:111

Try it online!

Explanation

Fueue is, as the name suggests, a queue-based language, which is a lot more mindboggling than it sounds (although a lot of that is due to the fact that the program and the data reside in the same queue).

Here is a breakdown of the program's execution (there are no negative integer literals in Fueue, so there's no syntax for them; I'll be representing the minus sign as _ to distinguish it from the negation command -):

Cmd    Explanation               Queue
72     Print 'H'.                :108)<101[44+-6:114)32[100 33H]87]:111
:108   Duplicate 108.            )<101[44+-6:114)32[100 33H]87]:111 108 108
)      Inactive.                 <101[44+-6:114)32[100 33H]87]:111 108 108)
<      Inactive.                 101[44+-6:114)32[100 33H]87]:111 108 108)<
101    Print 'e'.                [44+-6:114)32[100 33H]87]:111 108 108)<
[...]  Inactive.                 :111 108 108)<[44+-6:114)32[100 33H]87]
:111   Duplicate 111.            108 108)<[44+-6:114)32[100 33H]87]111 111
108    Print 'l'.                108)<[44+-6:114)32[100 33H]87]111 111
108    Print 'l'.                )<[44+-6:114)32[100 33H]87]111 111
)      Inactive.                 <[44+-6:114)32[100 33H]87]111 111)
<      Append to block.          111)[44+-6:114)32[100 33H]87 111]
111    Print 'o'.                )[44+-6:114)32[100 33H]87 111]
)      Deblock.                  44+-6:114)32[100 33H]87 111
44     Print ','.                +-6:114)32[100 33H]87 111
+      Inactive.                 -6:114)32[100 33H]87 111+
-      Negate 6.                 :114)32[100 33H]87 111+_6
:      Duplicate 114.            )32[100 33H]87 111+_6 114 114
)      Inactive.                 32[100 33H]87 111+_6 114 114)
32     Print ' '.                [100 33H]87 111+_6 114 114)
[...]  Inactive.                 87 111+_6 114 114)[100 33H]
87     Print 'W'.                111+_6 114 114)[100 33H]
111    Print 'o'.                +_6 114 114)[100 33H]
+      Add -6 and 114.           114)[100 33H]108
114    Print 'r'.                )[100 33H]108
)      Deblock.                  108 100 33H
108    Print 'l'.                100 33H
100    Print 'd'.                33H
33     Print '!'.                H
H      Halt the program.

I guess the more interesting question is how on earth did we get here. I started from the basic "Hello, World!":

72 101 108 108 111 44 32 87 111 114 108 100 33H

My primary goal was to get rid of the duplicate 108 for ll, since Fueue has a duplication command. So the naive thing to try is this:

72 101:108 111 44 32 87 111 114 108 100 33H

The problem is that now the 108 doesn't get printed when its duplicated: every command in Fueue puts the result at the end of the queue. So after printing He, and duplicating the 108 we'd end up with this queue:

111 44 32 87 111 114 108 100 33H108 108

Which would just print o, World! and then halt the program, dropping the ll completely.

So we need to delay the execution of everything from 111 to H until after we had time to print the ll. To delay a piece of code by one cycle through the queue, we can wrap it in a block and "unblock" it:

72 101:108)[111 44 32 87 111 114 108 100 33H]

This works! It prints He, then duplicates the 108, then puts the entire rest of the code after the double 108 so we have this queue now:

108 108 111 44 32 87 111 114 108 100 33H

Which is exactly what we want. But we can save one more byte: since the 108 don't get printed immediately, we're free to move the 72 and 101 around in the program: they're going to be printed in the first cycle through the queue no matter what and the 108s are going to end up after them. So by moving the 101 to the end of the program, we can avoid the space between the two numbers.

At this point, we've got my initial 44-byte solution. But I wanted to get rid of the duplicate 111 as well, which seems kinda possible since one of them is now at the start of the block and we've got swap commands. So the first idea is to split up our block around the 111 and add in a duplicate and swap:

72:108~[44 32 87]:111)[114 108 100 33H]101

Of course, this doesn't quite work. There's a couple of problems here: a) we've got no deblock command for the first block. b) The swap happens on the first cycle through the queue, so it actually swaps the block with the duplication wreaking all sorts of havoc. What we really want is to duplicate the 111, then swap the block between the two numbers, but then we also want to deblock that before printing the second 111. That last part is an issue, because if we don't deblock the block the first time around, the 111 is going to printed on the second cycle (before the block can be executed), but if we do deblock it immediately, we can't swap it between the two numbers as a single unit.

The trick is to use the "append" command instead of swap. Instead of trying to get from here:

[44 32 87]111 111

to here:

111 44 32 87 111

We are going to go here instead:

111[44 32 87 111]

By appending the first copy of 111 into the block, and making use of the automatic move to the end of the queue, we hit two birds with one stone: we've moved the , W characters in between the two os and we've ensured that the second 111 can't be printed before the other characters get deblocked. So the basic idea now looks something like this:

72:108<[44 32 87]:111)[114 108 100 33H]101

There's still an issue: the < should happen on the second cycle, because we need the duplication to happen first. We could go with the )[<] technique we used for the 44-byte solution, but we can also delay it by moving the101between it and its argument (because numbers are not a valid first argument for<, the<` will be inactive on the first cyle). We also still need a deblock command for the first block:

72:108)<101[44 32 87]:111)[114 108 100 33H]

Now we're talking. On the first cycle, ) has nothing to deblock so it just moves to the end. Likewise, < has nothing to append we have time to duplicate the 111. On the second cycle, ) still has nothing to deblock, and < appends one copy of the 111 to the block, whereas the other one gets printed. On the third cycle, ) can finally deblock [44 32 87 111], so that they get printed on the fourth cycle. Woohoo, we got Hello, Wo!

But wait: what about the second block? In the current code, it gets deblocked immediately in the first cycle so it would already be executed on the second cycle, printing rld! and terminating the program way too early. The trick is to move it into the first block. That way, it can't possibly be deblocked or executed before those other characters are printed:

72:108)<101[44 32 87)[114 108 100 33H]]:111

We're at 43 bytes now, but we can save two more. This is similar to how we saved the space in the original solution: it doesn't matter where the three numbers inside the outer block appear, because they are going to be printed on the first cycle regardless of where they are. So we can move the ) and the inner block between the numbers to avoid the spaces again:

72:108)<101[44)32[114 108 100 33H]87]:111

This does in fact delay the program by one cycle (because the ) can't deblock the inner block on the first cycle of the outer block), but it doesn't affect the program's result.

The final byte is saved with a bit of arithmetic, courtesy of Ørjan Johansen, to compute the 108 from the 114. The actual code to do so is fairly simple: +-6:114. We make a copy of the 114, we negated a 6 and then add them together to get 108. Since -6 is not a negative literal, but a command applied to a 6, this computation takes two cycles. Thankfully, the : delays the 114 as well, so this just works out. We also now need to remove this from the inner block, so that we have enough time for these two cycles to go through before the d! is printed:

72:108)<101[44+-6:114)32[100 33H]87]:111
\$\endgroup\$
  • \$\begingroup\$ Got another byte with arithmetic: Try it online! \$\endgroup\$ – Ørjan Johansen Mar 8 '18 at 9:33
  • \$\begingroup\$ @ØrjanJohansen Oh wow, now it's getting crazy. :D \$\endgroup\$ – Martin Ender Mar 8 '18 at 10:34
7
+250
\$\begingroup\$

Grass, 463 446 bytes

It exits with a crash. Append vw to get a non-crashing version (448 bytes).

wWWWwWWWWwWWWWWwvwwWWwWWWwvWwWwwwwwWWWwWWWwWWWWWwvwWWwwwwwwwwwwwWWWwWWWWWwWWWWwvwWWwwwwwWWWWWWWWWWWWwWWWwvWwwwwwwwwwwwWWwwwwwwWWWWWWWWwWWWWWWWwwWWWWWWwwwwwwwvwWWWWWWWwwwwwwwwwWWWWWWWWWWWWWwWWWwvWwwwwwwwwwwwwwwwwwWWwwwwwwwwwwwwWWWWWWWWWWWWWWWWWwvwWwWwwwwwwwwWwwwwwwWwwwwwwWwwwwwwwWwwwwwwwWwwwwwwwwwwwwwwWWWWWWWWWWWWWWWWWWwvwwWWWWWWWWWWWWWWWWWWWWWWwWWWwwwvWWwWWWWWWWWWWWWWWWWWWWWWwwwwWWwwwwwwwwwWwwwwwwWwwwWwwwwwwwwwWWWWWWWWWWWWwWwwwwwwwwwwwwwwwwww

Try it online!

Based on the TIO example. I think it was from this page by rst76 (613 bytes with lowercase w).

wWWWwWWWWwWWWWWwv                      x -> x + 3
wwWWwWWWwv                             f -> apply f twice (Church numeral 2)
Ww                                     f -> apply f 2**2 = 4 times
Wwwwww                                 x -> x + 4
WWWw                                   x -> x + 8
WWWw                                   x -> x + 32
WWWWWw                                 x -> x + 64
vwWWwwwwwwwwwwwWWWwWWWWWwWWWWw         f -> f(u+2 + 64 + 64 + 32) = f(23)
vwWWwwwwwWWWWWWWWWWWWwWWWwv            f -> f(23 + 8 + 1) = f(32 space)
Wwwwwwwwwwww                           (f->f(32))(x->x+1) = 33 !
WWwwwwww                               (f->f(32))(x->x+8) = 40
WWWWWWWWw                              40 + 4 = 44 ,
WWWWWWWww                              40 + 32 = 72 H
WWWWWWwwwwwww                          (f->f(23))(x->x+64) = 87 U+2
vwWWWWWWWwwwwwwwwwWWWWWWWWWWWWWwWWWwv  f -> f(32 + 64 + 4) = f(100 d)
Wwwwwwwwwwwwwwwwww                     (f->f(100)(x->x+1) = 101 e
WWwwwwwwwwwwww                         (f->f(100)(x->x+8) = 108 l
WWWWWWWWWWWWWWWWWw                     108 + 3 = 111 o
vw                                     begin function
Ww                                       c -> print c; return this function
Wwwwwwwww                                print H
Wwwwwww                                  print e
Wwwwwww                                  print l
Wwwwwwww                                 print l
Wwwwwwww                                 print o
Wwwwwwwwwwwwwww                          print ,
WWWWWWWWWWWWWWWWWWw                      print space
vwwWWWWWWWWWWWWWWWWWWWWWWwWWWwwwv      f = f -> c -> print c; return f(f)
                                       f(f) will return itself as a quine.
WWw                                    Apply the first half of output with
                                         the previous function as argument.
WWWWWWWWWWWWWWWWWWWWWwwww              111 + 3 = 114 r
WWwwwwwwwww                            print U+2
Wwwwwww                                print o
Wwww                                   print r
Wwwwwwwwww                             print l
WWWWWWWWWWWWw                          print d
Wwwwwwwwwwwwwwwwwww                    print !

Generator based on ASCII-only's (too long to post in a comment).

\$\endgroup\$
  • \$\begingroup\$ :| explanation pls \$\endgroup\$ – ASCII-only Apr 28 '18 at 2:39
  • \$\begingroup\$ Or even better, convert to this form if you don't mind \$\endgroup\$ – ASCII-only Apr 28 '18 at 2:43
  • \$\begingroup\$ @ASCII-only Added the link to answer. Not sure it is actually better. \$\endgroup\$ – jimmy23013 Apr 28 '18 at 5:14
  • \$\begingroup\$ Probably not, I just wanted it to add to RosetTIO to make it easier for other people to attempt to golf it (not that anyone will :P) \$\endgroup\$ – ASCII-only Apr 28 '18 at 6:12
6
\$\begingroup\$

APL, 17 bytes

⎕←'Hello, World!'

This is the portable way of printing from a full program.

In the ngn/apl demo, you can omit the ⎕← for 15 bytes.

\$\endgroup\$
6
\$\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\$
  • \$\begingroup\$ Can you add Scrabble scores to the explanation? \$\endgroup\$ – CalculatorFeline Jun 5 '17 at 4:34
  • \$\begingroup\$ The version using valid scrabble words is only 100 bytes longer. \$\endgroup\$ – pppery Aug 2 '17 at 0:44
6
\$\begingroup\$

C++, 48 bytes

(must be compiled with g++)

puts is slightly more concise than std::cout, shaving 6 bytes off of the other c++ answer.

#include<cstdio>
main(){puts("Hello, World!");}
\$\endgroup\$
  • 1
    \$\begingroup\$ With g++, you can eliminate the space on line 1 and the int on line 2. \$\endgroup\$ – Dennis Aug 29 '15 at 3:56
  • \$\begingroup\$ @Dennis, done. I think this is the shortest possible in C++. \$\endgroup\$ – DJMcMayhem Aug 29 '15 at 7:02
  • 2
    \$\begingroup\$ This is not legal C++ code. The return type of main must be int and cannot be empty. \$\endgroup\$ – Hubi Aug 31 '15 at 9:34
  • \$\begingroup\$ @Hubi but it does correctly compile and run if you use g++. \$\endgroup\$ – DJMcMayhem Aug 31 '15 at 15:58
  • 1
    \$\begingroup\$ @DJMcMayhem The fact, that compiler compiles something, does not mean, that it is correct. C++ does not support default int. \$\endgroup\$ – Zereges Oct 25 '15 at 11:20
6
\$\begingroup\$

Mascarpone, 29 bytes

[!dlroW ,olleH]$.............

The esolangs page notes that

from a typical programmer's point of view, it is not obvious how to program in it

In fact, although the language's designer believes it to be Turing complete, and I personally respect his expertise in esoteric languages enough to take it on trust that it's at the very least a non-trivial language, I haven't figured out how to write a loop. So what this does is to push the characters [!dlroW ,olleH] onto the stack (the [] delimiters are necessary, and do for some reason end up on the stack too), pop the ] with $, and then print everything except the [, one character at a time.

\$\endgroup\$
  • 2
    \$\begingroup\$ I know this is way late, but you can loop by having an operation call itself [!dlroW ,olleH]$[/.:!]v*:! \$\endgroup\$ – BlackCap Jul 21 '17 at 14:57
6
\$\begingroup\$

Glava 1.4, 16 bytes

Edit: from Doorknob's and ConorO'Brien's suggestions, the name has changed to Glava.

p("Hello, World!

Glava is a golfing Java dialect (obviously). It adds shorthands to many keywords and common phrases in Java code. So, the code above actually corresponds to the Java code:

System.out.print("Hello World!")

You may be wondering, where does the ") come from? Well, Glava has a feature where it automatically adds closing brackets and double quotes. Also, when a closing curly bracket is needed, it places a semicolon before it.

Another neat feature is that if you do not specify a main class or method, it will do it for you. So the compiled code in the end looks like:

public class Main {public static void main (String[] A) { System.out.print("Hello World!");}}
\$\endgroup\$
  • 1
    \$\begingroup\$ FREAKING FINALLY! Suggestion: Add a piece of code that completes quotes, parens, and } <-- those so you can omit the last four chars. (Maybe a little AIS could help here?) \$\endgroup\$ – Conor O'Brien Jan 3 '16 at 17:46
  • \$\begingroup\$ Java for golf, but there's STILL a freakin' semicolon! \$\endgroup\$ – cat Jan 3 '16 at 18:21
  • \$\begingroup\$ @cat yeah, I know. Me and Conor are trying to figure out how to avoid having to use it. \$\endgroup\$ – GamrCorps Jan 3 '16 at 18:22
  • 3
    \$\begingroup\$ @cat well, Glava 1.2+ supports semicolon insertion before closing curly brackets, so it fixes that problem \$\endgroup\$ – GamrCorps Jan 4 '16 at 16:38
6
\$\begingroup\$

Shtriped, 199 bytes

e n
e b
i b
+ x y
 +
  i x
  d y
  +
 +
 d x
0
 + b b b
1
 + b n n
 0
A
 1
 0
B
 0
 1
1
1
1
A
0
0
B
1
1
A
0
A
0
0
B
1
A
0
B
A
0
B
1
A
A
A
0
0
B
A
A
1
A
B
A
A
1
1
1
A
A
B
1
A
B
1
A
A
1
A
A
A
1
A
B
s n

(Tested in v1.0.0. Does not output trailing newline.)

Shtriped has no strings, only non-negative arbitrary precision integers. But you can print strings by encoding them as integers.

The integer that encodes Hello, World is 46758282851806618588827407. Every two digits essentially encodes one character in offset ASCII order, 82 is l, 85 is o, etc. The program basically declares the variable n to 0, and increments it one by one until it is 46758282851806618588827407, then prints it as a string. (In Shtriped, any integer larger than 0 needs to be incremented one by one to get there.)

Incrementing that high is obviously impossible in any reasonable amount of time, (a 3Ghz processor could maybe do it in 500 million years) so don't run this program, you will never see it finish! However, I am certain that it would finish, it if had the time. It should never run out of memory or have a stack overflow thanks to tail recursion optimization.

To explain what's really happening, here's a nearly identical program that will finish in a few seconds, outputting Hel. Everything is the same except the large column of 01AB's above the last line.

e n \ declare n to 0, this is the variable that will be incremented to that huge number 
e b \ declare b to 0, this is the binary place value that will keep getting doubled
i b \ increment b, making it 1

+ x y \ define a function called "+" that returns x + y
 +    \ define a nested function also called "+"
  i x \ increment x
  d y \ decrement y unless y is 0, in that case return the last statement's value
  +   \ recursively call self
 +    \ call nested "+"
 d x  \ decrement (and return) x, since we will have over counted by 1

0 \ define a function called "0" that adds b to itself, doubling it
 + b b b
1 \ define a function called "1" that adds b to n, then calls 0
 + b n n
 0

\ at this point we could set n to be any number by calling 0 and 1
\ according to the desired number's reversed binary representation
\ but these A and B helper functions help golf that part
A \ calls 1 then 0
 1
 0
B \ calls 0 then 1
 0
 1

\ call functions 0 1 A B to increment n to the desired number
B
1
1
1
1
A
0
A
0
0
A
B
1
1
\ expanding the B's and A's, this becomes 0111111001000100111
\ which reverses to 1110010001001111110 in binary
\ which is 467582 in decimal
\ which is the encoding of the string "Hel"

s n \ finally, print n as a string

Note that I'm very doubtful this answer is optimal for Shtriped. Printing each character of Hello, World! or some combinations of its substrings could be much shorter, but doing that would require lots of trial and error and mathematical calisthenics (or at least a better golfer). For now, I like this elegant, if suboptimal solution.

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

Brain-Flak, 180, 176, 170 + 3 = 173 bytes

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

Try it online!

This code is 170 bytes long, but adds three bytes for the -A flag, which is required to force brain-flak to input and output in ASCII. One little detail is that this also requires the -r flag, but it did not when I first wrote this answer, so I am not adding one byte for it.

I'd post a detailed explanation, but this language hurts my brain...

Thanks to @Wheatwizard for saving 4 10 bytes!


Crossed out 4 is still regular 4... :(

\$\endgroup\$
  • 1
    \$\begingroup\$ You can save two bytes by moving the last 3 in the first push portion to the beginning and popping it for the first 3. (Since that is probably confusing here is a try it online) \$\endgroup\$ – Sriotchilism O'Zaic Sep 6 '16 at 17:49
  • \$\begingroup\$ You can also change ([]){} to [][]. (try it online) \$\endgroup\$ – Sriotchilism O'Zaic Sep 6 '16 at 17:51
  • \$\begingroup\$ @WheatWizard Good tips, thankyou! \$\endgroup\$ – DJMcMayhem Sep 6 '16 at 17:53
  • \$\begingroup\$ You can change (({})){}([])[](){} to (({}))[]{}[][](). (try it online) \$\endgroup\$ – Sriotchilism O'Zaic Sep 6 '16 at 18:11
  • \$\begingroup\$ Ok, two more: try it online \$\endgroup\$ – Sriotchilism O'Zaic Sep 6 '16 at 18:19
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\$
  • \$\begingroup\$ nice work ... I thought it could be done better \$\endgroup\$ – MickyT Sep 4 '15 at 1:01
  • \$\begingroup\$ 608 bytes using (define f (lambda (a b) (char (- (* 6 19) (* a 13) b)))) \$\endgroup\$ – Leaky Nun Aug 23 '17 at 11:00
  • \$\begingroup\$ 604 bytes after golfing Leaky Nun's answer slightly \$\endgroup\$ – Sherlock9 Aug 23 '17 at 13:07
6
\$\begingroup\$

Casio Basic, 15 Bytes

"Hello, World!"

I think it explaines itself well enough...

\$\endgroup\$
  • \$\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\$ – NoOneIsHere May 30 '17 at 20:16
  • \$\begingroup\$ Thanks and sorry that I messed up the formatting, I'm not really used to yet... \$\endgroup\$ – ADDB May 30 '17 at 20:17
  • \$\begingroup\$ Perfectly OK! Just use four spaces before code, and a pound sign (#) or two before your header. \$\endgroup\$ – NoOneIsHere May 30 '17 at 20:18
6
\$\begingroup\$

Lost, 56 54 45 bytes

Two bytes saved thanks to @MartinEnder

v<<<<<<<<<<>>>>>>>>>>>
>%?"Hello, WorldvU"-+@

Try it online!

Explanation

This is now a bit outdated, I will try to update soon

Lost is a 2 dimensional language in which the start location and direction are entirely random. As you might imagine it is rather difficult to write deterministic programs in lost. However the language has a couple of design features that allow for deterministic programs to be written.

Here's how this one works:

I'll first give you some information on the operations in Lost that are important here, so you don't have to read the github. I will leave out the more obvious ones.

  • @ exits, but only if the "safety" is off. The safety begins on.

  • % turns the safety off.

  • ? Pops the TOS and jumps if it is non-zero.

  • ! jumps unconditionally.

  • ( pops a value and saves it for later.

Ok now we are read to dive in.

The main code is the following line

"Hello, WorldvU"-+@

This pushes the string Hello, WorldvU, subtracts the U from the v to get a !, and then terminates the program (we assume the safety is off)

However we have to get to this program so we create a line of arrows to catch the randomly moving pointers

v<<<<<<<<<<<<<<<<<<<<
>%"Hello, WorldvU"-+@

We also add a % to turn the safety off once we have corralled the programs. We can now see that the v is in the string to redirect ips that start inside the string.

Now the problem is that some of the programs accumulate junk before we catch them, for example if you start on the 1 you might get a 1, or even worse if you start in the string going west you will get %>@+!(. So we add some code to clear the stack. >?!| should do the trick, and if we use the > from earlier we can save a byte.

v<<<<<<<<<<<<<<<<<<<<<<<
>%?!|"Hello, WorldvU"-+@

Now there is just one problem. If the program starts on ! going north or south, it will jump the stream back to itself and loop forever. To fix this we add a v below the !.

v<<<<<<<<<<<<<<<<<<<<<<<
>%?!|"Hello, WorldvU"-+@
   v

Lastly I reversed some of the upper stream. This just makes the program a little faster, doesn't lose me any bytes so why not.

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