63
\$\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\$
27
  • \$\begingroup\$ Comments are not for extended discussion; this conversation has been moved to chat. \$\endgroup\$ – Dennis Jun 8 '17 at 13:41
  • 1
    \$\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
  • 1
    \$\begingroup\$ This is so much fun, I can't stop making solutions! \$\endgroup\$ – Adám Jun 9 '17 at 12:31
  • 1
    \$\begingroup\$ This has a bonus, and thus is code-golf. See here. \$\endgroup\$ – Rɪᴋᴇʀ Jun 15 '17 at 1:52
  • 1
    \$\begingroup\$ @Riker Did you mean to say "is not code-golf"? I think it still is, as the bonus is just an optional, harder version. The bonus modifier is just to make it viable as the preferred solution. My other options are post as separate question (would be closed as a dup), or use a different tag (which, at the end of the day, this is just 2 different difficulty code-golf challenges together, so doing that would defeat the point of the code-golf tag). For any rule, there will always be a good exception (I think this use case counts as one) And no one here seems bothered by it. \$\endgroup\$ – Tezra Jun 16 '17 at 15:47

108 Answers 108

1 2 3
4
0
\$\begingroup\$

Yabasic, 21.5 bytes!

An anonymous function that takes no input, prints "Hello World!", then crashes with error "Goodbye Cruel World!"

?"Hello World!"
Error"Goodbye Cruel World!"

Try it online!

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

Forth (gforth), 26 bytes

." Goodbye Cruel World!" =

Try it online!

Prints output text and then crashes with a stack-underflow when it tries to call equals on an empty stack (assumes stack is empty before code is executed).


Forth (gforth), 28.5! bytes

." Hello World!" s" Goodbye Cruel World!" exception throw

Try it online!

The bonus is actually worse than the basic implementation even after the score modifier, due to the required use of exception and throw to get a custom error message in Forth.

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

Python 3, 33 bytes

print('goodbye cruel world!')

0/0
\$\endgroup\$
4
  • 1
    \$\begingroup\$ I believe you need the ! at the end for it to be valid. \$\endgroup\$ – Οurous Aug 20 '18 at 6:27
  • \$\begingroup\$ oops, thank for reminding me \$\endgroup\$ – AndiChin Aug 20 '18 at 22:31
  • \$\begingroup\$ Why use \n\n0/0 instead of simply ;_? \$\endgroup\$ – Jonathan Frech Aug 20 '18 at 22:41
  • 1
    \$\begingroup\$ This answer is extremely similiar to the example one presented in the question. \$\endgroup\$ – Jonathan Frech Aug 20 '18 at 22:41
0
\$\begingroup\$

Common Lisp, 39 bytes

(format t"Goodbye, cruel world!~%")1/0

I have no real idea of LISP yet, but this should work even without a REPL but with direct eval, I have no way to proof it.

\$\endgroup\$
2
  • \$\begingroup\$ I think TIO's Common Lisp is not a REPL; it works there. \$\endgroup\$ – Jonathan Frech Aug 21 '18 at 13:24
  • \$\begingroup\$ @JonathanFrech fine then, thanks! \$\endgroup\$ – univalence Aug 21 '18 at 13:24
0
\$\begingroup\$

Batch, 29 Bytes

echo Goodbye Cruel World!
|{

Explanation:

echo Goodbye Cruel World!         //Prints out (echoes) "Goodbye Cruel World!"
|{                                //I just typed random stuff here and hoped it would return an error.
\$\endgroup\$
4
  • 1
    \$\begingroup\$ I don't think that's a crash, that's just a command to shutdown the computer \$\endgroup\$ – Jo King Oct 22 '18 at 2:49
  • \$\begingroup\$ A program that crashes the computer would have the same effect (for /p) but I still get your point and will try to rephrase my answer \$\endgroup\$ – MilkyWay90 Oct 22 '18 at 11:35
  • \$\begingroup\$ I take crash to mean the program ending prematurely or as the question phrases it, an unexpected error. The computer turning off when you use the shutdown command is completely expected behaviour... Would it not be easier to do something like set /a 1/0? \$\endgroup\$ – Jo King Oct 22 '18 at 11:40
  • \$\begingroup\$ Oh okay, I'll just put random chars after the echo. \$\endgroup\$ – MilkyWay90 Oct 22 '18 at 11:42
0
\$\begingroup\$

Pepe, 195 191 bytes

Saved 4 bytes thanks to u_ndefined.

 reeEeeeEEErEeEEeEEEEreeereeereeEEeeEeereeEEeeeEereeEEEEeeEreeEEeeEeEREeeEeeeeeReeereeEeeeeEEreeEEEeeEereeEEEeEeEreeEEeeEeEreeEEeEEeeReeereeEeEeEEEreeereeEEEeeEereeEEeEEeereeEEeeEeereeeEeeeeEReeee

Outputs exactly Goodbye Cruel World!RERROR!.

And in the debug log: R # ERROR: R doesn't exist

Try it online!

Pepe, 199 195 bytes

Saved 4 bytes thanks to u_ndefined.

Because the absence of space after the ! annoys me.

reeEeeeEEErEeEEeEEEEreeereeereeEEeeEeereeEEeeeEereeEEEEeeEreeEEeeEeEREeeEeeeeeReeereeEeeeeEEreeEEEeeEereeEEEeEeEreeEEeeEeEreeEEeEEeeReeereeEeEeEEEreeereeEEEeeEereeEEeEEeereeEEeeEeereeeEeeeeEReeeReeee

Try it online!

\$\endgroup\$
2
  • 3
    \$\begingroup\$ Replacing Reeee with R works, and saves you 4 bytes, \$\endgroup\$ – u-ndefined Oct 24 '18 at 8:50
  • \$\begingroup\$ @u_ndefined I've never seen an absolutely serious comment be so hilarious. \$\endgroup\$ – Magic Octopus Urn Oct 24 '18 at 17:41
0
\$\begingroup\$

Julia 1.0, 51 bytes long, score 25.5!

print("Hello World!");error("Goodbye Cruel World!")

Try it online!

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

K4, 21.5

-1"Hello World!";.:`$"Goodbye Cruel World!"

Does not work on variants of K available on TiO, as casting to symbol from string has not yet been implemented

The program prints "Hello, World", then attempts to get the value to which the symbol `Goodbye Cruel World has been set. No value has been set resulting in an error.

q)k)-1"Hello World!";.:`$"Goodbye Cruel World!"
Hello World!
'Goodbye Cruel World!
\$\endgroup\$
0
\$\begingroup\$

Jstx, 22 bytes / 2 = score 11!

₧P4☼♫╗ååÿΔ{îª2╡¬ûÿ~í£▬

Try it online!

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

Python 2, 30 bytes

print"Goodbye Cruel World";1/0

Try it online!

Similar to the Python 3 answer, this prints then tries to evaluate an invalid expression, exiting with a ZeroDivisionError.

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

Emacs Lisp, 55/2=27.5 bytes!

(error(and(princ"Hello World!")"Goodbye Cruel World!"))

Usage:

$ emacs --batch --eval '(error(and(princ"Hello World!")"Goodbye Cruel World!"))'

Output:

Goodbye Cruel World! # to stderr
Hello World! # to stdout, exits with non zero
\$\endgroup\$
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\$
0
\$\begingroup\$

Pip, 19.5 18! (36 bytes/2)

O"Hello";V"Goodbye Cruel".P" World!"

Try it online!

Outputs Hello without a newline; then prints World!, and finally concatenates and tries to evaluate Goodbye Cruel World! as code. This fails because the unary operator ! needs an operand, leading to the error message

Hit end of tokens while parsing expression
Fatal parsing error while evaluating Goodbye Cruel World!
Fatal error during execution, program terminated.
\$\endgroup\$
0
\$\begingroup\$

Underload, 24 bytes

(Goodbye Cruel World!)S*

Try it Online!

(Goodbye Cruel World!)S | Puts "Goodbye Cruel World!" onto the stack, then pops and prints it.
*                       | Tries to concatenate two items of an empty stack.
\$\endgroup\$
0
\$\begingroup\$

Python 3, 33 31

print('Goodbye Cruel World!')
e

very basic

Try it online!

Python 3, 23! 19!

print('Hello World!')
Goodbye Cruel World!

Try it online!

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

Ahead, 36/2 = 18 bytes!

Prints then divides by zero. The error contents contain a copy of the codeboard, so the string Goodbye Cruel World! will appear.

"!dlroW olleH"W/Goodbye Cruel World!

Try it online!

Ahead, 24 bytes

Same but doesn't get the bonus.

"!dlroW leurC eybdooG"W/

Try it online!

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

Batch, 36 bytes

Exits with a CRASH!! (the two trailing newlines must not be removed)

@echo(Goodbye Cruel World!
@call ^


\$\endgroup\$
1 2 3
4

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.