# 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 • This is so much fun, I can't stop making solutions! – Adám Jun 9 '17 at 12:31 ## 103 Answers # Jelly, 12 bytes “¿µƝɓṭỵae»Ȯ:  Try it online! Explanation: “¿µƝɓṭỵae»Ȯ: Ȯ Print “¿µƝɓṭỵae A string... » Decoded from base-250 : Integer division  As the integer division is a dyad, it will implicitly take the chain's current value as both arguments - which is a string. Crashes because it expects integers. • Welcome to PPCG! – Dennis Jun 8 '17 at 13:56 • Thank you! I've been lurking for a while now but this is the first time I found a challenge that I felt like I could actually solve decently! – scatter Jun 8 '17 at 14:02 • Impressive answer, although nearly all Jelly answers are impressive, both because of the length and the fact that you managed to learn Jelly. – Gryphon Jun 8 '17 at 16:38 • A base-250 encoded string That is both cool an scary that you can do that. X3 – Tezra Jun 8 '17 at 20:39 • This is significantly shorter than the string "Goodbye cruel world!" (20 bytes). Crazy... – Adam Plocher Jun 11 '17 at 2:45 # C, 43 bytes main(){puts(puts("Goodbye Cruel World!"));}  Prints the string and then tries to use the return value as a pointer to another string to be printed, which causes a segmentation fault. Try it online! # C, 42 bytes Thanks to @Ruslan! main(i){i=puts("Goodbye Cruel World!")/0;}  Try it online! Just for fun: C (on 64-bit Linux), 149 bytes Modified from this Hello World -program here. const int main[]={-443987883,440,113408,-1922629632,4149,1358336,84869120,15544,266023168,1869563654,1702453860,1970422560,1461742693,1684828783,33};  Try it online! • I like this approach, but the instructions do say, The answer must be a whole executable program. – Cody Jun 8 '17 at 18:38 • main(i){i=puts("Goodbye Cruel World!")/0;} strips one byte off. – Ruslan Jun 9 '17 at 14:42 • You don't need i. puts("")/0; is a syntactically correct statement. – rici Jun 11 '17 at 14:55 • @rici Yes it is, but it doesn't crash (at least on TIO). – Steadybox Jun 11 '17 at 16:38 • @Steadybox: that's optimization for you. – rici Jun 11 '17 at 18:57 # SOGL, 1525 17 bytes / 2 = 8.5! Q7┌θ/²?‘■←#c℮‘o0n  Explanation: ...‘ push "goodbye cruel world!" ...‘ push "hello world!" o output "Hello World!" 0n attempt to make an array where each line is 0 characters long, making the array required to be infinite, which crashes (OutOfMemoryError)  (Ab)uses the fact that SOGL uses STDERR as a debug output, so in it there is a lot of text, along with the line ∑@22: ["goodbye cruel world!"]  If you piped the STDOUT of the Processing sketch to a file, the "Goodbye Cruel World!" would be there. • Since the challenge mentions "The strings Hello World! and Goodbye Cruel World! are case insensitive, but otherwise should appear exactly as above.", you can golf your code by getting rid of the function █ entirely and just output in all lowercase. – Kevin Cruijssen Aug 23 '18 at 10:08 • @KevinCruijssen oh huh, thanks! – dzaima Aug 23 '18 at 10:45 ## ><>, 25 bytes "!dlroW leurC eybdooG">o<  Basically it adds the string to the stack (Backwards, last in first out) and then does the equivalent of: while(1): pop the stack print the character  When there are no characters left on the stack (The whole string has been printed) popping the stack gives an error • +1. Came to #o<"Goodbye Cruel World!", which is basically the same. – hakr14 Mar 24 '18 at 4:06 # Python 3 | Score: 24.5!23 22! print("Hello World!")+"Goodbye Cruel World!"  Print "Hello World", than use invalid operator '+' on "Goodbye Cruel World!" to the NoneType return element. (cut out \n\r from previous version) Try it online! # Python 3 | Score: 34 30 +print("Goodbye Cruel World!")  Print Goodbye, than do an invalid unary + operation on print result (NoneType) Try it online! • +"Goodbye Cruel World!" is shorter by 3 bytes and outputs a TypeError. – Gábor Fekete Jun 8 '17 at 14:01 • print("Goodbye Cruel World!")/0 is shorter for the second one (3 bytes?) – matsjoyce Jun 8 '17 at 15:39 • @matsjoyce I was afraid that would crash before the print. But since it prints first, I'll just do unary on the print 'result' :3 – Tezra Jun 8 '17 at 15:48 • 2.585e+22 is a pretty big score... you sure you couldn't golf it down more? – tuskiomi Jun 8 '17 at 16:51 • @tuskiomi The '!' means that the final score is modified by the bonus challenge. – Tezra Jun 8 '17 at 16:57 # sed, 32 bytes iGoodbye Cruel World! w/dev/full  i inserts a line, and w writes to a file. /dev/full in this case because all writes to it return ENOSPC ("No space left on device"). It still needs a single line of input to work, though.  echo 1 | sed -f crash.sed
Goodbye, cruel world!
sed: couldn't flush /dev/full: No space left on device

• Didn't even know there exists such a device! – Ruslan Jun 9 '17 at 15:06

## Lua, 31, 30 bytes

a=-print'Goodbye Cruel World!'


first prints out 'Goodbye Cruel World!' and then crashes when trying to add a nil value and 0.

Output:

Goodbye Cruel World!
input:1: attempt to perform arithmetic on a nil value


Credit to GalladeGuy for 1 byte less

• it prints out 'Goodbye Cruel World!' and then crashes though which i just thought it would simply have to crash to be accepted. – eniallator Jun 11 '17 at 17:42
• @Trebuchette The requirement is "Your program must print Goodbye Cruel World! to output, and then crash", the OP did not specify whether or not "output" means stderr, stdout, a messagebox, or any of the above. – Pharap Jun 12 '17 at 0:27
• @Pharap Oh, I see. STDERR only matters if you're going for the bonus. Thanks! – Trebuchette Jun 12 '17 at 6:25
• @Trebuchette Nope. It says "Or, as a bonus twist challenge, print Hello World! and crash with Goodbye Cruel World!". 'crash' does not necissarily imply stderr, 'crash' can also mean (among other things) an exception being thrown. Unless the OP defines it further it's open to interpretation. Also some applications of Lua have no concept of stderr (e.g. Lua embedded as a scripting language for games) and will instead print to a message box or a log file etc. – Pharap Jun 12 '17 at 6:57
• You can save a byte by doing this instead: a=-print"Goodbye Cruel World!" – GalladeGuy Aug 21 '18 at 1:47

# R, 22 20! bytes (44/2) (40/2)

cat("Hello World!")
Goodbye Cruel World!


Try it online!

### Output:

Hello World!

Saved two points thanks to digEmAll

• You can shorten it to 40/2  Try it online! – digEmAll Aug 25 '18 at 12:09

# AWK, 72 bytes, Score 36!

BEGIN{print"Hello World!";print"Goodbye Cruel World!">"/dev/stderr";0/0}


Try it online!

AWK isn't fond of trying to divide by 0.

# CJam, 34 bytes, score 17!

"Goodbye Cruel World!"D>"Hello"ooo


Try it online! (See Debug panel for STDERR)

### Explanation

"Goodbye Cruel World!"              e# Push "Goodbye Cruel World!".
D>            e# Slice after index 13: " World!".
"Hello"o    e# Push "Hello" and print it.
o   e# Print " World!".
o  e# Attempt to print from an empty stack. Crashes.


On TIO, it generates this error message:

"Goodbye Cruel World!"D>"Hello"ooo
^
RuntimeException: The stack is empty
Java exception:
java.lang.RuntimeException: The stack is empty


# C Preprocessor, 27 bytes

#error Goodbye Cruel World!


Output:

fatal error C1189: #error:  Goodbye Cruel World!

• You may be able to shorten it further with just #Goodbye Cruel World! – apricot boy Jun 10 '17 at 23:58
• @apricotboy That would still produce an error but the full error message "goodbye cruel world" isn't output by the compiler (on MSVC at least) – Govind Parmar Jun 19 '17 at 16:02
• @Gorvind Parmar ah. Well it definitely does on gcc: i.imgur.com/qmGnoJv.png – apricot boy Jun 20 '17 at 4:27

# APL (Dyalog), 17.5 bytes

### Without bonus, 20 bytes

Goodbye Cruel World!


Try it online!

Note that the code is unquoted, so APL tries to execute it but World is not defined, causing a VALUE ERROR crash with the offending line of code included in the error message.

### With bonus, 35 ÷ 2 = 17.5 bytes

'Hello World!'
Goodbye Cruel World!


Try it online!

First prints the required string, then crashes like the above program.

### More sofisticated bonus version, 35 ÷ 2 = 17.5 bytes

⍎'Goodbye Cruel',5↓⎕←'Hello World!'


Try it online!

Prints the first string, then drops the first five characters from that (5↓), then concatenates that (,) to a new prefix, and then attempts to execute (⍎) that, causing the same error as above.

• @Cyoce Typo. Thanks – Adám Jun 10 '17 at 22:05

# JS (ES5), 46 / 2 = 23 bytes!

alert("Hello, World!")["Goodbye Cruel World!"]


Alerts Hello, World!, then errors with Uncaught TypeError: Cannot read property 'Goodbye Cruel World!' of undefined

Bash 20.5! 18.5!

I am not going to bash jelly, but I am a little bashful of my bash at bashing out a quick bash script. 18.5 isn't too bad for a non-golfing language. (Note this has to be a script, interactive bash will try to interpret ! as a history lookup)

echo Hello World!
Goodbye\ Cruel\ $_  Returns with error code 127 and: Hello World! bash.sh: line 2: Goodbye Cruel World!: command not found  As requested no "'s... anywhere :). As suggested by apricot boy I now lookup the last argument of the previous command to save 4 bytes. • I tried to beat you … and failed with 21! bytes. :) W=\ World\!;echo Hello$W;"Goodbye Cruel$W" – reitermarkus Jun 10 '17 at 22:10 • You could probably change the second line to Goodbye\ Cruel\ !$, not 100% but pretty sure that !$ is "last word of last command" – apricot boy Jun 11 '17 at 0:03 • But what if an executable named "Goodbye Cruel World!" exists in the PATH? :) – spuck Aug 19 '19 at 17:50 • Verified OK on TIO.run... beats my zsh answer :/ – roblogic Aug 21 '19 at 3:41 # Operation Flashpoint scripting language, 45/2 = 22.5 bytes f={hint"Hello World!";a Goodbye Cruel World!}  Call with: call f;  Output: # TeX, 19! Hello World!#\bye Goodbye Cruel World!  To force TeX to actually produce a dvi/pdf file without manual intervention, compile with -interaction=nonstopmode. It prints Hello World!, throws an error for using # when you're not supposed to and then stops compilation with \bye. However, whatever's after \bye is still output in the error message, so it applies for the bonus. # C#, 116 / 2 = 58 bytes! using System;class P{static void Main(){Console.Write("Hello World!");throw new Exception("Goodbye Cruel World!");}}  Normal version for 94 87 bytes: class P{static void Main(){System.Console.Write("Goodbye Cruel World!");int n=0;n/=n;}}  Saved 7 bytes thanks to @KevinCruijssen. • int n=0;n/=n; is shorter for your first answer. – Kevin Cruijssen Jun 9 '17 at 9:44 • @KevinCruijssen Nice spot, I was having trouble with getting it to compile without division by constant zero error. – TheLethalCoder Jun 9 '17 at 9:46 • Yeah, in Java you can just do int n=1/0;, but apparently that isn't possible in C# (which is actually a good thing for the language, but bad for codegolfing). Btw, why isn't the bonus on at the top? That one is shorter. – Kevin Cruijssen Jun 9 '17 at 10:35 • @KevinCruijssen I wasn't sure if it qualified as it was a bit unclear when I posted my answer, seeing as it has been further clarified I've switched them around. – TheLethalCoder Jun 9 '17 at 10:37 # WinDBG (Windows XP/Vista Local Kernel Debugging), 33 bytes .echo Goodbye Cruel World!;.crash  Warning: This will crash the entire machine, not just the program. Local kernel debugging is only allowed on Windows XP and Vista (but not enabled by default in Vista). The WinDBG dialog on local kernel debugging does't mention any other Windows OS so I assume it can't even be enabled for those. Presumably for other Windows OS's you can attach to a remote machine for kernel debugging, but it's the remote machine that will crash so I don't think this solution counts there. • Local kernel debugging is also supported on Windows 7, and I haven't heard that it's been removed since then (but I may have missed it). – Cody Gray Jun 11 '17 at 13:06 # PowerShell, 26 Bytes 'Goodbye Cruel World!';1/0  I think dividing by 0 is the easiest way to throw an error. # PowerShell, 35/2 = 17.5 Bytes "Hello World!";Goodbye Cruel World!  by TessellatingHeckler, throws the error like so: PS C:\Users\Connor> "Hello World!";Goodbye Cruel World! Hello World! Goodbye : The term 'Goodbye' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:16 + "Hello World!";Goodbye Cruel World!  • Shouldn't it be $w='World!' (with an !)? – gmatht Jun 11 '17 at 2:53
• "Hello World!";Goodbye Cruel World! is 17.5 bytes, throws an exception because Goodbye is not recognized as a command, and the exception message includes the line in full so it matches the regex.. – TessellatingHeckler Jun 11 '17 at 19:21
• Using the same logic as the 17.5b answer, 'Goodbye Cruel World!';x would save two bytes for 24 – Veskah Aug 20 '18 at 23:10

# Fortran (GFortran), 58/2=29 bytes!

PRINT*,'Hello World!'
ERRORSTOP 'Goodbye Cruel World!'
END


Try it online!

## Node.js, Score: 25.5 24.5!

Saved 1 point thanks to ETHproductions

A syntactically correct full program which crashes at runtime because console.log() is not returning a function.

console.log('Hello World!')Goodbye Cruel World!


Try it online!

• Sadly, there is no factorial for 25.5... :(( – Mr. Xcoder Jun 8 '17 at 13:37
• @Mr.Xcoder It is Gamma(26.5), as with Mathematica definition. – user202729 Jun 8 '17 at 15:39
• @user202729 who said Mathematica ain't broken? :))) – Mr. Xcoder Jun 8 '17 at 15:40
• Can you remove the X (and maybe even the newline)? – ETHproductions Jun 8 '17 at 16:58
• @ETHproductions Yes indeed. Thanks! – Arnauld Jun 8 '17 at 17:03

# Aceto, score: 21.5!

yeru
b Ce+
do l"d
GoWorl
"!dl
p"or
HeW
"llo


Prints Hello World!, then crashes with

Traceback (most recent call last):
File "/Users/l3viathan/bin/aceto", line 230, in _plus
self.push(y+x)
TypeError: unsupported operand type(s) for +: 'int' and 'str'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/l3viathan/bin/aceto", line 811, in <module>
A.run()
File "/Users/l3viathan/bin/aceto", line 104, in run
raise e
File "/Users/l3viathan/bin/aceto", line 98, in run
self.step()
File "/Users/l3viathan/bin/aceto", line 152, in step
method(self, cmd)
File "/Users/l3viathan/bin/aceto", line 233, in _plus
raise CodeException(f"Can't add {x!r} to {y!r}")
__main__.CodeException: Can't add 'Goodbye Cruel World' to 0


# Pyth, 28 24 bytes

"GOODBYE CRUEL WORLD!"hY


Prints a string, then tries to get the first element of the empty list.

Try this!

# AHK, 50 / 2 = 25! (non-competing)

Non-competing because an added requirement made the answer invalid. I can't find a way to make it compile, output the text, and crash. Whatever I try fails at least one of those requirements.

Send,Hello World!
OutputDebug,Goodbye Cruel World!


This is the most boring solution I could think of. It doesn't actually crash but that's not technically a requirement. All it has to do is output a message to the debug window. It does that because I tell it to do so.

• This is currently invalid. OP states that the program must crash if the language is capable if that, which AHK is. – internet_user Jun 8 '17 at 16:58
• @pycoder Ah, that was added 40 minutes after I posted. I'll update for the new rule but it'll cost bytes. – Engineer Toast Jun 8 '17 at 17:08

# Japt, 22 bytes

°Oo!dlžW ¤¨C eybºoGw

°Oo!dl&#158;W ¤¨C eybºoGw
Oo                            output
!dl&#158;W ¤¨C eybºoG     the compressed string "!dlroW leurC eybdooG"
w    reversed.
°                              ° transpiles to ++, causing an error; a string can't be incremented


Try it online!

Saved 3 bytes thanks to obarakon and ETHproductions

• You can compress the string using Oc"<string>" and then replace the current string with the compressed version and surrounded by backticks. – Luke Jun 8 '17 at 13:39
• An explanation would be nice. – iFreilicht Jun 9 '17 at 8:39
• @iFreilicht explanation added. – Tom Jun 9 '17 at 9:26

# Jelly, 10.5! bytes

“,ḷṅḳȦ»¹“¿µƝɓṭỵae»+/R


Try it online!

This exploits undefined behavior, using Python strings (strings) instead of Jelly strings (list of 1-char strings). The conversion is done by reducing the Jelly string by addition, and Python's + concatenates two strings, so two strings added together are concatenated Python-wise. Then, it uses the appropriate monad (range) so that Python's int is called on the string, resulting in an error that would always contain Goodbye Cruel World!.

Explanation:

“,ḷṅḳȦ»¹“¿µƝɓṭỵae»+/R Main Link, niladic.
“,ḷṅḳȦ»¹              Print "Hello World!"
“¿µƝɓṭỵae»+/  Convert "Goodbye Cruel World!" to a Python string
R Make a range out of it


# Ruby, 43 42 bytes/2 = 21!

puts"Hello World!"
-"Goodbye cruel World!"


Saved half a byte with the help of Alexis Andersen, by replacing "String"/0 with -"String". This only "works" with Ruby versions lower than 2.3, in which the unary minus method was actually added to the String class!

With Ruby < 2.3:

$ruby -e 'puts"Hello World!";-"Goodbye cruel World!"' Hello World! -e:1:in <main>': undefined method -@' for "Goodbye cruel World!":String (NoMethodError)  With Ruby >= 2.3: $ ruby -e 'puts"Hello World!";"Goodbye cruel World!"/0'
hello world!
-e:1:in <main>': undefined method /' for "Goodbye cruel World!":String (NoMethodError)

• you can save (half) a byte by using - on the string instead of / i.e. -"Goodbye crueld World!" – Alexis Andersen Jun 9 '17 at 15:24
• @AlexisAndersen thanks! Today I also learned about a new method in the String class (see updated post) – daniero Jun 9 '17 at 19:20

# x86-64 Binary Code (with Linux system calls), 43 bytes

## Disassembly:

0:  31 c0                   xor    eax,eax
2:  ff c0                   inc    eax            ; write syscall number = 1
4:  31 ff                   xor    edi,edi
6:  ff c7                   inc    edi            ; stdout file descriptor = 1
8:  48 8d 35 07 00 00 00    lea    rsi,[rip+0x7]  ; load the string at offset 16 into rsi
f:  31 d2                   xor    edx,edx
11: b2 15                   mov    dl,0x15        ; 21 byte string
13: 0f 05                   syscall
15: f4                      hlt
16: 47 6f 6f 64 62 79 65 20 43 72 75 65 6c 20 57 6f 72 6c 64 21 0a .ascii "Goodbye Cruel World!\n"

Note: 0x16 code bytes + 0x15 string bytes = 0x2B = 43 total bytes


This program bundles the data it needs (the string "Goodbye Cruel World!\n") into its own code. It loads a pointer to that string using rip relative addressing, and calls the write syscall directly rather than through a glibc wrapper, so it's entirely position-independent, and we can easily test it by embedding the code into a const string and casting that string to a function pointer. To crash the program, I end it with a hlt instruction, which with ring 0 privileges would silence the processor forever (or at least until the next interrupt comes in), but with ring 3 privileges (typical for user programs) we get a far less dramatic Segmentation Fault.

## Test Program:

#include <stdio.h>

const char code[43] = "\x31\xC0\xFF\xC0\x31\xFF\xFF\xC7\x48\x8D\x35\x07\x00\x00\x00\x31\xD2\xB2\x15\x0F\x05\xF4Goodbye Cruel World!\n";

int main() {
printf("Code bytes: %zi\nNow running the code:\n\n", sizeof(code));
((void(*)())code)();
printf("Failed to crash, now exiting!\n");
return 0;
}


## Output:

Code bytes: 43
Now running the code:

Goodbye Cruel World!
Segmentation fault


Note that the 43 byte code is a complete program as specified by the challenge, not just a function. It doesn't depend on the main function of the test program to function correctly; it would still print the string and crash if loaded and jumped-to by the loader directly.

• Save a few bytes by using push/pop to load registers. For example, the first two instructions can be push 1+pop rax, which is 1 byte shorter. Then, the next two instructions can be replaced with mov edi, eax, which is 2 bytes shorter. The same push/pop trick can be applied to instructions 6 and 7: push 0x15+pop rdx. – Cody Gray Jun 11 '17 at 13:02

# 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.

# Pyth, 38 / 2 = 19 bytes! 36 / 2 = 18 bytes!

"Hello World!"v"Goodbye Cruel World!


Test it online!

Explanations

It prints Hello World!, then try to evaluate Goodbye Cruel World!. It fails doing it, because that string is not a valid code.

The result is:

Hello World!
Traceback (most recent call last):
File "pyth.py", line 760, in <module>
File "<string>", line 4, in <module>
File "/app/macros.py", line 1085, in Pliteral_eval
File "/app/.heroku/python/lib/python3.4/ast.py", line 46, in literal_eval
File "/app/.heroku/python/lib/python3.4/ast.py", line 35, in parse
File "<unknown>", line 1
Goodbye Cruel World!
^
SyntaxError: invalid syntax