Goodbye Cruel World!

53

7

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>

Tezra

Posted 2017-06-08T13:09:24.210

Reputation: 1 371

Comments are not for extended discussion; this conversation has been moved to chat.

– Dennis – 2017-06-08T13:41:04.233

as a bonus twist challenge, print "Hello World!" and crash with "Goodbye Cruel World!"? – Magic Octopus Urn – 2017-06-08T14:34:54.683

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 – 2017-06-08T14:39:55.717

@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 – 2017-06-08T14:45:42.877

@Tezra okay... java's still really long because of boilerplate – Socratic Phoenix – 2017-06-08T14:46:40.263

@carusocomputing print "Hello World!" to STDOUT and print "Goodbye Cruel World!" to STDERR when you crash – Stephen – 2017-06-08T15:21:13.587

@StephenS I meant explain what a "bonus twist challenge" is, not what he was asking for. – Magic Octopus Urn – 2017-06-08T15:48:55.120

@carusocomputing That is further explained in the rules. For a score bonus, you must print "Hello World!" to output instead, but the debug 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!) – Tezra – 2017-06-08T15:50:11.093

@carusocomputing it is an optional bonus challenge to strive for. – Tezra – 2017-06-08T15:51:44.127

Does it actually have to crash, or can it just output to STDERR? – internet_user – 2017-06-08T16:24:33.920

@pycoder If the language is capable of crashing (Exit code != 'OK'), it needs to crash. Otherwise use the standard 'error report' (STDERR) for the language. – Tezra – 2017-06-08T16:54:09.517

The "output box"? The "debug field"? Are we supposed to guess what IDE you use and use the same one? – Peter Taylor – 2017-06-08T17:07:18.347

@PeterTaylor remnant from previous wording. Use Where ever STDOUT and STDERR go to (or is) in your language. – Tezra – 2017-06-08T17:27:34.063

So you must print "Goodbye Cruel World" to STDERR (possibly along with other text) and then have a nonzero exit code? – CalculatorFeline – 2017-06-08T19:00:39.253

@CalculatorFeline to STDOUT then crash. STDERR only matters if you go for the bonus challenge. (Please use @ Tezra in the chat at the top of the comments for further clarifications) – Tezra – 2017-06-08T19:11:13.263

1This is so much fun, I can't stop making solutions! – Adám – 2017-06-09T12:31:08.260

@Adám Thanks! That is part of my goal with my challenges. To be simple, easy, but fun. ^w^ – Tezra – 2017-06-09T12:38:18.077

Can your program print extra text? – ericw31415 – 2017-06-12T14:00:59.583

@ericw31415 Only if that is part of the error output. – Tezra – 2017-06-12T14:16:14.690

This has a bonus, and thus is code-golf. See here.

– Rɪᴋᴇʀ – 2017-06-15T01:52:42.053

@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. – Tezra – 2017-06-16T15:47:22.233

@Tezra yes, sorry for the typo. And you're right, bonuses are intended to make an alternate solution viable. However, in this case, it's almost always shorter to include the HW part. Printing HW doesn't take as many characters as the goodbye, so it's pretty much guaranteed a bonus solution will be shorter in any given language. – Rɪᴋᴇʀ – 2017-06-16T16:14:21.880

The leaderboard isn't working because of the answer formatting. – 12Me21 – 2018-04-01T00:30:57.017

Related – JayCe – 2018-09-06T17:12:25.063

Does Goodbye Cruel World have to go to STDERR even if Hello World is not included? – Titus – 2018-10-27T03:58:11.743

@Titus It goes to STDOUT (or an equivalent); unless you do the bonus challenge which does require Goodbye Cruel World in the error output. – Tezra – 2018-10-29T12:31:11.950

Answers

36

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.

scatter

Posted 2017-06-08T13:09:24.210

Reputation: 874

7Welcome to PPCG! – Dennis – 2017-06-08T13:56:24.300

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 – 2017-06-08T14:02:49.903

28Impressive answer, although nearly all Jelly answers are impressive, both because of the length and the fact that you managed to learn Jelly. – Gryphon – 2017-06-08T16:38:15.827

4A base-250 encoded string That is both cool an scary that you can do that. X3 – Tezra – 2017-06-08T20:39:36.917

3This is significantly shorter than the string "Goodbye cruel world!" (20 bytes). Crazy... – Adam Plocher – 2017-06-11T02:45:45.107

36

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!

Steadybox

Posted 2017-06-08T13:09:24.210

Reputation: 15 798

I like this approach, but the instructions do say, The answer must be a whole executable program. – Cody – 2017-06-08T18:38:23.777

@Cody Thanks for pointing that out. It's fixed now. – Steadybox – 2017-06-08T18:43:39.643

1main(i){i=puts("Goodbye Cruel World!")/0;} strips one byte off. – Ruslan – 2017-06-09T14:42:08.973

@Ruslan Thanks. I initially had i;f(){i=puts("Goodbye Cruel World!")/0;}, but f(){puts(puts("Goodbye Cruel World!"));} had the same length and was more interesting. It seems that f(i){i=puts("Goodbye Cruel World!")/0;} would have worked too. – Steadybox – 2017-06-09T15:27:40.563

It should be mentioned that the program is required to crash by no mean... – idmean – 2017-06-11T10:04:25.350

1You don't need i. puts("")/0; is a syntactically correct statement. – rici – 2017-06-11T14:55:42.430

1@rici Yes it is, but it doesn't crash (at least on TIO). – Steadybox – 2017-06-11T16:38:14.967

1@Steadybox: that's optimization for you. – rici – 2017-06-11T18:57:45.560

11

SOGL, 15 25 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.

dzaima

Posted 2017-06-08T13:09:24.210

Reputation: 19 048

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 – 2018-08-23T10:08:45.350

@KevinCruijssen oh huh, thanks! – dzaima – 2018-08-23T10:45:49.620

10

><>, 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

AGourd

Posted 2017-06-08T13:09:24.210

Reputation: 271

+1. Came to #o<"Goodbye Cruel World!", which is basically the same. – hakr14 – 2018-03-24T04:06:55.520

9

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!

Tezra

Posted 2017-06-08T13:09:24.210

Reputation: 1 371

+"Goodbye Cruel World!" is shorter by 3 bytes and outputs a TypeError. – Gábor Fekete – 2017-06-08T14:01:35.750

print("Goodbye Cruel World!")/0 is shorter for the second one (3 bytes?) – matsjoyce – 2017-06-08T15:39:40.733

@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 – 2017-06-08T15:48:31.593

272.585e+22 is a pretty big score... you sure you couldn't golf it down more? – tuskiomi – 2017-06-08T16:51:30.973

1@tuskiomi The '!' means that the final score is modified by the bonus challenge. – Tezra – 2017-06-08T16:57:04.200

For the first one, the newline isn't necessary since you can perform addition on the None result from the print and the string, resulting in a crash (unless the error message can't contain "Hello World!" as well). – notjagan – 2017-06-08T17:31:41.643

9

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

eniallator

Posted 2017-06-08T13:09:24.210

Reputation: 343

2it prints out 'Goodbye Cruel World!' and then crashes though which i just thought it would simply have to crash to be accepted. – eniallator – 2017-06-11T17:42:25.230

@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 – 2017-06-12T00:27:37.520

@Pharap Oh, I see. STDERR only matters if you're going for the bonus. Thanks! – Trebuchette – 2017-06-12T06:25:40.763

@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 – 2017-06-12T06:57:53.890

1You can save a byte by doing this instead: a=-print"Goodbye Cruel World!" – GalladeGuy – 2018-08-21T01:47:21.563

Ah yes, very true. Nice catch! :) – eniallator – 2018-08-21T13:26:37.213

9

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

apricot boy

Posted 2017-06-08T13:09:24.210

Reputation: 281

3Didn't even know there exists such a device! – Ruslan – 2017-06-09T15:06:24.717

8

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

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

Try it online!

Output:

Hello World!

Error: object 'Goodbye Cruel World!' not found

Saved two points thanks to digEmAll

rturnbull

Posted 2017-06-08T13:09:24.210

Reputation: 3 689

You can shorten it to 40/2 Try it online!

– digEmAll – 2018-08-25T12:09:38.087

6

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.

Robert Benson

Posted 2017-06-08T13:09:24.210

Reputation: 1 339

6

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
    at net.aditsu.cjam.CJam.pop(CJam.java:75)
    at net.aditsu.cjam.Op1.run(Op1.java:10)
    at net.aditsu.cjam.Block.run(Block.java:304)
    at net.aditsu.cjam.CJam.runCode(CJam.java:210)
    at net.aditsu.cjam.CJam.main(CJam.java:240)

Business Cat

Posted 2017-06-08T13:09:24.210

Reputation: 8 927

6

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.

Adám

Posted 2017-06-08T13:09:24.210

Reputation: 37 779

1@Cyoce Typo. Thanks – Adám – 2017-06-10T22:05:40.657

6

C Preprocessor, 27 bytes

#error Goodbye Cruel World!

Output:

fatal error C1189: #error:  Goodbye Cruel World!

Govind Parmar

Posted 2017-06-08T13:09:24.210

Reputation: 828

1You may be able to shorten it further with just #Goodbye Cruel World! – apricot boy – 2017-06-10T23:58:24.103

@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 – 2017-06-19T16:02:33.933

@Gorvind Parmar ah. Well it definitely does on gcc: http://i.imgur.com/qmGnoJv.png

– apricot boy – 2017-06-20T04:27:48.427

5

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.

gmatht

Posted 2017-06-08T13:09:24.210

Reputation: 676

I tried to beat you … and failed with 21! bytes. :)

W=\ World\!;echo Hello$W;"Goodbye Cruel$W" – reitermarkus – 2017-06-10T22:10:19.940

1You could probably change the second line to Goodbye\ Cruel\ !$, not 100% but pretty sure that !$ is "last word of last command" – apricot boy – 2017-06-11T00:03:49.980

But what if an executable named "Goodbye Cruel World!" exists in the PATH? :) – spuck – 2019-08-19T17:50:22.653

Verified OK on TIO.run... beats my zsh answer :/ – roblogic – 2019-08-21T03:41:27.837

5

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

user70700

Posted 2017-06-08T13:09:24.210

Reputation:

5

Operation Flashpoint scripting language, 45/2 = 22.5 bytes

f={hint"Hello World!";a Goodbye Cruel World!}

Call with:

call f;

Output:

Steadybox

Posted 2017-06-08T13:09:24.210

Reputation: 15 798

4

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!

Arnauld

Posted 2017-06-08T13:09:24.210

Reputation: 111 334

Sadly, there is no factorial for 25.5... :(( – Mr. Xcoder – 2017-06-08T13:37:06.550

@Mr.Xcoder It is Gamma(26.5), as with Mathematica definition. – user202729 – 2017-06-08T15:39:13.823

1@user202729 who said Mathematica ain't broken? :))) – Mr. Xcoder – 2017-06-08T15:40:15.483

Can you remove the X (and maybe even the newline)? – ETHproductions – 2017-06-08T16:58:08.843

@ETHproductions Yes indeed. Thanks! – Arnauld – 2017-06-08T17:03:56.503

will it crash?? – i-- – 2017-06-09T09:26:34.000

@SagarV Yes. It prints Hello Worlds!, throws TypeError: console.log(...) is not a function (you need to expand the debug section of TIO to reveal the error) and halts. Any code that would be added after that would never be executed. – Arnauld – 2017-06-09T10:40:14.657

the error message must also contain Goodbye Cruel World! I don't think TypeError: console.log(...) is not a function satisfy – l4m2 – 2018-03-24T01:41:02.233

The debug sections does contain that phrase though ;) – Shieru Asakoto – 2018-03-24T05:17:23.233

@l4m2 I realize that there's indeed some ambiguity in the challenge about what the error message exactly is. But I believe it is correct according to the 6th rule. – Arnauld – 2018-03-24T08:18:17.177

oo when I run it on explorer console it doesn't print the source code in err – l4m2 – 2018-03-24T09:47:06.723

@l4m2 I've updated the language to Node.js, which is consistently showing the expected behavior. – Arnauld – 2018-03-24T10:31:33.633

4

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!

colsw

Posted 2017-06-08T13:09:24.210

Reputation: 3 195

Shouldn't it be $w='World!' (with an !)? – gmatht – 2017-06-11T02:53:35.327

"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 – 2017-06-11T19:21:52.370

1Using the same logic as the 17.5b answer, 'Goodbye Cruel World!';x would save two bytes for 24 – Veskah – 2018-08-20T23:10:33.440

4

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.

cp.fe.cp

Posted 2017-06-08T13:09:24.210

Reputation: 141

4

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.

milk

Posted 2017-06-08T13:09:24.210

Reputation: 3 043

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 – 2017-06-11T13:06:58.203

4

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

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

Try it online!

rafa11111

Posted 2017-06-08T13:09:24.210

Reputation: 310

3

Japt, 22 bytes

°Oo`!dlžW ¤¨C eybºoG`w
°Oo`!dl&#158;W ¤¨C eybºoG`w
 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

Tom

Posted 2017-06-08T13:09:24.210

Reputation: 3 078

You can compress the string using Oc"<string>" and then replace the current string with the compressed version and surrounded by backticks. – Luke – 2017-06-08T13:39:28.033

An explanation would be nice. – iFreilicht – 2017-06-09T08:39:40.657

1@iFreilicht explanation added. – Tom – 2017-06-09T09:26:47.143

3

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.

TheLethalCoder

Posted 2017-06-08T13:09:24.210

Reputation: 6 930

int n=0;n/=n; is shorter for your first answer. – Kevin Cruijssen – 2017-06-09T09:44:04.460

@KevinCruijssen Nice spot, I was having trouble with getting it to compile without division by constant zero error. – TheLethalCoder – 2017-06-09T09:46:43.703

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 – 2017-06-09T10:35:03.000

@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 – 2017-06-09T10:37:29.820

3

Haskell, 54 53 bytes, score 27! 26.5!

main=putStr"Hello World!">>fail"Goodbye Cruel World!"

Try it online! Outputs Hello World! and produces the following error message:

.code.tio: user error (Goodbye Cruel World!)

Edit: -1 byte/-0.5 score thanks to @nimi for suggesting fail.

Laikoni

Posted 2017-06-08T13:09:24.210

Reputation: 23 676

1fail instead of error. – nimi – 2017-06-08T20:53:12.810

@nimi Thanks! I didn't know about fail before. – Laikoni – 2017-06-15T15:59:39.080

3

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

L3viathan

Posted 2017-06-08T13:09:24.210

Reputation: 3 151

3

Pyth, 28 24 bytes

"GOODBYE CRUEL WORLD!"hY

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

Try this!

KarlKastor

Posted 2017-06-08T13:09:24.210

Reputation: 2 352

3

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.

Engineer Toast

Posted 2017-06-08T13:09:24.210

Reputation: 5 769

This is currently invalid. OP states that the program must crash if the language is capable if that, which AHK is. – internet_user – 2017-06-08T16:58:29.903

@pycoder Ah, that was added 40 minutes after I posted. I'll update for the new rule but it'll cost bytes. – Engineer Toast – 2017-06-08T17:08:30.283

3

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)

daniero

Posted 2017-06-08T13:09:24.210

Reputation: 17 193

you can save (half) a byte by using - on the string instead of / i.e. -"Goodbye crueld World!" – Alexis Andersen – 2017-06-09T15:24:56.177

@AlexisAndersen thanks! Today I also learned about a new method in the String class (see updated post) – daniero – 2017-06-09T19:20:12.510

3

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

Erik the Outgolfer

Posted 2017-06-08T13:09:24.210

Reputation: 38 134

3

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.

Calculating Nut

Posted 2017-06-08T13:09:24.210

Reputation: 51

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 – 2017-06-11T13:02:57.710

3

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.

Curtis Parfitt-Ford

Posted 2017-06-08T13:09:24.210

Reputation: 31

3

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

Jim

Posted 2017-06-08T13:09:24.210

Reputation: 1 442

3

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                   push  $0x1
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";

EDIT: TIO link now works again.

ceilingcat

Posted 2017-06-08T13:09:24.210

Reputation: 5 503

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 – 2018-04-01T02:57:41.377

64 bit multiply fills up rdx:rax – qwr – 2018-04-01T03:22:27.863

3

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!")

H. Rittich

Posted 2017-06-08T13:09:24.210

Reputation: 131

1Welcome to the site! :) – James – 2018-03-24T13:20:03.323

3

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.

Friz64

Posted 2017-06-08T13:09:24.210

Reputation: 31

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 – 2018-08-21T16:27:25.670

3

x86-16 Assembly, IBM PC DOS, 28 bytes

00000000: b409 ba07 01cd 2147 6f6f 6462 7965 2043  ......!Goodbye C
00000010: 7275 656c 2057 6f72 6c64 2124            ruel World!$

Unassembled listing:

B4 09       MOV  AH, 9              ; DOS display string function
BA 0107     MOV  DX, OFFSET BYE     ; load address of message
CD 21       INT  21H                ; print and say goodbye
BYE DB 'Goodbye Cruel World!$'

Explanation

This will first display the string below without terminating the program. It will then continue to execute the subsequent memory contents as random CPU instructions, including jumps to other code, hardware, etc.

This will actually crash DOS to the point that a hard reset (power cycle) of your PC will most likely be required.

640KB

Posted 2017-06-08T13:09:24.210

Reputation: 7 149

2

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.

Stewie Griffin

Posted 2017-06-08T13:09:24.210

Reputation: 43 471

2

PHP, 26

Goodbye Cruel World!<?=!a;

Christoph

Posted 2017-06-08T13:09:24.210

Reputation: 1 489

1This 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 – 2017-06-08T21:41:15.560

2

Arcplus, 25 bytes

(p "Goodbye Cruel World!"

Skidsdev

Posted 2017-06-08T13:09:24.210

Reputation: 9 656

The stderr output doesn't contain Goodbye Cruel World as required for the bonus multiplier. – L3viathan – 2017-06-08T15:14:37.117

@L3viathan the spec doesn't specify STDERR: but the debug must also contain – Skidsdev – 2017-06-08T15:17:09.010

@L3viathan it doesn't output the exact string though, due to the spaces vs underscores, so I'll change it anyway – Skidsdev – 2017-06-08T15:18:03.170

Yeah, that's what I meant, I didn't complain that it wasn't stderr. – L3viathan – 2017-06-08T15:25:00.530

2

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.

Chris

Posted 2017-06-08T13:09:24.210

Reputation: 1 313

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 – 2017-06-10T13:27:58.470

@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 – 2017-06-10T21:24:10.767

2

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.

AniSkywalker

Posted 2017-06-08T13:09:24.210

Reputation: 29

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 – 2017-06-08T20:54:46.773

Go's print() prints to STDERR, not STDOUT. You have to use fmt for printing to STDOUT. – totallyhuman – 2017-06-10T20:40:19.487

@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 – 2017-06-11T21:03:45.993

2

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.

Scott Milner

Posted 2017-06-08T13:09:24.210

Reputation: 1 806

If you replaced the "{" with a "(", you could have a frowny emoticon as the last line. Would that have the same effect? – eaglgenes101 – 2017-10-30T22:31:43.520

@eaglgenes101 No. ( does not define a list, it just groups expressions. – Scott Milner – 2017-10-30T22:49:42.253

2

Alice, 44 40 bytes, score 22 20!

"!dlroW olleH"d&o`Goodbye 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&o`Goodbye Cruel World!Mode: Cardinal
Grid:
                 v
"!dlroW olleH"d&o`Goodbye 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>'

Nitrodon

Posted 2017-06-08T13:09:24.210

Reputation: 9 181

2Crossed out 44 is still a regular 44. ;( – R. Kap – 2017-06-13T00:00:41.723

2

Ruby, 38 bytes, score 19!

p"Hello World";"Goodbye cruel World".q

Run with ruby -e

marmeladze

Posted 2017-06-08T13:09:24.210

Reputation: 227

1The output should contain the specified string, and nothing else. -- This prints extra quotes around the string. – daniero – 2017-06-11T02:50:00.877

2

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

Bharath

Posted 2017-06-08T13:09:24.210

Reputation: 121

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 – 2017-06-09T14:51:00.740

You can remove superfluous whitespace around the =s and newlines after ;s. – Erik the Outgolfer – 2017-06-11T11:14:00.437

2

Swift - 50 bytes, 25 points after bonus

print("Hello World!\nGoodbye Cruel World!")
[0][1]

Alexander - Reinstate Monica

Posted 2017-06-08T13:09:24.210

Reputation: 481

Can you do something like print("Goodbye Cruel World");1/0, instead of using fatalError? – Rɪᴋᴇʀ – 2017-06-16T16:12:57.243

@Riker my understanding was that the good bye had to come after the error – Alexander - Reinstate Monica – 2017-06-16T16:19:11.890

@Riker cool, I'll fix it when i get on my computer, thanks – Alexander - Reinstate Monica – 2017-06-16T16:26:06.327

@Riker Division by a zero literal is a compile time error – Alexander - Reinstate Monica – 2017-06-16T16:50:39.770

Let us continue this discussion in chat.

– Alexander - Reinstate Monica – 2017-06-16T17:03:06.443

2

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.

eaglgenes101

Posted 2017-06-08T13:09:24.210

Reputation: 577

2

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"

snail_

Posted 2017-06-08T13:09:24.210

Reputation: 1 982

Using a weird bug: ?"Goodbye Cruel World!";? – 12Me21 – 2018-03-03T16:14:44.813

2

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)

EndermanAPM

Posted 2017-06-08T13:09:24.210

Reputation: 21

2

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!

alert`Hello World!`['Goodbye Cruel World!']

The same method as OrphanBot, but saves a few bytes with ES6 template strings.

FPCSJames

Posted 2017-06-08T13:09:24.210

Reputation: 21

1Hello 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. – Post Rock Garf Hunter – 2017-06-15T01:27:41.643

2

F#, score: 32!

[<EntryPoint>]printf"Hello World"
failwith"Goodbye Cruel World!"

Try it online!

Ciaran_McCarthy

Posted 2017-06-08T13:09:24.210

Reputation: 689

2

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.

12Me21

Posted 2017-06-08T13:09:24.210

Reputation: 6 110

2

Kotlin, 88 bytes/2=44 bytes!

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

Try it online!

JohnWells

Posted 2017-06-08T13:09:24.210

Reputation: 611

Using @EndermanAPM Error instead of Exception would yield 84/2 or 42. – JohnWells – 2018-04-01T02:05:06.210

2

Assembly (MIPS, SPIM), 97 92 bytes

.data
a: .asciiz "Goodbye Cruel World!"
.text
.globl main
main:
li $2 4
la $4 a
syscall
j $0

Try it online!

Not gonna lie, i haven't touched MIPS in a long time. Plus i'm not familiar with what shortcuts i can use with SPIM, but i'm satisfied.
For those of you not familiar with mips, the dumbed down version: data declares allocated data (obviously) which in our case is the ascii string. Text is our function space, and main is our main method. Interestingly, mips lacks a native output, so we need a system call for this.
li $2 4 means load immediate, or put a number in this register. In this case 4, to the $V0 register. This will tell the system call what it's doing, and 4 roughly means "print text"

la $4 a Next, we load the address of our text into a register so that the system call knows what it's printing.

Then we call syscall our system call.
To break it, i jump to 0 which is essentially a goto. 0 is not a valid target, so it errors. This saves 5 bytes over divide by zero.

Edit: Safe Alternative 112 Bytes.

Try it online!

If you're not fond of a program running until it essentially overflows the stack, this will create an exception and exit safely thereafter. This one does so by trying to read from a misaligned location, which is a few bytes shorter than divide by zero.

Andrew Baumher

Posted 2017-06-08T13:09:24.210

Reputation: 351

1Quick note: jump to 0, aside from causing errors, is an incredibly unexpected behavior - what it does is fail spectacularly. Afaik most emulators for mips will just error and call it a day, though i can't vouch for all of them. If this behavior is too much of a "watch the world burn" i can tone it down to whatever is desired, i guess – Andrew Baumher – 2019-08-21T03:00:30.580

extra credit for crashing the system, not just a program :) – roblogic – 2019-08-21T03:51:48.507

2

Wren, 37 bytes

-System.print("Goodbye Cruel World!")

Try it online!

Explanation

              "Goodbye Cruel World!"  // Define the string "Goodbye Cruel World!"
 System.print(                      ) // Output the string to STDOUT
-                                     // Apply negation upon the returned string
                                      // which is "Hello World". Negation on strings
                              // isn't defined in Wren.

user85052

Posted 2017-06-08T13:09:24.210

Reputation:

Definitely thank you for the explanation. – my pronoun is monicareinstate – 2019-12-27T14:00:09.417

1

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.

Lobachevsky

Posted 2017-06-08T13:09:24.210

Reputation: 151

You can just remove ~×⍴ since the reciprocal of a string gives a DOMAIN ERROR on all APL systems. – Adám – 2017-06-09T12:11:30.230

1

Kitanai (28 bytes)

print"Goodbye Cruel World!"z

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

Sygmei

Posted 2017-06-08T13:09:24.210

Reputation: 1 137

1

Micro, 24 20.5

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

Previous version, no bonus:

""Goodbye, cruel world"0/

raddish0

Posted 2017-06-08T13:09:24.210

Reputation: 91

1

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!"

Trebuchette

Posted 2017-06-08T13:09:24.210

Reputation: 1 692

1

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!");}

Jonas

Posted 2017-06-08T13:09:24.210

Reputation: 177

1

Pyth -- 38/2 = 19 !

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

Try It

Maria

Posted 2017-06-08T13:09:24.210

Reputation: 644

1

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!");
    }
}

tsunko

Posted 2017-06-08T13:09:24.210

Reputation: 11

1

C, 60 bytes

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

Garhoogin

Posted 2017-06-08T13:09:24.210

Reputation: 29

1

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!

Robert S.

Posted 2017-06-08T13:09:24.210

Reputation: 1 253

1

Clean, 64 bytes / 2 = 32 score

-2 thanks to Jo King

import StdEnv
Start=("Hello world!",abort"Goodbye cruel world!")

Try it online!

Prints Hello world!, tries to print the second element of the tuple and aborts with Goodbye cruel world!

Οurous

Posted 2017-06-08T13:09:24.210

Reputation: 7 916

1

PowerShell, 49 bytes

'Goodbye Cruel World!';[Environment]::FailFast(0)

Try it online!

Prints Goodbye Cruel World! and crashes. Uses the .NET built-in FailFast() feature.

Gabriel Mills

Posted 2017-06-08T13:09:24.210

Reputation: 778

Invalid, "Goodbye Cruel World!" must be in the error – ASCII-only – 2019-01-24T03:18:58.407

@ASCII-only Fixed. – Gabriel Mills – 2019-01-24T14:41:15.723

1

JavaScript, 55 bytes, score 27.5!

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

darrylyeo

Posted 2017-06-08T13:09:24.210

Reputation: 6 214

1

JavaScript, 51 bytes, Real Crash

[console.log("Goodbye Cruel World!"),...Array(1e9)]

Lukas

Posted 2017-06-08T13:09:24.210

Reputation: 111

1

Keg, 23 bytes

Basically a port of the ><> answer.

\!dlroW leurC eybdooG{,

Explanation

\!dlroW leurC eybdooG#Push "Goodbye Cruel World!"
{,#                   Forever, pop and output the top of the stack

This halts by popping an empty stack.

Keg, 13 bytes

Without the -rt flag that you can actually try it online.

“⑮I⅍Gc¡“,\!,/

Try it online!

Keg -rt, 14 bytes

(Doesn't work on TIO as Keg needs a pull)

/00,\!,“⑮I⅍Gc¡

Try it online!

Explanation

       “⑮I⅍Gc¡ # Define a space-separated string "Goodble Cruel World"
      ,        # Print it as a character
   ,\!         # Print an exclamation mark
/00            # Perform 0-division, which is an undefined operation

user85052

Posted 2017-06-08T13:09:24.210

Reputation:

14 bytes: /00,\!,“⑮I⅍Gc¡ using -rt – Lyxal – 2019-12-27T22:14:57.777

1

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

roblogic

Posted 2017-06-08T13:09:24.210

Reputation: 554

1

Rust, (83) 41.5! bytes

fn main(){print!("Hello World!");"".bytes().nth(1).expect("Goodbye Cruel World!");}

Try it online!

Rust, 41 bytes

fn main(){print!("Goodbye Cruel World!")}

Try it online!

Elcan

Posted 2017-06-08T13:09:24.210

Reputation: 913

the second one's supposed to crash after it prints Goodbye Cruel World! – Sagittarius – 2019-12-27T05:28:22.033

1

ink, 44! bytes

VAR a="Goodbye Cruel World!"
Hello World!->a

Try it online!

Funnily enough, even though variables created in VAR declarations are usually always available even if the VAR statement is unreachable, this program only "works" if that VAR statement comes before the divert - if it doesn't, it's a syntax error instead.

Sara J

Posted 2017-06-08T13:09:24.210

Reputation: 2 576

1

W, 34 33/2 = 16.5 bytes

s|x@`p"Goodbye Cruel"" World!"P+/

Explanation

"Hello"p                            % Print "Hello" to STDOUT without a newline
                       " World!"P   % Output " World" to STDOUT with a newline
        "Goodbye Cruel"          +  % Join "Goodbye Cruel" with the string
                                  / % Perform division upon strings (which is undefined behavior)
                                    % Join the two different snippets of code into a single snippet

The error message provides the source code for debugging purposes.

user85052

Posted 2017-06-08T13:09:24.210

Reputation:

1

W d, 17 bytes

Weirdly enough, I got the same bytecount when I avoided the bonus!

.≈ò♠┐M*óö↑á☼r↕Qá╠%·

Unpacked:

CD(IdK815Ak]T&:Q>`P/

After string-decompression:

Goodbye Cruel World!"P/

Explanation

"Goodbye Cruel World!"   % Define the string "Goodbye Cruel World!"
                      P  % Output the string to STDOUT with a newline
                       / % Divide 0 by the string, which causes an error.
                         % We can't do 0-division because in W,
                         % 0-division is defined as positive infinity.

user85052

Posted 2017-06-08T13:09:24.210

Reputation:

1

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!

Dion

Posted 2017-06-08T13:09:24.210

Reputation: 35

0

Rexx (Regina), 39/2 37/2 bytes = 19.5!

say Hello World!
-Goodbye Cruel World!

Try it online!

theblitz

Posted 2017-06-08T13:09:24.210

Reputation: 1 201

0

Mathematica, 23! Bytes

Print["Hello World!"]/."Goodbye Cruel World!";

Prints the first string then attempts to use the second string as a replacement rule which it isn't so crashes (throws an error message which is equivalent to a crash in Mathematica).

Output:

Hello World

ReplaceAll::reps: {Goodbye Cruel World!} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. >>

Ian Miller

Posted 2017-06-08T13:09:24.210

Reputation: 727

0

C, 42 bytes

Not shorter than Steadybox's C answer, but more resistant to optimization.

main(){ftw(puts("Goodbye Cruel World!"));}

ftw has a short name and its first parameter is a pointer, so the return value from puts makes it crash.

ugoren

Posted 2017-06-08T13:09:24.210

Reputation: 16 527

0

Batch, 20.5 bytes!

@echo Hello World!
"Goodbye Cruel World!
  • +41 bytes source code
  • -50% bonus

ericw31415

Posted 2017-06-08T13:09:24.210

Reputation: 2 229

0

tcl, 28

error "Goodbye cruel World!"

demo

sergiol

Posted 2017-06-08T13:09:24.210

Reputation: 3 055

3An anonymous user suggested improving the answer by claiming the bonus with set c World;puts Hello\ $c;Goodbye\ Cruel\ $c! – Martin Ender – 2017-06-16T18:30:55.117

0

T-SQL, 22 bytes

[Goodbye Cruel World!]

It tries to execute the nonexistent stored procedure called Goodbye Cruel World! -if there is no SQL Server instance with that dramatic sp-.

WORNG ALL

Posted 2017-06-08T13:09:24.210

Reputation: 61

0

Windows .BAT, Score: 19.5!

echo Hello World!&"Goodbye Cruel World!

Yes it works on my CMD

l4m2

Posted 2017-06-08T13:09:24.210

Reputation: 5 985

0

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!

Taylor Scott

Posted 2017-06-08T13:09:24.210

Reputation: 6 709

0

Java 8, 108 bytes, score 54!

interface M{static void main(String[]a){System.out.print("Hello World!");new Byte("Goodbye Cruel World!");}}

Try it online here.

This solution attempts to create a Byte from the given String and crashes since "Goodbye Cruel World!" cannot be evaluated to an integer value.

Java 8, 93 bytes (no bonus)

interface M{static void main(String[]a){System.out.print("Goodbye Cruel World!");int i=0/0;}}

This is pretty straightforward as well. It crashes upon trying to divide by zero.

Try it online here.

O.O.Balance

Posted 2017-06-08T13:09:24.210

Reputation: 1 499

0

J, 28 Bytes

=:echo'Goodbye cruel world!'

Echoes 'Goodbye cruel world!', and then encounters a syntax error when theres no variable to assign the result (an empty list) to.

Example:

   =:echo'Goodbye cruel world!'
Goodbye cruel world!
|syntax error
|   =:echo'Goodbye cruel world!'

Bolce Bussiere

Posted 2017-06-08T13:09:24.210

Reputation: 970

0

Jstx, 22 bytes / 2 = score 11!

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

Try it online!

Quantum64

Posted 2017-06-08T13:09:24.210

Reputation: 371

0

Python 3, 33 bytes

print('goodbye cruel world!')

0/0

Whalalalalalala CHen

Posted 2017-06-08T13:09:24.210

Reputation: 337

1I believe you need the ! at the end for it to be valid. – Οurous – 2018-08-20T06:27:28.870

oops, thank for reminding me – Whalalalalalala CHen – 2018-08-20T22:31:07.590

Why use \n\n0/0 instead of simply ;_? – Jonathan Frech – 2018-08-20T22:41:13.510

1This answer is extremely similiar to the example one presented in the question. – Jonathan Frech – 2018-08-20T22:41:48.007

0

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.

reffu

Posted 2017-06-08T13:09:24.210

Reputation: 1 361

0

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.

Mega Man

Posted 2017-06-08T13:09:24.210

Reputation: 1 379

I think TIO's Common Lisp is not a REPL; it works there.

– Jonathan Frech – 2018-08-21T13:24:10.113

@JonathanFrech fine then, thanks! – Mega Man – 2018-08-21T13:24:52.470

0

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.

Kevin Cruijssen

Posted 2017-06-08T13:09:24.210

Reputation: 67 575

} exits in an error (non-legacy). Try it online! Also, for legacy .0 causes division by 0 error forcibly. – Magic Octopus Urn – 2018-10-24T17:47:42.713

@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. – Kevin Cruijssen – 2018-10-24T20:44:30.753

.•Uqʒ•’‚¿Þ¡ ÿ ‚ï!’ -> “‚¿bye±ƒuel‚ï“ for -4. There's no in modern 05AB1E, but here's an equal-bytes alternative. – Grimmy – 2019-09-03T13:41:43.883

@Grimy Thanks. Didn't knew cr was a dictionary word. – Kevin Cruijssen – 2019-09-04T06:43:10.827

22/2 is 11, not 11.5. – Grimmy – 2019-09-04T09:09:48.730

1@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. – Kevin Cruijssen – 2019-09-04T09:27:01.800

0

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!

RedClover

Posted 2017-06-08T13:09:24.210

Reputation: 719

3Replacing Reeee with R works, and saves you 4 bytes, – u_ndefined – 2018-10-24T08:50:20.020

@u_ndefined I've never seen an absolutely serious comment be so hilarious. – Magic Octopus Urn – 2018-10-24T17:41:15.287

0

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.

DLosc

Posted 2017-06-08T13:09:24.210

Reputation: 21 213

0

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.

MilkyWay90

Posted 2017-06-08T13:09:24.210

Reputation: 2 264

1I don't think that's a crash, that's just a command to shutdown the computer – Jo King – 2018-10-22T02:49:26.853

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 – MilkyWay90 – 2018-10-22T11:35:51.363

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? – Jo King – 2018-10-22T11:40:28.343

Oh okay, I'll just put random chars after the echo. – MilkyWay90 – 2018-10-22T11:42:03.380

0

Julia 1.0, 51 bytes long, score 25.5!

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

Try it online!

gggg

Posted 2017-06-08T13:09:24.210

Reputation: 1 715

0

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!

Thaufeki

Posted 2017-06-08T13:09:24.210

Reputation: 421

0

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.

Triggernometry

Posted 2017-06-08T13:09:24.210

Reputation: 765

0

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

Jordon Biondo

Posted 2017-06-08T13:09:24.210

Reputation: 1 030

0

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.

recursive

Posted 2017-06-08T13:09:24.210

Reputation: 8 616

0

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

Sagittarius

Posted 2017-06-08T13:09:24.210

Reputation: 169

0

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?

TheOnlyMrCat

Posted 2017-06-08T13:09:24.210

Reputation: 1 079

0

Ruby, 41 bytes / 2 = 20.5 bytes!

"Goodbye Cruel World!"&$><<"Hello World!"

Try it online!

$><< is a very useful method of output for Ruby golfing--syntax around it is very forgiving("Goodbye Cruel World!"&puts"Hello World!" would be a syntax error, for example, rather than the runtime exception we need), and << has medium precedence so we can control when it executes more freely.

histocrat

Posted 2017-06-08T13:09:24.210

Reputation: 20 600

0

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.

Madison Silver

Posted 2017-06-08T13:09:24.210

Reputation: 139

0

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!

snail_

Posted 2017-06-08T13:09:24.210

Reputation: 1 982