49
\$\begingroup\$

Background

Hello golfers! I would like to learn all the programming languages! But I kinda have a short attention span... and copying all the Hello World examples gets boring... but I like fire! ^w^

Challenge

So here is the plan! I want you all to write the smallest code that will compile, print Goodbye Cruel World!, and then crash. Or, as a bonus twist challenge, print Hello World! and crash with Goodbye Cruel World!

Rules

  • Your score will be total character count used. The answer must be a whole executable program.
  • Your program must print Goodbye Cruel World! to output, and then crash (unexpected error).
    • For a score bonus, you must print Hello World! to output instead, but the error message must also contain Goodbye Cruel World!. If you complete the bonus challenge, you may divide your score by 2. (Include a ! at the end of your score if you are claiming the bonus!)
  • As long as the standard output still prints, and standard error still prints, the order doesn't matter. Just as long as neither can block the other from happening.
  • The output must contain the contents of the above; " shouldn't appear in the output.
  • The output should contain the specified string, and nothing else.
  • The crash report can contain anything, but to claim the bonus, the following regex should match /Goodbye Cruel World!/mi (aka, contains, ignore case/surrounding text))
  • The strings Hello World! and Goodbye Cruel World! are case insensitive, but otherwise should appear exactly as above.
  • If the language is capable of crashing (it cannot change its exit code), it needs to crash. Otherwise use the standard "error report" (i.e., STDERR) for the language.

I can crash Python 3, so I have included an example Python 3 answer! Now lets all set the world on fire! ^W^

var QUESTION_ID=125282,OVERRIDE_USER=0;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+r.match(SCORE_REG)[0],language:r.match(LANG_REG)[0].replace(/<\/?[^>]*>/g,"").trim(),link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/\d+((?=!?$)|(?= Bytes))/i,OVERRIDE_REG=/^Override\s*header:\s*/i;LANG_REG=/^[^,(\n\r\|]+/i
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}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="//cdn.sstatic.net/Sites/codegolf/all.css?v=617d0685f6f3"> <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><div id="language-list"> <h2>Winners 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><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\$
  • \$\begingroup\$ Comments are not for extended discussion; this conversation has been moved to chat. \$\endgroup\$ – Dennis Jun 8 '17 at 13:41
  • \$\begingroup\$ as a bonus twist challenge, print "Hello World!" and crash with "Goodbye Cruel World!"? \$\endgroup\$ – Magic Octopus Urn Jun 8 '17 at 14:34
  • \$\begingroup\$ Suppose I'm working in a language like Java, where STDOUT and STDERR are, of course, printed in different threads. This means that, although the program, in order, prints "Hello world" and then crashes, it is possible that the stack trace will be printed first... Is that allowed? \$\endgroup\$ – Socratic Phoenix Jun 8 '17 at 14:39
  • \$\begingroup\$ @SocraticPhoenix As long as STDOUT still prints, and STDERR still prints, the order doesn't matter. Just as long as neither can block the other from happening. \$\endgroup\$ – Tezra Jun 8 '17 at 14:45
  • 1
    \$\begingroup\$ This is so much fun, I can't stop making solutions! \$\endgroup\$ – Adám Jun 9 '17 at 12:31

95 Answers 95

0
\$\begingroup\$

Stax, 16 bytes

ö╞îö~l%♀~K5╓╖]Æ(

Run and debug it

It's a compressed string literal, followed by a packed Qe. Q peeks and outputs, and e is eval, which fails.

\$\endgroup\$
0
\$\begingroup\$

Zsh, 18!

36/2 bytes, including hello world! for extra credit. Try it online!

echo hello world!
goodbye\ cruel\ $_

NB: The identifier $_ doesn't work with <<< because <<< runs in a sub-shell. Example

\$\endgroup\$
0
\$\begingroup\$

05AB1E (legacy), score: 13.5 13 11.5 (23 bytes / 2 for bonus)

…Ÿ™‚ï!“‚¿bye±ƒuel‚ï!“.ǝ

Try it online.

-1.5 (-3 bytes) thanks to @Grimy.

Outputs in full lowercase.

05AB1E (legacy) is unable to exit with an error as far as I know (unless there is a bug in its source code), so instead this will print hello world! to STDOUT and goodbye cruel world! to STDERR.

Explanation:

…                 # Three lowercase dictionary-compressed words with space delimiter
 Ÿ™               #  "hello"
   ‚ï             #  "world"
     !            #  Literal "!"
“             “   # Push dictionary string in lowercase with automatic space-delimiter:
 ‚¿bye±ƒuel‚ï!    #  "goodbye cruel world!"
               .ǝ # Print to STDERR
                  # And print the top of the stack to STDOUT implicitly

See this 05AB1E this of mine (section How to use the dictionary?) to understand why …Ÿ™‚ï! is hello world! and “‚¿bye±ƒuel‚ï!“ is goodbye cruel world!.


05AB1E, score: 11.5 (23 bytes / 2 for bonus)

…Ÿ™‚ï!,“‚¿bye±ƒuel‚ï!“F

Unlike the legacy version, the new version is able to error out sometimes. The difference between the above program are:

  • The ,, which is an explicit print with trailing newline
  • And F instead of , which is a ranged loop and will error because the "goodbye cruel world!" is not an integer:

(RuntimeError) Could not convert goodbye cruel world! to integer.

\$\endgroup\$
  • \$\begingroup\$ } exits in an error (non-legacy). Try it online! Also, for legacy .0 causes division by 0 error forcibly. \$\endgroup\$ – Magic Octopus Urn Oct 24 '18 at 17:47
  • \$\begingroup\$ @MagicOctopusUrn Ah, completely forgot about .0, since the commands had already changed when I posted this and it's not in the new version anymore. As for the errors in the Elixir rewrite, it can crash with quite a few different ways now, but mostly due to a bug that wasn't in the legacy version yet, so usually I report it in the 05AB1E chat to Adnan. \$\endgroup\$ – Kevin Cruijssen Oct 24 '18 at 20:44
  • \$\begingroup\$ .•Uqʒ•’‚¿Þ¡ ÿ ‚ï!’ -> “‚¿bye±ƒuel‚ï“ for -4. There's no in modern 05AB1E, but here's an equal-bytes alternative. \$\endgroup\$ – Grimmy Sep 3 at 13:41
  • \$\begingroup\$ @Grimy Thanks. Didn't knew cr was a dictionary word. \$\endgroup\$ – Kevin Cruijssen Sep 4 at 6:43
  • 1
    \$\begingroup\$ @Grimy Woops, should have been 23 instead of 22.. Your versions were missing the exclamation mark in the goodbye cruel world!. I've updated the 11 to 11.5 when I noticed that, but forgot to update the 22. \$\endgroup\$ – Kevin Cruijssen Sep 4 at 9:27
0
\$\begingroup\$

33, 24 bytes

"Goodbye Cruel World!"pd

Try it online!

Simple case. Prints Goodbye Cruel World! then crashes with a floating-point exception caused by the d instruction, which tries to divide 0 by 0. I could just put a character in that 33 doesn't recognise, but where's the fun in that?

\$\endgroup\$
0
\$\begingroup\$

JavaScript, 31.5! (does this count?)

(c=console).log("Hello World!");c.error("Goodbye Cruel World!")

Output:

Hello World!          //is printed to stdout
Goodbye Cruel World!  //is printed to stderr
undefined

JavaScript, 37

console.log("Goodbye Cruel World!")=0

Output:

Goodbye Cruel World!
ReferenceError: Invalid left-hand side in assignment
\$\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.