62
\$\begingroup\$

Background

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

Challenge

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

Rules

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

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

var QUESTION_ID=125282,OVERRIDE_USER=0;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+r.match(SCORE_REG)[0],language:r.match(LANG_REG)[0].replace(/<\/?[^>]*>/g,"").trim(),link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/\d+((?=!?$)|(?= Bytes))/i,OVERRIDE_REG=/^Override\s*header:\s*/i;LANG_REG=/^[^,(\n\r\|]+/i
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/Sites/codegolf/all.css?v=617d0685f6f3"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>

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

109 Answers 109

3
\$\begingroup\$

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.

\$\endgroup\$
2
\$\begingroup\$

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.

\$\endgroup\$
2
\$\begingroup\$

PHP, 26

Goodbye Cruel World!<?=!a;
\$\endgroup\$
1
  • 1
    \$\begingroup\$ This doesn't crash. In fact, this only throws a warning which usually are disregarded. Basically, your code is just Goodbye Cruel World! which is incorrect. If you want to crash, do <?x();, which will throw an exception in PHP 7+. \$\endgroup\$ Jun 8 '17 at 21:41
2
\$\begingroup\$

Arcplus, 25 bytes

(p "Goodbye Cruel World!"
\$\endgroup\$
4
  • \$\begingroup\$ The stderr output doesn't contain Goodbye Cruel World as required for the bonus multiplier. \$\endgroup\$
    – L3viathan
    Jun 8 '17 at 15:14
  • \$\begingroup\$ @L3viathan the spec doesn't specify STDERR: but the debug must also contain \$\endgroup\$
    – Mayube
    Jun 8 '17 at 15:17
  • \$\begingroup\$ @L3viathan it doesn't output the exact string though, due to the spaces vs underscores, so I'll change it anyway \$\endgroup\$
    – Mayube
    Jun 8 '17 at 15:18
  • \$\begingroup\$ Yeah, that's what I meant, I didn't complain that it wasn't stderr. \$\endgroup\$
    – L3viathan
    Jun 8 '17 at 15:25
2
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ If you replaced the "{" with a "(", you could have a frowny emoticon as the last line. Would that have the same effect? \$\endgroup\$ Oct 30 '17 at 22:31
  • \$\begingroup\$ @eaglgenes101 No. ( does not define a list, it just groups expressions. \$\endgroup\$ Oct 30 '17 at 22:49
2
\$\begingroup\$

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.

\$\endgroup\$
3
  • \$\begingroup\$ Switch the strings around. "Hello World" should be in STDOUT, and "Goodbye Cruel World!" should be in the error message. (for the bonus challange) \$\endgroup\$
    – Tezra
    Jun 8 '17 at 20:54
  • \$\begingroup\$ Go's print() prints to STDERR, not STDOUT. You have to use fmt for printing to STDOUT. \$\endgroup\$ Jun 10 '17 at 20:40
  • \$\begingroup\$ @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? \$\endgroup\$ Jun 11 '17 at 21:03
2
\$\begingroup\$

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)
\$\endgroup\$
2
  • \$\begingroup\$ you can save (half) a byte by using - on the string instead of / i.e. -"Goodbye crueld World!" \$\endgroup\$ Jun 9 '17 at 15:24
  • \$\begingroup\$ @AlexisAndersen thanks! Today I also learned about a new method in the String class (see updated post) \$\endgroup\$
    – daniero
    Jun 9 '17 at 19:20
2
\$\begingroup\$

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.

\$\endgroup\$
2
\$\begingroup\$

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
\$\endgroup\$
2
\$\begingroup\$

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"
\$\endgroup\$
1
  • \$\begingroup\$ Using a weird bug: ?"Goodbye Cruel World!";? \$\endgroup\$
    – 12Me21
    Mar 3 '18 at 16:14
2
\$\begingroup\$

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)
\$\endgroup\$
2
\$\begingroup\$

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>'
\$\endgroup\$
1
2
\$\begingroup\$

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.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Hello and welcome to the site. It is customary to put separate languages in separate answers. The site may prompt you not to but thats SE's policy not ours. \$\endgroup\$
    – Grain Ghost
    Jun 15 '17 at 1:27
2
\$\begingroup\$

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.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ fail instead of error. \$\endgroup\$
    – nimi
    Jun 8 '17 at 20:53
  • \$\begingroup\$ @nimi Thanks! I didn't know about fail before. \$\endgroup\$
    – Laikoni
    Jun 15 '17 at 15:59
2
\$\begingroup\$

Swift - 50 bytes, 25 points after bonus

print("Hello World!\nGoodbye Cruel World!")
[0][1]
\$\endgroup\$
5
  • \$\begingroup\$ Can you do something like print("Goodbye Cruel World");1/0, instead of using fatalError? \$\endgroup\$ Jun 16 '17 at 16:12
  • \$\begingroup\$ @Riker my understanding was that the good bye had to come after the error \$\endgroup\$
    – Alexander
    Jun 16 '17 at 16:19
  • \$\begingroup\$ @Riker cool, I'll fix it when i get on my computer, thanks \$\endgroup\$
    – Alexander
    Jun 16 '17 at 16:26
  • \$\begingroup\$ @Riker Division by a zero literal is a compile time error \$\endgroup\$
    – Alexander
    Jun 16 '17 at 16:50
  • \$\begingroup\$ Let us continue this discussion in chat. \$\endgroup\$
    – Alexander
    Jun 16 '17 at 17:03
2
\$\begingroup\$

F#, score: 32!

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

Try it online!

\$\endgroup\$
2
\$\begingroup\$

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.

\$\endgroup\$
2
\$\begingroup\$

Kotlin, 88 bytes/2=44 bytes!

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

Try it online!

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

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.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Quick 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 \$\endgroup\$ Aug 21 '19 at 3:00
  • \$\begingroup\$ extra credit for crashing the system, not just a program :) \$\endgroup\$
    – roblogic
    Aug 21 '19 at 3:51
2
\$\begingroup\$

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.
\$\endgroup\$
1
  • \$\begingroup\$ Definitely thank you for the explanation. \$\endgroup\$ Dec 27 '19 at 14:00
2
\$\begingroup\$

BRASCA, 33 29 28 27 bytes

-4 bytes
-2 bytes thanks to Command Master

`!dlroW leurC eybdooG`[o]~o

Try it online!

Explanation

`!dlroW leurC eybdooG`              - Push "Goodbye Cruel World!", reversed
                      [o]           - Output the stack
                         ~o        - Attempt to print a character with codepoint -1, which crashes.
\$\endgroup\$
2
  • 1
    \$\begingroup\$ Wouldn't `!dlroW leurC eybdooG`[o]1-o work and be shorter? \$\endgroup\$ Jan 27 at 12:00
  • 1
    \$\begingroup\$ You can also use ~ instead of 1- \$\endgroup\$ Jan 27 at 12:06
2
\$\begingroup\$

F#, 71 bytes

[<EntryPoint>]
let main a=
  printfn"Goodbye Cruel World!"
  a.[0]|>int

Try it online!

The function main takes an array of strings a and has a return value of integer. The program attempts to get index 0 of the arguments, even though there are no arguments. The |>int converts a.[0] to an int, or otherwise, the program wouldn't compile because the return value has to be int. The boilerplate code [<EntryPoint>] kind of made it necessarily long but you, unfortunately, cannot get rid of it.

\$\endgroup\$
4
  • \$\begingroup\$ Welcome to CGCC! Here is a Try it online! link for your submission which makes it easier for others to test your solution. \$\endgroup\$
    – Laikoni
    Jan 27 at 9:27
  • \$\begingroup\$ I don't now much about F#, but at least the Hello-World Example on TIO runs fine without the [<EntryPoint>] boilerplate, so it might be worth checking out when exactly it is needed. Try it online! \$\endgroup\$
    – Laikoni
    Jan 27 at 9:29
  • 1
    \$\begingroup\$ I just found there is an implicit entry point. Then the whole main is not needed and just printfn"Goodbye Cruel World!";[].[0] would work with the same error: Try it online! \$\endgroup\$
    – Laikoni
    Jan 27 at 9:55
  • \$\begingroup\$ @Laikoni thank you very much! \$\endgroup\$
    – root
    Jan 27 at 13:35
1
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ 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. \$\endgroup\$
    – pipe
    Jun 10 '17 at 13:27
  • \$\begingroup\$ @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. \$\endgroup\$
    – Chris
    Jun 10 '17 at 21:24
1
\$\begingroup\$

Ruby, 38 bytes, score 19!

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

Run with ruby -e

\$\endgroup\$
1
  • 1
    \$\begingroup\$ The output should contain the specified string, and nothing else. -- This prints extra quotes around the string. \$\endgroup\$
    – daniero
    Jun 11 '17 at 2:50
1
\$\begingroup\$

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.

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

Kitanai (28 bytes)

print"Goodbye Cruel World!"z

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

\$\endgroup\$
1
\$\begingroup\$

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!"
\$\endgroup\$
1
\$\begingroup\$

Micro, 24 20.5

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

Previous version, no bonus:

""Goodbye, cruel world"0/
\$\endgroup\$
1
\$\begingroup\$

Pyth -- 38/2 = 19 !

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

Try It

\$\endgroup\$
1
\$\begingroup\$

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.