| Bytes | Lang | Time | Link |
|---|---|---|---|
| nan | Swift 6 | 250301T190526Z | macOSist |
| 028 | Tcl | 170616T153430Z | sergiol |
| 394 | Bespoke | 250216T113234Z | Josiah W |
| 012 | UiuaSBCS | 240728T054630Z | Europe20 |
| 069 | Pascal | 240727T180000Z | Kai Burg |
| nan | JavaScript | 230622T174108Z | Nikolay |
| 032 | Perl 32 Bytes | 230622T170942Z | Wallace |
| 028 | x8616 machine code | 190122T194034Z | 640KB |
| 356 | KonamiCode | 211112T173059Z | Ginger |
| 105 | Vyxal | 210903T214521Z | emanresu |
| nan | 210226T125147Z | user1006 | |
| 071 | F# | 210127T091001Z | root |
| nan | Python 3 | 210127T172935Z | M Virts |
| 027 | BRASCA | 210127T091953Z | SjoerdPe |
| 023 | Keg | 190820T235209Z | user8505 |
| 014 | 05AB1E | 201210T235949Z | Makonede |
| 036 | Batch | 200426T085956Z | ScriptKi |
| nan | Ahead | 200215T090457Z | snail_ |
| 3331 | Python 3 | 200212T162404Z | Dion |
| 051 | JavaScript | 190819T162640Z | Lukas |
| 017 | W d | 191227T130114Z | user8505 |
| nan | W | 191227T124918Z | user8505 |
| 024 | Underload | 191230T164703Z | Madison |
| nan | Ruby | 191227T215042Z | histocra |
| 037 | Wren | 191227T135033Z | user8505 |
| nan | Pip | 180824T155747Z | DLosc |
| 315 | JavaScript | 190903T124316Z | Sagittar |
| 024 | 33 | 190905T210054Z | TheOnlyM |
| 044 | ink | 190905T193122Z | Sara J |
| nan | 05AB1E legacy | 180821T140201Z | Kevin Cr |
| 018 | Zsh | 190821T032432Z | roblogic |
| nan | x86 and x64_64 machine language on Linux | 180324T034143Z | ceilingc |
| nan | Rust | 190821T074245Z | Elcan |
| 092 | Assembly MIPS | 190821T023608Z | Andrew B |
| 016 | Stax | 190821T000154Z | recursiv |
| nan | Emacs Lisp | 190819T190628Z | Jordon B |
| 030 | Python 2 | 190124T170619Z | Triggern |
| 049 | PowerShell | 181024T220303Z | GMills |
| nan | Jstx | 180401T022326Z | Quantum6 |
| 215 | K4 | 181024T173144Z | Thaufeki |
| 055 | JavaScript | 181025T005014Z | darrylye |
| 051 | Julia 1.0 | 181024T152650Z | gggg |
| 191 | Pepe | 180823T110714Z | RedClove |
| 029 | Batch | 181022T024609Z | MilkyWay |
| 402 | R | 170612T074224Z | rturnbul |
| nan | SOGL | 170608T133758Z | dzaima |
| nan | Rust | 180821T161343Z | Friz64 |
| 030 | Lua | 170608T172754Z | eniallat |
| 039 | Common Lisp | 180821T131014Z | univalen |
| nan | Clean | 180821T035727Z | Οurous |
| 042 | Processing 3 | 180820T225800Z | Robert S |
| 033 | Python 3 | 180820T015325Z | AndiChin |
| 026 | Forth gforth | 180820T122052Z | reffu |
| 108 | Java 8 | 180330T114200Z | O.O.Bala |
| nan | Kotlin | 180401T015235Z | JohnWell |
| 028 | J | 180401T003315Z | Bolce Bu |
| 215 | Yabasic | 180330T014027Z | Taylor R |
| nan | OCaml | 180324T125506Z | H. Ritti |
| 195 | Windows .BAT | 180324T014416Z | l4m2 |
| 245 | Node.js | 170608T133058Z | Arnauld |
| nan | Fortran GFortran | 180324T004109Z | rafa1111 |
| nan | SmileBASIC | 180324T000438Z | 12Me21 |
| 032 | F# | 180323T235601Z | Ciaran_M |
| 022 | TSQL | 170702T021535Z | WORNG AL |
| 025 | Swift 50 bytes | 170609T212715Z | Alexande |
| 265 | Haskell | 170608T134745Z | Laikoni |
| 043 | C | 170608T150547Z | Steadybo |
| 024 | PHP | 170615T011145Z | FPCSJame |
| nan | Operation Flashpoint scripting language | 170614T221912Z | Steadybo |
| 020 | Alice | 170609T034702Z | Nitrodon |
| 205 | Batch | 170612T140611Z | ericw314 |
| 042 | C | 170612T123042Z | ugoren |
| nan | Kotlin | 170612T103659Z | Enderman |
| nan | JavaScript 58 bytes | 170609T122939Z | Bharath |
| 023 | Mathematica | 170612T001754Z | Ian Mill |
| 026 | PowerShell | 170608T165030Z | colsw |
| 195 | Rexx Regina | 170610T200414Z | theblitz |
| 028 | SmileBASIC 3 | 170611T042333Z | snail_ |
| 060 | C | 170611T035351Z | Garhoogi |
| 083 | Java 6 | 170611T025150Z | tsunko |
| nan | 170610T071430Z | gmatht | |
| nan | 170610T235900Z | Maria | |
| nan | JS ES5 | 170610T235606Z | user7070 |
| nan | Pyth | 170610T230421Z | Jim |
| 175 | APL Dyalog | 170609T120916Z | Adá |
| 021 | LOLCODE | 170610T210147Z | Curtis P |
| 066 | C++ | 170610T203154Z | Jonas |
| 205 | Micro | 170609T131657Z | raddish0 |
| nan | Lua | 170610T173045Z | Trebuche |
| 030 | Julia | 170610T052443Z | eaglgene |
| 043 | x8664 Binary Code with Linux system calls | 170610T020626Z | David Zh |
| 027 | C Preprocessor | 170609T213451Z | Govind P |
| 033 | WinDBG Windows XP/Vista Local Kernel Debugging | 170609T194020Z | milk |
| nan | Ruby | 170608T174606Z | daniero |
| 105 | Jelly | 170609T160753Z | Erik the |
| 028 | Kitanai | 170609T123610Z | Sygmei |
| 028 | APL | 170609T110059Z | Lobachev |
| nan | C# | 170608T132858Z | TheLetha |
| 022 | Japt | 170608T132352Z | Tom |
| 038 | Ruby | 170609T052542Z | marmelad |
| 032 | sed | 170609T012752Z | apricot |
| 019 | TeX | 170608T215854Z | cp.fe.cp |
| 076 | Go | 170608T204502Z | AniSkywa |
| 244 | TIBASIC | 170608T212207Z | Scott Mi |
| 012 | Jelly | 170608T134939Z | Christia |
| nan | Perl 5 | 170608T174441Z | Chris |
| nan | 170608T130924Z | Tezra | |
| 024 | Pyth | 170608T155435Z | KarlKast |
| 034 | CJam | 170608T154451Z | Business |
| 072 | AWK | 170608T153625Z | Robert B |
| 025 | Arcplus | 170608T141917Z | Mayube |
| 215 | Aceto | 170608T143307Z | L3viatha |
| 025 | ><> | 170608T133811Z | AGourd |
| 026 | PHP | 170608T132344Z | Christop |
| 028 | Octave | 170608T131413Z | Stewie G |
Swift 6, 56 ÷ 2 = 28 bytes!
print("Hello World!")
fatalError("Goodbye Cruel World!")
...there's literally nothing interesting to say about this.
Swift 6 (no bonus), 34 bytes
[print("Goodbye Cruel World!")][1]
Bespoke, 394 bytes
say it:bye-bye
say it loudly anywhere you go
goodbye,people;you are s-o mean and rud-e-e-e
bye-bye;I m depressed
why,oh god,is this world so cruel
not for a nanosecond I get any O.K moments
get out;u r just bad,an abject mockery
why,oh god,is this world so cruel
one day,I go
I get to obtain petrol,get to obtain lighters
and bur-n-n-n it down til it topples
a blazing inferno,cities go to dust
Prints GooDBye CrueL worLD! and exits with a Stack underflow. error.
UiuaSBCS, Score: 12
⍤"Goodbye Cruel World!"0
⍤ errors if the condition is anything but 1. Here, because it is 0, it throws an error with the message Goodbye Cruel World!.
Pascal, 69 B
Reading from a file that is not in inspection mode constitutes an error (get(output)).
However, it is not guaranteed that this “crashes” the program.
- Processors are allowed to leave errors undetected. If so, there must be an accompanying document stating such error is not detected. Ergo, you need a processor that does recognize a. m. error condition.
- As many errors as possible shall be detected upon construction (≈ compilation) of a program.
The following
programmay or may not be accepted. At least the GPC and FPC compile theprogram, though, but a different processor may rightfully refuse the same code. - Pascal is incapable of crashing, i. e. programmers cannot programmatically change the exit code: The notion of an “exit code” is completely unknown to Pascal. Instead, implementers of processors are free to choose any error reporting mechanism they like. Having said that, the GPC and FPC implementations do print a message to STDERR and change to a non‑zero exit status.
program p(output);begin write('Goodbye Cruel World!');get(output)end.
- Users of the FreePascal Compiler need to insert a compiler directive
{$mode ISO}in front ofprogram, or specify the‑MISOcommand‑line parameter. Otherwise Pascal’s built‑in proceduregetis not defined. - Arguably the error
get(output)causes is easily anticipated by humans, so I am not sure if this meets the definition of a, quote, “unexpected error”.
JavaScript, 51 / 2 = 25.5! 43 / 2 = 21.5!
"Goodbye Cruel World!"(console.log("Hello World!"))
console.log can be changed to alert and ("") to backticks saving 8 bytes (but I'm not sure this is eligible):
"Goodbye Cruel World!"(alert`Hello World!`)
x86-16 machine code, 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 likely crash DOS to the point that a hard reset (power cycle) of your PC will be required.
KonamiCode, 356 bytes
v(^^^^^^^>^)>((>))v(^>^>^)>((>))v(^>^>^)>((>))v(^>>)>((>))v(^^^^^^^^^>^^^^^^^^)>((>))v(^>^^>^)>((>))v(^>>^)>((>))v(^^^>^^)>((>))v(^^^^^^^^^>^^^^^^^^^)>((>))v(^>^>^^^^)>((>))v(^>^>^^^^^^^)>((>))v(^>>^)>((>))v(^>>^^^^^^^^)>((>))v(^^^>^^)>((>))v(^>^>^^^^^^^^^)>((>))v(^>^>^)>((>))v(^>^>^^^^)>((>))v(^>>^^^^^^^^)>((>))v(^>>)>((>))v(^^^>^^^)>(>)L(>)<<>((>))B(>)
Sadly, the fact that we have to encode "Goodbye, cruel world!" makes this very long.
Vyxal, 10.5! bytes
`ƛ⁋Ṗ⊍ Crꜝ∞ ƛ€!`kh\!+←
`...` # Push 'Goodbye Cruel World!' as a compressed string
kh\!+, # Push 'Hello World!', which will be implicitly output even though the program errors.
← # Crash by accessing a nonexistent variable, Vyxal logs the stack on erroring
JavaScript: 24.5!
alert('Hello World!');throw'Goodbye Cruel World!'
If alert does not count as a valid output function, then I will use console.log (3 extra points).
F#, 71 bytes
[<EntryPoint>]
let main a=
printfn"Goodbye Cruel World!"
a.[0]|>int
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.
BRASCA, 33 29 28 27 bytes
-4 bytes
-2 bytes thanks to Command Master
`!dlroW leurC eybdooG`[o]~o
Explanation
`!dlroW leurC eybdooG` - Push "Goodbye Cruel World!", reversed
[o] - Output the stack
~o - Attempt to print a character with codepoint -1, which crashes.
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¡“,\!,/
Keg -rt, 14 bytes
(Doesn't work on TIO as Keg needs a pull)
/00,\!,“⑮I⅍Gc¡
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
Batch, 36 bytes
Exits with a CRASH!! (the two trailing newlines must not be removed)
@echo(Goodbye Cruel World!
@call ^
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!
Ahead, 24 bytes
Same but doesn't get the bonus.
"!dlroW leurC eybdooG"W/
Python 3, 33 31
print('Goodbye Cruel World!')
e
very basic
Python 3, 23! 19!
print('Hello World!')
Goodbye Cruel World!
JavaScript, 51 bytes, Real Crash
[console.log("Goodbye Cruel World!"),...Array(1e9)]
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.
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.
Underload, 24 bytes
(Goodbye Cruel World!)S*
(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.
Ruby, 41 bytes / 2 = 20.5 bytes!
"Goodbye Cruel World!"&$><<"Hello World!"
$><< 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.
Wren, 37 bytes
-System.print("Goodbye Cruel World!")
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.
Pip, 19.5 18! (36 bytes/2)
O"Hello";V"Goodbye Cruel".P" World!"
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.
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
33, 24 bytes
"Goodbye Cruel World!"pd
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?
ink, 44! bytes
VAR a="Goodbye Cruel World!"
Hello World!->a
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.
05AB1E (legacy), score: 13.5 13 11.5 (23 bytes / 2 for bonus)
…Ÿ™‚ï!“‚¿bye±ƒuel‚ï!“.ǝ
-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
Finstead 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.
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
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.
Rust, (83) 41.5! bytes
fn main(){print!("Hello World!");"".bytes().nth(1).expect("Goodbye Cruel World!");}
Rust, 41 bytes
fn main(){print!("Goodbye Cruel World!")}
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
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.
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.
Stax, 16 bytes
ö╞îö~l%♀~K5╓╖]Æ(
It's a compressed string literal, followed by a packed Qe. Q peeks and outputs, and e is eval, which fails.
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
Python 2, 30 bytes
print"Goodbye Cruel World";1/0
Similar to the Python 3 answer, this prints then tries to evaluate an invalid expression, exiting with a ZeroDivisionError.
PowerShell, 49 bytes
'Goodbye Cruel World!';[Environment]::FailFast(0)
Prints Goodbye Cruel World! and crashes. Uses the .NET built-in FailFast() feature.
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!
JavaScript, 55 bytes, score 27.5!
console.log('Hello World!')
throw'Goodbye Cruel World!'
Julia 1.0, 51 bytes long, score 25.5!
print("Hello World!");error("Goodbye Cruel World!")
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
Pepe, 199 195 bytes
Saved 4 bytes thanks to u_ndefined.
Because the absence of space after the ! annoys me.
reeEeeeEEErEeEEeEEEEreeereeereeEEeeEeereeEEeeeEereeEEEEeeEreeEEeeEeEREeeEeeeeeReeereeEeeeeEEreeEEEeeEereeEEEeEeEreeEEeeEeEreeEEeEEeeReeereeEeEeEEEreeereeEEEeeEereeEEeEEeereeEEeeEeereeeEeeeeEReeeReeee
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.
R, 22 20! bytes (44/2) (40/2)
cat("Hello World!")
`Goodbye Cruel World!`
Output:
Hello World!
Error: object 'Goodbye Cruel World!' not found
Saved two points thanks to digEmAll
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.
Rust, 66 bytes / 2 = 33
fn main(){println!("Hello World!");panic!("Goodbye Cruel World!")}
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.
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
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.
Clean, 64 bytes / 2 = 32 score
-2 thanks to Jo King
import StdEnv
Start=("Hello world!",abort"Goodbye cruel world!")
Prints Hello world!, tries to print the second element of the tuple and aborts with Goodbye cruel world!
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!
Python 3, 33 bytes
print('goodbye cruel world!')
0/0
Forth (gforth), 26 bytes
." Goodbye Cruel World!" =
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
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.
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.
Kotlin, 88 bytes/2=44 bytes!
fun main(a:Array<String>){print("Hello World!")
throw Exception("Goodbye Cruel World!")}
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!'
Yabasic, 21.5 bytes!
An anonymous yabasic function that takes no input, prints "Hello World!", then crashes with error "Goodbye Cruel World!"
?"Hello World!"
Error"Goodbye Cruel World!"
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!")
Windows .BAT, Score: 19.5!
echo Hello World!&"Goodbye Cruel World!
Yes it works on my CMD
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!`
Fortran (GFortran), 58/2=29 bytes!
PRINT*,'Hello World!'
ERRORSTOP 'Goodbye Cruel World!'
END
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.
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-.
Swift - 50 bytes, 25 points after bonus
print("Hello World!\nGoodbye Cruel World!")
[0][1]
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.
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.
C, 42 bytes
Thanks to @Ruslan!
main(i){i=puts("Goodbye Cruel World!")/0;}
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};
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.
Operation Flashpoint scripting language, 45/2 = 22.5 bytes
f={hint"Hello World!";a Goodbye Cruel World!}
Call with:
call f;
Output:
Alice, 44 40 bytes, score 22 20!
"!dlroW olleH"d&o`Goodbye Cruel World!é
-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>'
Batch, 20.5 bytes!
@echo Hello World!
"Goodbye Cruel World!
- +41 bytes source code
- -50% bonus
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.
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!")}
Output:
Hello world
Exception in thread "main" java.lang.Error: Goodbye cruel world!
at Simplest_versionKt.main(Simplest version.kt:8)
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
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. >>
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!
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"
C, 60 bytes
puts("Hello, World!");puts("Goodbye, cruel world!");abort();
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!");
}
}
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.
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
Pyth, 38 / 2 = 19 bytes! 36 / 2 = 18 bytes!
"Hello World!"v"Goodbye Cruel World!
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
APL (Dyalog), 17.5 bytes
Without bonus, 20 bytes
Goodbye Cruel World!
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!
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!'
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.
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.
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!");}
Micro, 24 20.5
"Hello, World!":\"Goodbye, cruel world"0/
Previous version, no bonus:
""Goodbye, cruel world"0/
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!"
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.
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.
C Preprocessor, 27 bytes
#error Goodbye Cruel World!
Output:
fatal error C1189: #error: Goodbye Cruel World!
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.
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)
Jelly, 10.5! bytes
“,ḷṅḳȦ»¹“¿µƝɓṭỵae»+/R
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
Kitanai (28 bytes)
print"Goodbye Cruel World!"z
It just prints "Goodbye Cruel World!" then tries to call unknown function z (so it crashes)
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.
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.
Japt, 22 bytes
°Oo`!dlW ¤¨C eybºoG`w
°Oo`!dlžW ¤¨C eybºoG`w
Oo output
`!dlžW ¤¨C eybºoG` the compressed string "!dlroW leurC eybdooG"
w reversed.
° ° transpiles to ++, causing an error; a string can't be incremented
Saved 3 bytes thanks to obarakon and ETHproductions
Ruby, 38 bytes, score 19!
p"Hello World";"Goodbye cruel World".q
Run with ruby -e
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
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.
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.
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.
Jelly, 12 bytes
“¿µƝɓṭỵae»Ȯ:
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.
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.
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)
Python 3 | Score: 34 30
+print("Goodbye Cruel World!")
Print Goodbye, than do an invalid unary + operation on print result (NoneType)
Pyth, 28 24 bytes
"GOODBYE CRUEL WORLD!"hY
Prints a string, then tries to get the first element of the empty list.
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)
AWK, 72 bytes, Score 36!
BEGIN{print"Hello World!";print"Goodbye Cruel World!">"/dev/stderr";0/0}
AWK isn't fond of trying to divide by 0.
Arcplus, 25 bytes
(p "Goodbye Cruel World!"
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
><>, 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
PHP, 26
Goodbye Cruel World!<?=!a;
Octave, 28 bytes
disp"Goodbye Cruel World!"
d
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.
