# Goodbye Cruel World!

## 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> • Comments are not for extended discussion; this conversation has been moved to chat. – Dennis Jun 8 '17 at 13:41 • as a bonus twist challenge, print "Hello World!" and crash with "Goodbye Cruel World!"? – Magic Octopus Urn Jun 8 '17 at 14:34 • 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? – Socratic Phoenix Jun 8 '17 at 14:39 • @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. – Tezra Jun 8 '17 at 14:45 • @Tezra okay... java's still really long because of boilerplate – Socratic Phoenix Jun 8 '17 at 14:46 ## 85 Answers # OCaml, 28.5! (57 Bytes / 2) The OCaml version: print_string"Hello World!";failwith"Goodbye Cruel World!" The output is: Hello World!Fatal error: exception Failure("Goodbye Cruel World!") • Welcome to the site! :) – DJMcMayhem Mar 24 '18 at 13:20 # Rust, 66 bytes / 2 = 33 fn main(){println!("Hello World!");panic!("Goodbye Cruel World!")} Try it online! Prints "Hello World!" and makes the the program panic with message "Goodbye Cruel World!" The panic! macro doesnt need a semicolon because it returns () just like the main function. • Hi and welcome to PPCG! Just a small correction: the panic! macro returns the never type (!), which can be used as any type (including ()) example playground – Herman L Aug 21 '18 at 16:27 # Octave, 28 bytes disp"Goodbye Cruel World!" d Try it online! This displays "Goodbye Cruel World!" in the shortest possible way in Octave (by skipping the parentheses and avoiding a space). The d on the next line is an undefinied variable, so it errors with the message: error: 'd' undefined near line 2 column 1 error: called from .code.tio at line 2 column 1 If it's OK to output: ans = Goodbye Cruel World! then it can be 24 bytes. ## PHP, 26 Goodbye Cruel World!<?=!a; • This doesn't crash. In fact, this only throws a warning which usually are disregarded. Basically, your code is just Goodbye Cruel World! which is incorrect. If you want to crash, do <?x();, which will throw an exception in PHP 7+. – Ismael Miguel Jun 8 '17 at 21:41 # Arcplus, 25 bytes (p "Goodbye Cruel World!" • The stderr output doesn't contain Goodbye Cruel World as required for the bonus multiplier. – L3viathan Jun 8 '17 at 15:14 • @L3viathan the spec doesn't specify STDERR: but the debug must also contain – Skidsdev Jun 8 '17 at 15:17 • @L3viathan it doesn't output the exact string though, due to the spaces vs underscores, so I'll change it anyway – Skidsdev Jun 8 '17 at 15:18 • Yeah, that's what I meant, I didn't complain that it wasn't stderr. – L3viathan Jun 8 '17 at 15:25 # Perl 5, 43/2 = 21.5 bytes! say'Hello World!';die'Goodbye Cruel World!' Pretty straightforward. die just crashes the program with the given error message plus some extra fluff. • Can't remember the exact rule but this program doesn't run without the -E flag, so you need to add at least one byte. – pipe Jun 10 '17 at 13:27 • @pipe The -E flag is allowed on this site without a penalty, since it's arguably the "normal" way of writing a perl one-liner. – Chris Jun 10 '17 at 21:24 # TI-BASIC, 24 bytes (which happens to be 4!) :Disp "GOODBYE CRUEL WORLD! :{ Displays the string, then partially defines a list, causing a syntax error. • If you replaced the "{" with a "(", you could have a frowny emoticon as the last line. Would that have the same effect? – eaglgenes101 Oct 30 '17 at 22:31 • @eaglgenes101 No. ( does not define a list, it just groups expressions. – Scott Milner Oct 30 '17 at 22:49 # Go, 76 bytes, score 38! package main func main(){print("Hello World!");panic("Goodbye Cruel World!")} (Edit: switch strings around). Formatted: package main func main() { print("Hello World!") panic("Goodbye Cruel World!") } No semicolon in formatted version because of the line breaks. https://play.golang.org/p/DM48LwZ_0T Might be able to reduce this with a wizardry int-->string hack, but whatever. • Switch the strings around. "Hello World" should be in STDOUT, and "Goodbye Cruel World!" should be in the error message. (for the bonus challange) – Tezra Jun 8 '17 at 20:54 • Go's print() prints to STDERR, not STDOUT. You have to use fmt for printing to STDOUT. – totallyhuman Jun 10 '17 at 20:40 • @totallyhuman Is that not a compile/runtime configuration? The Go spec only defines it as "prints all arguments; formatting of arguments is implementation-specific" so the Go code itself is correct, no? – AniSkywalker Jun 11 '17 at 21:03 # Ruby, 38 bytes, score 19! p"Hello World";"Goodbye cruel World".q Run with ruby -e • The output should contain the specified string, and nothing else. -- This prints extra quotes around the string. – daniero Jun 11 '17 at 2:50 # Julia, 30 bytes !print("Goodbye Cruel World!") Eagerly prints "Goodbye Cruel World!", then tries to NOT the return value and crashes because performing a NOT on a void value is not defined. # LOLCODE, I CAN HAZ 21 BYTES :Goodbye Cruel World! Simply places an invalid operator in front of the string. You can give it a go online here. # SmileBASIC 3, 28 bytes Tries to call a function named the empty string, which of course doesn't exist. There's probably a better way to make a SB program crash, but this way is only 5 characters, so I'm not complaining. ?"Goodbye Cruel World! CALL" • Using a weird bug: ?"Goodbye Cruel World!";? – 12Me21 Mar 3 '18 at 16:14 # JavaScript 58 bytes , with bonus 58/2 = 29 bytes console.log("Hello World!"); throw "Goodbye Cruel World!" Very Straightforward , I have crashed the program with the "Good Bye Cruel World!" error. EDIT : Thanks to eithed and Erik the OutGolfer , Saved 36 bytes !. Hope this method still works for the challenge • You don't need to assign the message - console.log("Hello World!");throw new Error("Goodbye Cruel World!") will suffice (or even console.log("Hello World!");throw "Goodbye Cruel World!", though the rules are kind of weird for JS on this one) – eithed Jun 9 '17 at 14:51 • You can remove superfluous whitespace around the =s and newlines after ;s. – Erik the Outgolfer Jun 11 '17 at 11:14 # Kotlin, 89/2= 44.5 bytes! Pretty much the same as the java answer fun main(args:Array<String>){ println("Hello world") throw Error("Goodbye cruel world!")} Try it online! Output: Hello world Exception in thread "main" java.lang.Error: Goodbye cruel world! at Simplest_versionKt.main(Simplest version.kt:8) # Alice, 44 40 bytes, score 22 20! "!dlroW olleH"d&oGoodbye Cruel World!é Try it online! -4 bytes by finding an interpreter bug. ### Explanation "!dlroW olleH" push this string (one character at a time) d stack depth &o output that many bytes  print debug information The Alice interpreter is written in Ruby, which can be strict about character encoding. When the debug command attempts to output the é (or any character in the range 0x80-0xFF) at the end of the program, this character is interpreted as ASCII-8BIT instead of UTF8, causing a crash. Mode: Cardinal Grid: v "!dlroW olleH"d&oGoodbye Cruel World!Mode: Cardinal Grid: v "!dlroW olleH"d&oGoodbye Cruel World!/opt/alice/state.rb:234:in write': "\xE9" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError) from /opt/alice/state.rb:234:in <<' from /opt/alice/state.rb:234:in block (2 levels) in print_grid' from /opt/alice/state.rb:234:in each' from /opt/alice/state.rb:234:in block in print_grid' from /opt/alice/state.rb:233:in each' from /opt/alice/state.rb:233:in each_with_index' from /opt/alice/state.rb:233:in print_grid' from /opt/alice/state.rb:221:in print_debug_info' from /opt/alice/interpreter.rb:16:in rescue in <main>' from /opt/alice/interpreter.rb:13:in <main>' • – R. Kap Jun 13 '17 at 0:00 # PHP, 24 bytes <?d'Goodbye Cruel World! Produces: Parse error: syntax error, unexpected ''Goodbye Cruel World!' (T_ENCAPSED_AND_WHITESPACE) in [...][...] on line 1 # JavaScript (ES6), 43 / 2 = 21.5 bytes! alertHello World!`['Goodbye Cruel World!'] The same method as OrphanBot, but saves a few bytes with ES6 template strings. • Hello and welcome to the site. It is customary to put separate languages in separate answers. The site may prompt you not to but thats SE's policy not ours. – Sriotchilism O'Zaic Jun 15 '17 at 1:27 # Swift - 50 bytes, 25 points after bonus print("Hello World!\nGoodbye Cruel World!") [0][1] • Can you do something like print("Goodbye Cruel World");1/0, instead of using fatalError? – Rɪᴋᴇʀ Jun 16 '17 at 16:12 • @Riker my understanding was that the good bye had to come after the error – Alexander Jun 16 '17 at 16:19 • @Riker cool, I'll fix it when i get on my computer, thanks – Alexander Jun 16 '17 at 16:26 • @Riker Division by a zero literal is a compile time error – Alexander Jun 16 '17 at 16:50 • – Alexander Jun 16 '17 at 17:03 # F#, score: 32! [<EntryPoint>]printf"Hello World" failwith"Goodbye Cruel World!" Try it online! # SmileBASIC, 44/2 = 22 bytes! At first I thought there would be no way to get the bonus, since errors in SB only show a specific message along with the line number (ex: IF without THEN in 0:4) But then I remembered that MML (the language used for playing music) gives more detailed error messages, which display the code that caused the error! ?"Hello, World! BGMPLAY"Goodbye Cruel World! Output: Hello, World! Illegal MML in 0:2(BGMPLAY:1) Goodbye Cruel World! ^ Missing number (in Track 0) The error occurs because the o (set octave) command expects a number. # x86 and x64_64 machine language on Linux, 38 61 bytes/2=30.5! 60 bytes/2=30! 00: e8 20 00 00 00 call 0x25 05: 48 65 6c 6c 6f 20 57 "Hello World!Goodbye Cruel World!" 6f 72 6c 64 21 47 6f 6f 64 62 79 65 20 43 72 75 65 6c 20 57 6f 72 6c 64 21 25: 59 pop %ecx 26: 6a 01 push0x1
28:       5b                      pop   %ebx
29:       6a 0c                   push  $0xc 2b: 5a pop %edx 2c: 6a 04 push$0x4
2e:       58                      pop   %eax
2f:       cd 80                   int   $0x80 31: 01 c0 add %eax,%ecx 33: b3 02 mov$0x2,%bl
35:       b2 14                   mov   $0x14,%dl 37: 2c 08 sub$0x8,%al
39:       cd 80                   int   \$0x80
3b:       6e                      outsb  %ds:(%esi),(%dx)

Prints Hello World! to stdout and Goodbye Cruel World! to stderr. Crashing is easy in machine language. To Try it online!, compile and run the following C program.

const char main[]="\xe8 \0\0\0Hello World!Goodbye Cruel World!Yj\1[j\fZj\4X\xcd\x80\1\xc1\xb3\2\xb2\24,\b\xcd\x80n";
• Since a 64 bit number can represent 8 chars, I wonder if it is possible to construct the string using some clever arithmetic and shifting. Specifically 47 6f 6f 64 62 79 65 20 43 72 75 65 6c 20 57 6f 72 6c 64 21. – qwr Apr 1 '18 at 2:57
• 64 bit multiply fills up rdx:rax – qwr Apr 1 '18 at 3:22

# Kotlin, 88 bytes/2=44 bytes!

fun main(a:Array<String>){print("Hello World!")
throw Exception("Goodbye Cruel World!")}

Try it online!

• Using @EndermanAPM Error instead of Exception would yield 84/2 or 42. – JohnWells Apr 1 '18 at 2:05

## APL, 28

÷~×⍴⎕←'Goodbye Cruel World!'

This first displays the text, then tries to take the reciprocal ÷ of the not ~ of the sign × (an integer 1) of the length ⍴ of the text. As the sign of the length will always be 1, the not of which is 0, the reciprocal will produce a DOMAIN ERROR.

In all fairness, ngn\apl does not crash, rather will output infinity. Nearly all other (legacy) APLs such as Dyalog, APL2000, and IBM APL2, do not handle NaNs or +/-Inf and will crash as expected.

• You can just remove ~×⍴ since the reciprocal of a string gives a DOMAIN ERROR on all APL systems. – Adám Jun 9 '17 at 12:11

# Kitanai (28 bytes)

print"Goodbye Cruel World!"z

It just prints "Goodbye Cruel World!" then tries to call unknown function z (so it crashes)

# Lua, 47 / 2 == 23 bytes

Prints "Hello World!" to STDOUT, then crashes with "Goodbye cruel world!" and a stack trace to SDTERR.

print"Hello World!"
error"Goodbye cruel world!"

# Micro, 24 20.5

"Hello, World!":\"Goodbye, cruel world"0/

Previous version, no bonus:

""Goodbye, cruel world"0/

## C++, 66 bytes

Compiles with VS 2017. A little type confusion for the crash.

extern"C"{int puts(void*);int main=puts("Goodbye Cruel World!");}

# Pyth -- 38/2 = 19 !

K" World!"p"Hello"Kp"Goodbye Cruel"KsG

Try It

# Java 6, 83 bytes, Score 41.5!

Java 6 loaded static initializers before searching for the main method, making it possible to bypass the lengthy main signature. However, past 6, it first looks for the main method and then static initializers, making this solution void.

class A{static{System.out.print("Hello World!");new Long("Goodbye Cruel World!");}}

Expanded:

class A {
static {
System.out.print("Hello World!");
new Long("Goodbye Cruel World!");
}
}

C, 60 bytes

puts("Hello, World!");puts("Goodbye, cruel world!");abort();

# Processing 3, 42 bytes

println("Goodbye Cruel World!");int b=1/0;

First try at using Processing for a golfing challenge. Couldn't figure out a way for the bonus challenge since Processing is very good at finding errors before you run your code!