title: Goodbye Cruel World!

text:
# Question
Title: Goodbye Cruel World!
## Background

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

## Challenge

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

## Rules

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

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

```
var QUESTION_ID=125282,OVERRIDE_USER=0;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+r.match(SCORE_REG)[0],language:r.match(LANG_REG)[0].replace(/<\/?[^>]*>/g,"").trim(),link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/\d+((?=!?$)|(?= Bytes))/i,OVERRIDE_REG=/^Override\s*header:\s*/i;LANG_REG=/^[^,(\n\r\|]+/i
```

```
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
```

```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/Sites/codegolf/all.css?v=617d0685f6f3"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>
```

# Answer
> 37 votes
# 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!

# Answer
> 36 votes
# 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.

# Answer
> 11 votes
# 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

```

# Answer
> 11 votes
# 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

# Answer
> 10 votes
# 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!

# Answer
> 10 votes
# 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.

# Answer
> 10 votes
## \>\<\>, 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

# Answer
> 9 votes
## 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*

# Answer
> 7 votes
# C Preprocessor, 27 bytes

```
#error Goodbye Cruel World!

```

Output:

```
fatal error C1189: #error:  Goodbye Cruel World!

```

# Answer
> 7 votes
# Operation Flashpoint scripting language, 45/2 = 22.5 bytes

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

```

**Call with:**

```
call f;

```

**Output:**

# Answer
> 6 votes
# 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.

# Answer
> 5 votes
# 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.*

# Answer
> 5 votes
# 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)

```

# Answer
> 5 votes
# 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.

# Answer
> 4 votes
## 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!

# Answer
> 4 votes
# 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!

```

# Answer
> 4 votes
# 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.

# Answer
> 4 votes
# 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.

# Answer
> 4 votes
**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.

# Answer
> 4 votes
# 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`

# Answer
> 4 votes
# Fortran (GFortran), 58/2=29 bytes!

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

```

Try it online!

# Answer
> 3 votes
# Japt, 22 bytes

```
°Oo`!dlžW ¤¨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

```

Try it online!

Saved 3 bytes thanks to obarakon and ETHproductions

# Answer
> 3 votes
# 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

```

# Answer
> 3 votes
# Pyth, ~~28~~ 24 bytes

```
"GOODBYE CRUEL WORLD!"hY

```

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

Try this!

# Answer
> 3 votes
# 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

```

# Answer
> 3 votes
# 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.

# Answer
> 3 votes
# 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.

# Answer
> 3 votes
# 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.

# Answer
> 3 votes
# 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!")

```

# Answer
> 3 votes
# 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.

# Answer
> 3 votes
# 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.

# Answer
> 2 votes
# 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.

# Answer
> 2 votes
## PHP, 26

```
Goodbye Cruel World!<?=!a;

```

# Answer
> 2 votes
# 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`.

# Answer
> 2 votes
# Arcplus, 25 bytes

```
(p "Goodbye Cruel World!"

```

# Answer
> 2 votes
# 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)

```

# Answer
> 2 votes
# 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.

# Answer
> 2 votes
# TI-BASIC, 24 bytes <sub><sub>(which happens to be *4!*)</sub></sub>

```
:Disp "GOODBYE CRUEL WORLD!
:{

```

Displays the string, then partially defines a list, causing a syntax error.

# Answer
> 2 votes
# 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>'

```

# Answer
> 2 votes
# Swift - 50 bytes, 25 points after bonus

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

```

# Answer
> 2 votes
# 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.

# Answer
> 2 votes
# 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

```

# Answer
> 2 votes
# 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"

```

# Answer
> 2 votes
# 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)

```

# Answer
> 2 votes
# 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.

# Answer
> 2 votes
# F#, score: 32!

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

```

Try it online!

# Answer
> 2 votes
# 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.

# Answer
> 2 votes
# Kotlin, 88 bytes/2=44 bytes!

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

```

Try it online!

# Answer
> 2 votes
# 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.

# Answer
> 2 votes
# 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.

```

# Answer
> 2 votes
# 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.

# Answer
> 2 votes
# BRASCA, ~~33~~ ~~29~~ ~~28~~ 27 bytes

<sup>-4 bytes</sup>
<sup>-2 bytes thanks to Command Master</sup>

```
`!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.

```

# Answer
> 1 votes
# 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.

# Answer
> 1 votes
# **Ruby, 38 bytes, score 19!**

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

```

Run with `ruby -e`

# Answer
> 1 votes
## **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.

# Answer
> 1 votes
# 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

# Answer
> 1 votes
# Kitanai (28 bytes)

`print"Goodbye Cruel World!"z`

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

# Answer
> 1 votes
# Micro, ~~24~~ 20.5

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

```

Previous version, no bonus:

```
""Goodbye, cruel world"0/

```

# Answer
> 1 votes
# 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!"

```

# Answer
> 1 votes
# Pyth -- 38/2 = 19 !

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

```

Try It

# Answer
> 1 votes
# 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!");
    }
}

```

# Answer
> 1 votes
**C, 60 bytes**

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

```

# Answer
> 1 votes
# 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.

# Answer
> 1 votes
# 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!'

```

# Answer
> 1 votes
# 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!

# Answer
> 1 votes
# 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!`

# Answer
> 1 votes
# 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.

# Answer
> 1 votes
# 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.

# Answer
> 1 votes
# JavaScript, 55 bytes, score 27.5!

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

# Answer
> 1 votes
# JavaScript, 51 bytes, Real Crash

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

```

# Answer
> 1 votes
## 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

```

# Answer
> 1 votes
# 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.

# Answer
> 1 votes
# Zsh, 18!

**36/2** bytes, including `hello world!` for extra credit. Try it online!

```
echo hello world!
goodbye\ cruel\ $_

```

<sub> NB: The identifier `$_` doesn't work with `<<<` because `<<<` runs in a sub-shell. Example </sub>

# Answer
> 1 votes
# 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!

# Answer
> 1 votes
# 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.

# Answer
> 1 votes
## , ~~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.

# Answer
> 1 votes
## `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.

```

# Answer
> 1 votes
# 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.

# Answer
> 1 votes
# 05AB1E, score ~~14.5~~ 14!

```
”Ÿ™‚ï!”,.•1{ø{β?Õ&>₅₁\•™'!«ι

```

Try it online!

# Answer
> 1 votes
# Python 3, Score: 43/2=21.5!

```
+print("Hello"+"Goodbye Cruel World!"[-7:])

```

Try it online!

# Answer
> 1 votes
# 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).

# Answer
> 1 votes
# Vyxal, 10.5! bytes

```
`ƛ⁋Ṗ⊍ Crꜝ∞ ƛ€!`kh\!+←

```

Try it Online!

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

```

# Answer
> 1 votes
# 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.

# Answer
> 1 votes
# 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!`)
```

# Answer
> 0 votes
# Rexx (Regina), ~~39/2~~ ~~37/2~~ bytes = 19.5!

```
say Hello World!
-Goodbye Cruel World!

```

Try it online!

# Answer
> 0 votes
## 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!");}

```

# Answer
> 0 votes
## 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. >>

```

# Answer
> 0 votes
## 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.

# Answer
> 0 votes
# Batch, 20.5 bytes!

```
@echo Hello World!
"Goodbye Cruel World!

```
* **+41** bytes source code
* **-50%** bonus

# Answer
> 0 votes
# tcl, 28

```
error "Goodbye cruel World!"

```

## demo

# Answer
> 0 votes
# 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-.

# Answer
> 0 votes
# Windows .BAT, Score: 19.5!

```
echo Hello World!&"Goodbye Cruel World!

```

Yes it works on my CMD

# Answer
> 0 votes
# 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!

# Answer
> 0 votes
# Jstx, 22 bytes / 2 = score 11!

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

```

Try it online!

# Answer
> 0 votes
# Python 3, 33 bytes

```
print('goodbye cruel world!')

0/0

```

# Answer
> 0 votes
# 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.

# Answer
> 0 votes
# 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.

# Answer
> 0 votes
# Pepe, ~~195~~ 191 bytes

<sup>Saved 4 bytes thanks to u\_ndefined.</sup>

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

<sup>Saved 4 bytes thanks to u\_ndefined.</sup>

Because the absence of space after the `!` annoys me.

```
reeEeeeEEErEeEEeEEEEreeereeereeEEeeEeereeEEeeeEereeEEEEeeEreeEEeeEeEREeeEeeeeeReeereeEeeeeEEreeEEEeeEereeEEEeEeEreeEEeeEeEreeEEeEEeeReeereeEeEeEEEreeereeEEEeeEereeEEeEEeereeEEeeEeereeeEeeeeEReeeReeee

```

Try it online!

# Answer
> 0 votes
# 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.

```

# Answer
> 0 votes
# 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.

```

# Answer
> 0 votes
# Julia 1.0, 51 bytes long, score 25.5!

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

```

Try it online!

# Answer
> 0 votes
# 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!

```

# Answer
> 0 votes
# 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.

# Answer
> 0 votes
# 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

```

# Answer
> 0 votes
# 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

```

# Answer
> 0 votes
# 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?

# Answer
> 0 votes
# 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.

```

# Answer
> 0 votes
# 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!

# Answer
> 0 votes
# 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!

# Answer
> 0 votes
# Batch, 36 bytes

Exits with a CRASH!! (the two trailing newlines must not be removed)

```
@echo(Goodbye Cruel World!
@call ^

```

# Answer
> 0 votes
# Perl 32 Bytes

Try it online!

```
print"Goodbye Cruel World!";1/0;

```

---
Tags: code-challenge, hello-world
---


title: Find an Illegal String

text:
# Question
Title: Find an Illegal String
The challenge is to find a string of characters that **cannot** appear in *any* legal program in your programming language of choice. That includes comments, strings, or other "non-executable" parts.

## Challenge

* Your program may be specific to a particular version or implementation of your language's compiler/interpreter/runtime environment. If so, please specify the particulars.
* Only standard compiler/interpreter/runtime options are permitted. You cannot pass some weird flag to your compiler to get a specific result (e.g. passing a flag to convert warnings into errors).
* If your programming language requires a specific encoding (e.g. UTF-8), your string must also be correctly encoded (i.e. strings which fail solely due to character decoding errors are not allowed).
* Every individual character in your submission must be admissible in a legal program; that is, you can't just use a character which is always rejected.
* The compiler/interpreter/runtime must give an error when given *any* source code that contains your string as a substring. The error does not have to be the same across programs - one embedding of your string might cause a syntax error, while another might cause a runtime error.

## Scoring

* Shortest illegal string for each language wins.
* You should explain *why* your string is illegal (why it cannot appear anywhere in a legal program).
* Dispute incorrect solutions in the comments. More specifically, you should provide a link to TIO or equivalent demonstrating a legal program (i.e. one that doesn't produce any errors) that contains the proposed substring.
* Some languages (e.g. Bash, Batch, Perl) allow arbitrary binary data to be appended to a program without affecting validity (e.g. using `__DATA__` in Perl). For such languages, you may submit a solution that can appear *only* in such a trailing section. Make sure to make a note of that in your answer. (The definition of this "trailing section" is language-dependent, but generally means any text after the parser has entirely stopped reading the script).

## Example

In Python, I might submit

```
x
"""
'''

```

but this can be embedded into the larger program

```
"""
x
"""
'''
y
'''

```

so it isn't admissible.

# Answer
> 72 votes
# Changeling, 2 bytes

```

```

That's two linefeeds. Valid Changeling must always form a perfect square of printable ASCII characters, so it cannot contain two linefeeds in a row.

The error is always a parser error and always the same:

```
This shape is unpleasant.

```

accompanied by exit code **1**.

Try it online!

# Answer
> 44 votes
# Java, 4 bytes

```
;\u;

```

Try it online!

This is an invalid Unicode escape sequence and will cause an error in the compiler.

```
error: illegal unicode escape

```

# Answer
> 42 votes
# COBOL (GNU), 8 bytes

```

THEGAME

```

First, a linefeed to prevent you from putting my word in a commented line.

Then, historically, COBOL programs were printed on coding sheets, the compiler relies heavily on 80-character limited lines, there are no multiline comments and the first 6 characters are comments (often used as editable line numbers), you can put almost anything there, AFAIK. I chose `THEGAM` at the beginning of the next line.

Then, the 7th symbol in any line only accepts a very restricted list of characters : Space (no effect), Asterisk (comments the rest of the line), Hyphen, Slash, there may be others, but certainly not `E`.

The error given by GnuCobol, for instance, is :

```
error: invalid indicator 'E' at column 7

```

Try it online!

Also, you just lost the game.

# Answer
> 27 votes
# JavaScript, 7 bytes

```

;*/\u)
```

Note the leading newline.

* `\u)` is an invalid Unicode escape sequence and this is why this string is invalid
* Adding a `//` at the beginning will still not work because of the leading newline, leaving the second line uncommented
* Adding a `/*` will not uncomment the string completely because of the closing `*/` that completes it, leaving the `\u)` exposed
* As stated by @tsh, the bottom line can be turned into a regex by having a `/` after the string, so by having the `)` in front of the `\u`, we can ensure that the regex literal will always be invalid
* As stated by @asgallant, one could do `1||1(string)/` to avoid having to evaluate the regex. The semi-colon at the beginning of the second line stops that from happening by terminating the expression `1||1` before it hits the second line, thus forcing a SyntaxError with the `;*`.

### Try it!

```
clicky.onclick=a=>{console.clear();console.log(eval(before.value+"\n;*/\\u)"+after.value));}
```

```
textarea {
  font-family: monospace;
}
```

```
<button onclick="console.clear();">Clear console</button>
<br>
<textarea id=before placeholder="before string"></textarea>
<pre><code>
 */\u)</code></pre>
<textarea id=after placeholder="after string"></textarea>
<br>
<button id=clicky>Evaluate</button>
```

# Answer
> 24 votes
# Python, 10 bytes (not cpython)

```

?"""?'''?

```

### Edit:

Due to @feersum's diligence in finding obscure ways to break the Python interpreter, this answer is completely invalidated for any typical cpython environment as far as I can tell! (Python 2 and 3 for both Windows and Linux) I do still believe that these cracks will not work for Pypy on any platform (the only other Python implementation I have tested).

### Edit 2:

In the comments @EdgyNerd has found this crack taking advantage of a non-ascii encoding declaration! This seems to decode to `print("")`. I don't know exactly how this was found but I imagine the way to fix this sort of exploit would maybe be to try different combinations of any invalid characters where the `?`s are, and find one that doesn't behave well with any encoding.

---

Note the leading newline. Cannot be commented out due to the newline, and no combination of triple quoted strings should work if I thought about this correctly.

@feersum in the comments seems to have completely broken any cpython program on Windows as far as I can tell by adding the 0x1A character to the beginning of a file. It seems that maybe (?) this is due to the way this character is handled by the operating system, apparently being a translated to an EOF as it passes through stdin because of some legacy DOS standard.

In a very real sense this isn't an issue with python but with the operating system. If you create a python script that reads the file and uses the builtin `compile` on it, it gives the more expected behavior of throwing a syntax error. Pypy (which probably does just this internally) also throws an error.

# Answer
> 20 votes
# C (clang), 16 bytes

```
 */
#else
#else

```

Try it online!

`*/` closes any `/*` comment, and the leading space makes sure we didn’t just start one. The newline closes any `//` comment and breaks any string literal. Then we cause an `#else without #if` or `#else after #else` error (regardless of how many `#if 0`s we might be inside).

# Answer
> 20 votes
# Rust, 65540 bytes

```
`"###... a lot more #s ###

```

That is a backtick, quote, 65535 `#`s, and an invisible U+202A Per this advisory there is an issue with Unicode bidirectional overrides that can cause Unicode-aware editors to misrender the code, allowing bad actors to hide malicious code in plain sight. Starting in rust 1.56.1, rustc contains mitigation for that vulnerability, preventing the use of the relevant codepoints by default anywhere in the source code. However, the `text_direction_codepoint_in_literal` lint can be set to `allow` or `warn` to let use it in string literals. String literals are tricky to break out of, mainly because raw string literals are designed to allow any valid utf8 within them. However, take a look at rustc's lexer, and you will find something interesting\- no more than 65535 hashtags are permitted in delimiters. Simply adding the quote followed by the long string of hashtags is enough to break any attempts at surrounding it in strings, and the U+202A is always invalid anywhere but a string. However there is another problem- someone could use the starting quote to begin a string, and hide the nastiness that way. This is where the backtick comes into play- it is an error anywhere but a literal or a comment, thus making it truly impossible for rust to contain this code. If you're wondering if there is an easier solution that fails after the lexer you'd be disappointed- anything that passes the lexer can be thrown away by a macro, and tacking on a `#[cfg(nope)]` will make anything that parses disappear.

edit: an actually valid answer this time

# Answer
> 17 votes
# Ada - 2 bytes

I think this should work:

```

_
```

That's newline-underscore. Newline terminates comments and isn't allowed in a string. An underscore cannot follow whitespace; it used to be allowed only after letters and numbers, but the introduction of Unicode made things complicated.

# Answer
> 15 votes
# Pyth, 6 bytes

```
¡¡$¡"¡

```

`¡` is an unimplemented character, meaning that if the Pyth parser ever evaluates it, it will error out with a PythParseError. The code ensures this will happen on one of the `¡`s.

There are three ways a byte can be present in a Pyth program, and not be parsed: In a string literal (`"` or `."`, which are parsed equivalently), in a Python literal (`$`) and immediately after a `\`.

This code prevents `\` from making it evaluate without error, because that only affects the immediately following byte, and the second `¡` errors.

`$` embeds the code within the `$`s into the compiled Python code directly. I make no assumptions about what might happen there.

If the program reaches this code in a `$` context, it will end at the `$`, and the `¡` just after it will make the parser error. Pyth's Python literals always end at the next `$`, regardless of what the Python code might be doing.

If the program starts in a `"` context, the `"` will make the string end, and the final `¡` will make the parser error.

# Answer
> 13 votes
# x86 32-bit machine code, 11 bytes (and future-proof 64-bit)

```
90 90 90 90 90 90 90 90 90 0f 0b

```

This is `times 9 nop` / `ud2`. It's basically a NOP sled, so it still runs as 0 or more `nop`s and then `ud2` to raise an exception, regardless of how many of the `0x90` bytes were consumed as operands to a preceding opcode. Other single-byte instructions (like `times 9 xchg eax, ecx`) would work, too.

# x86 64-bit machine code, 10 bytes (current CPUs)

There are some 1-byte illegal instructions in 64-bit mode, until some future ISA extension repurposes them as prefixes or parts of multi-byte opcodes in 64-bit mode only, separate from their meaning in 32-bit mode. `0x0e` is illegal in 64-bit mode on current CPUs (tested on Intel Skylake). It's `push cs` in 32-bit mode; AMD64 freed up a bunch of opcodes for future use but as of yet neither Intel nor AMD have added any 64-bit-only extension to use them. But they still could, which is why this isn't future-proof; some future CPU could decode `0x0e` as an opcode or prefix.

```
0e 0e 0e 0e 0e 0e 0e 0e 0e 0e

```

---

**Rules interpretation for executable machine code**:

* The bytes can't be jumped over (like the "not parsed" restriction), because CPUs don't raise exceptions until they actually try to decode/execute (non-speculatively).
* Illegal means *always* raises an exception, for example an illegal-instruction exception. (Real programs can catch that with an exception handler on bare metal, or install an OS signal handler, but I think this captures the spirit of the challenge.)

---

**It works because a shorter byte-string ending in `ud2` could appear as an imm32 and/or part of the addressing mode for another instruction, or split across a pair of instructions**. It's easiest to think about this in terms of what you could put before the string to "consume" the bytes as part of an instruction, and leave something that won't fault.

I think an instruction can consume at most 9 bytes of arbitrary stuff: a SIB byte, a disp32, and an imm32. i.e. the first 2 bytes of this instruction can consume 8 NOPs and a ud2, but not 9.

```
c7 84 4b 00 04 00 00 78 56 34 12        mov dword [rbx+rcx*2+0x400],0x12345678

```

Can't beat 9 nops:

```
    db 0xc7, 0x84   ; opcode + mod/rm byte: consumes 9 bytes (SIB + disp32 + imm32)
    times 9 nop          ; 1-byte xchg eax, ecx or whatever works, too
    ud2
  ----
   b:   c7 84 90 90 90 90 90 90 90 90 90        mov    DWORD PTR [rax+rdx*4-0x6f6f6f70],0x90909090
  16:   0f 0b                   ud2

```

64-bit mode:

```
 c7 84 0e 0e 0e 0e 0e 0e 0e 0e 0e        mov    DWORD PTR [rsi+rcx*1+0xe0e0e0e],0xe0e0e0e
 0e                      (bad)

```

But the bytes for 8 NOPs + ud2 (or `times 9 db 0x0e`) can appear as part of other insns:

```
    db 0xc7, 0x84   ; defender's opcode + mod/rm that consumes 9 bytes

    times 8 nop          ; attacker code
    ud2

    times 10 nop    ;; defenders's padding to be consumed by the 0b opcode (2nd half of ud2)
----
  18:   c7 84 90 90 90 90 90 90 90 90 0f        mov    DWORD PTR [rax+rdx*4-0x6f6f6f70],0xf909090
  23:   0b 90 90 90 90 90       or     edx,DWORD PTR [rax-0x6f6f6f70]
  29:   90                      nop
  2a:   90                      nop
  ...

```

# Answer
> 11 votes
# Shakespeare Programming Language, 2 bytes

```
.:

```

Explanation: If this string is in the title of the play, the `.` ends it and the `:` is not a valid character name. Similar problems occur in an act and scene name. No character can speak a line beginning with `:`, and the `.` will end a `Recall` statement, which can otherwise create a comment.

# Answer
> 10 votes
# INTERCAL, 12 bytes

```
DOTRYAGAINDO

```

Try to crack it online!

INTERCAL's approach to syntax errors is a bit special. Essentially, an invalid statement won't actually error unless the program tries to execute it. In fact, the idiomatic syntax for comments is to start them with `PLEASE NOTE`, which really just starts a statement, declares that it isn't to be executed, and then begins it with the letter `E`. If your code has `DODO` in the middle of it, you could prepend `DOABSTAINFROM(1)(1)` and tack any valid statement onto the end and you'll be fine, if it's `DODODO` you can just bend execution around it as `(1)DON'TDODODOCOMEFROM(1)`. Even though INTERCAL lacks string literal syntax for escaping them, there's no way to use syntax errors to create an illegal string, even exhausting every possible line number with `(1)DO(2)DO...(65535)DODODO`, since it seems that it's plenty possible to have duplicate line numbers with `COME FROM` working with any of them.

To make an illegal string, we actually need to use a perfectly valid statement: `TRY AGAIN`. Even if it doesn't get executed, it strictly must be the last statement in a program if it's in the program at all. 12 bytes is, to my knowledge, the shortest an illegal string can get using `TRY AGAIN`, because it needs to guarantee that there is a statement after it (executed or not) so `DOTRYAGAIN` is just normal code, and it needs to make sure that the entire statement is indeed `TRY AGAIN`, so `TRYAGAINDO` doesn't work because it can easily be turned into an ignored, normal syntax error: `DON'TRYAGAINDOGIVEUP`, or `PLEASE DO NOT TRY TO USE TRYAGAINDO NOT THAT IT WOULD WORK`. No matter what you put on either side of `DOTRYAGAINDO`, you'll error, with either `ICL993I I GAVE UP LONG AGO`, `ICL079I PROGRAMMER IS INSUFFICIENTLY POLITE`, or `ICL099I PROGRAMMER IS OVERLY POLITE`.

# Answer
> 9 votes
# APL and MATL and Fortran, 3 bytes

```

'

```

Newline, Quote, Newline always throws an error since block comments do not exist:

# Answer
> 9 votes
## Commodore 64 Basic, 2 bytes

```

B

```

(that's a newline followed by the letter "B").

Any line in a Commodore 64 program must begin with either a line number or a BASIC keyword, and stored programs only permit line numbers. There are no keywords beginning with "B" (or "H", "J", "K", "Q", "X", "Y", or "Z").

# Answer
> 7 votes
# C#, 16 bytes

```

*/"
#endif<#@#>
```

Works because:

* `//` comment won't work because of the new line
* `/*` comment won't work because of the `*/`
* You can't have constants in the code alone
* Adding `#if false` to the start won't work because of the `#endif`
* The `"` closes any string literal
* The `<#@#>` is a nameless directive so fails for T4 templates.
* The new line tricks it so having `/` at the start won't trick the `*/`

Each variation fails with a compilation error.

# Answer
> 7 votes
# Desmos, 3 bytes

```

\

```

(linefeed, backslash, linefeed)

I recently said "Pasting in invalid-formatted text \[into Desmos\] simply does nothing." As I recently discovered, this isn't quite true. When pasting in multiple lines, it's happy to throw errors if one of them is invalid. Now, this works even if some of those lines other are blank, causing them to be ignored. Therefore, we make a `\` on its own line, which is guaranteed to throw an error.

Logically, we *should* be able to knock this down to two bytes (`\`, `LF`), as no legal line can end with a `\`. However, Desmos strangely interprets this as an empty list (normally represented as `[]`), for reasons I don't understand. This makes that two-byte string an unusual almost-illegal string, where the only valid program containing that string is the string itself.

# Answer
> 5 votes
# Literate Haskell, 15 bytes

Repairing a deleted attempt by nimi.

```

\end{code}
5
>

```

Try it online!

nimi's original attempt is the last two lines, based on Literate Haskell not allowing `>` style literate code to be on a neighboring line to a literate comment line (`5` here). It failed because it can be embedded in a comment in the alternate ("LaTeX") literate coding style:

```
\begin{code}
{-
5
>
-}
\end{code}

```

However, the `\begin{code}` style of Literate Haskell does *not* nest, neither in itself nor in `{- -}` multiline comments, so by putting a line with `\end{code}` just before the line with the `5`, that workaround fails, and I don't see a different one.

# Answer
> 4 votes
# Free Pascal, 18 bytes

```

*)}{$else}{$else}

```

First close all possible comments, then handle conditional compile.

Please comment here if I forgot something.

# Answer
> 4 votes
# CJam, 7 bytes

```
"e#"
:"

```

Try it online!

# Answer
> 4 votes
# Brain-Hack (a variation of Brain-Flak), ~~3~~ 2 bytes

Thanks to Wheat Wizard for pointing out that Brain-Hack doesn't support comments, saving me a byte.

```
(}

```

Try it online!

# Answer
> 4 votes
# JavaScript (Node.js), ~~9~~ 8 bytes

```
`*/
\u`~

```

Try it online!

I think this should be illegal enough.

## Previous JS attempts in other answers

> ```
>
> ;*/\u)
>
> ```
>
> By @Cows quack
>
> As an ES5 answer this should be valid, but in ES6 wrapping the code with a pair of backticks wrecks this. As a result valid ES6 answers must involve backticks.
>
> ```
> `
> `*/}'"`\u!
>
> ```
>
> By @iovoid
>
> This is an improved version involving backticks. However a single `/` after the code breaks this (It becomes a template literal being multiplied by a regex, useless but syntactically valid.) @Neil made a suggestion that changing `!` to `)`. This should theoretically work because adding `/` at the end no longer works (due to malformed regex.)

## Explanation

```
`*/
\u`~

```

This is by itself illegal, and also blocks all single and double quotes because those quotes cannot span across lines without a `\` at the end of a line

```
//`*/
\u`~

```

and

```
/*`*/
\u`~

```

Blocks comments by introducing illegal escape sequences

```
``*/
\u`~

```

Blocks initial backtick by introducing non-terminated RegExp literal

```
console.log`*/
\u`~

```

Blocks tagged template literals by introducing an expected operator between two backticks

# Answer
> 4 votes
# Go, 6 bytes

*/```
</code></pre>

Try to crack it online!

The grave accent (\`) marks a raw string literal, inside which all characters except \`, including newlines and backslashes, are interpreted literally as part of the string. Three \`'s in a row are the core: adjacent string literals are invalid and \` always closes a \` string, so there's no way to make sense of them. I had to use 3 more bytes for anti-circumvention, a newline so we can't be inside a single-line comment or a normal quoted string, and a \*/ so we can't be inside a multi-line comment.

# Answer
> 4 votes
# Jelly, ~~3~~ 4 bytes

```
»»
€

```

Try it online!

Alternative 4 bytes:

```
»

€

```

*+1 byte because emanresu A found an issue with the old approach*

Jelly has no comments, and every line in the code is parsed whether or not it is reachable. The only way to prevent some code from being executed is by putting it in a string literal. There are different types of string literals based on the ending character, but almost all start with . This is countered by `»`, which terminates a string (and interprets it as a dictionary-compressed string).

The only two string literal types that do not terminate at the first `»` are  and , which each process precisely the next two characters. However this still leaves the newline unescaped.

Thus  (each/map) will always be executed on a link (line) of its own. It tries to get a link from its left; since none exists, the interpreter errors.

# Answer
> 4 votes
# Google Sheets, Excel; 3 bytes

For a single-cell Formula (starts with `+` or `=`). Otherwise, you can just put whatever arbitrary text you want into a cell.

Here it is: `1"1`

* A string has to be enclosed in `"`s. A double quote must be escaped by `""`.
* The `"` has to be a string token boundary.
* If it's the end, following a string with a 1 is illegal.
* If it's the beginning, preceding a string with a 1 is also illegal.

# Answer
> 4 votes
## Swift,  ~~4~~  3 bytes

There's control characters in here, so I'll just give their ASCII values: `0A 22 00`.

Most of the ways that other C-family languages do this don't work in Swift, because Swift allows nested block comments.

The null character always generates at least a warning. However, if it's in the middle of whitespace or a line comment, it's *only* a warning, not an error. Additionally, Xcode lets you put most control characters inside of a block comment and just rolls with it.

Emphasis on most. For some reason, if you have a null byte in the middle of a block comment or string literal, the Swift compiler gets lost and can't find the end, no matter where it is. This causes an error (and also breaks Xcode's syntax highlighting). So, this is three bytes:

* `0A` -- a newline, to make sure we're not in a line comment or single-line string literal.
* `22` -- `"`, the start of a single-line string literal, unless it's inside a multi-line string literal or block comment. This does not end a multi-line string literal if it started inside of one.
* `00` -- a null byte, to prevent the block comment or string literal from terminating.

The original answer used `/*` (open block comment) rather than `"`.

# Answer
> 3 votes
# AWK, 4 bytes

```

/

```

Try it online!

Since `AWK` doesn't have a method to do multi-line comments, need 2 newlines before and 1 after `/` to prevent commenting out or turning this into a regex, e.g. add `1/`. The most common message being \`unexpected newline or end of string.

With previous crack

# Answer
> 3 votes
# VBA, 2 Bytes

A linefeed followed by an underscore - the `_` functions as the line continuation character in VBA, and as there is nothing in the line directly to the left or above the line continuation, coupled with VBA's lack of multiline comments means that this will always throw the compile time error `Compile Error:` `Invalid character`

```

_

```

# Answer
> 3 votes
# JavaScript, 11 characters

```
`
`*/}'"`\u)

```

The backticks make sure to kill template strings, the quotes get rid of strings, the newline avoid commented lines, the end of comment avoids block comments, and the last backtick and escape (with a `)` to avoid appending numbers or `/`) try to start a invalid string.

Try it online!

# Answer
> 3 votes
# SmileBASIC, 2 bytes

```

!

```

Nothing continues past the end of a line, so all you need is a line break followed by something which can't be the start of a statement. `!` is the logical not operator, but you aren't allowed to ignore the result of an expression, so even something like `!10` would be invalid (while `X=!10` works, of course)

Similar things will work in any language where everything ends at the end of a line, as long as it parses the code before executing it.

There are a lot of alternative characters that could be used here, so I think it would be more interesting to list the ones that COULD be valid.

`@` is the start of a label, for example, `@DATA`; `(` could be part of an expression like `(X)=1` which is allowed for some reason; any letter or `_` could be a variable name `X=1`, function call `LOCATE 10,2`, or keyword `WHILE 1`; `'` is a comment; and `?` is short for `PRINT`.

# Answer
> 3 votes
## TI-Basic (83+/84+/SE, 24500 bytes)

```
A

```

(24500 times)

TI(-83+/84+/SE)-Basic does syntax checking only on statements that it reaches, so even 5000 `End` statements in a row can be skipped with a `Return`. This, in contrast, cannot fit into the RAM of a TI-83+/84+/SE, so no program can contain this string. Being a bit conservative with the character count here.

The original TI-83 has 27000 bytes of RAM, so you'll need 27500 `A`s in that case.

## TI-Basic (89/Ti/92+/V200, 3 bytes)

```
"

```

Newline, quote, newline. The newline closes any comments (and disallows embedding the illegal character in a string, since AFAIK multiline string constants are not allowed), the other newline disallows closing the string, and the quote gives a syntax error.

You can get to 2 bytes with

```
±

```

without the newline, but I'm not sure whether this counts because `±` is valid only in string constants.

# Answer
> 3 votes
# Rockstar, ~~4~~ 5 bytes

*Crossed out 4 is still 4 :(*

```
)
"""

```

Rockstar is a very... wordy language.
While `"` can be used to define a string, such as `Put "Hello" into myVar`, to my knowledge there is no way for 3 quotes to appear outside of a comment, and the close paren ensures that won't happen either (Comments in Rockstar are enclosed in parentheses, like this).

Rockstar also has a poetic literal syntax, in which punctuation is ignored, so the newline makes sure that the 3 quotes are the start of a line of code, which should always be invalid

# Answer
> 3 votes
# Ruby, ~~58~~ ~~23~~ 27 bytes AND proof of impossibility at bottom

This snippet is valid in any Ruby version prior to Ruby 2.3 (when heredocs were added):

```

=end
)}end/;[}'"\//;[}#{]}

```

Old version (invalid):

```

=end
)}end/;kill(Process.pid,-9)'"\//;kill Process.pid,-9

```

This cannot be used anywhere in a Ruby program except after `__END__`.

# Proof of impossibility

This solution is impossible in any Ruby version after and including Ruby 2.3.

Any Ruby solution can be inserted into this snippet and function as a valid program:

```
<<'string'

# Insert code here

string

```

With this particular snippet, you can add (note leading newline)

```

string

```

to your solution in order to invalidate the program. However, changing the "name" of the heredoc will again invalidate your solution. Heredocs can have infinite placeholders, meaning a solution accounting for all of them would be infinitely long. Thus an answer in Ruby 2.3+ is impossible.

Thanks to histocrat for pointing this out.

# Answer
> 3 votes
# JavaScript, 7 bytes

```
 */
#`#

```
* Adding a `//` at the beginning will still not work because of the leading newline, leaving the second line uncommented.
* Adding a `/*` will not uncomment the string completely because of the closing `*/` that completes it, leaving the `#` exposed.
* Adding ``` will not quote the string completely, because of ``` that completes a string, leaving the `#` exposed.
* Regular expressions won't work because of `#` following `/` character.
* `/` following `*` cannot be parsed as a regular expression, as regular expressions cannot have newlines

### Try it!

```
clicky.onclick=a=>{console.clear();console.log(eval(before.value+" */\n#`#"+after.value));}
```

```
textarea {
  font-family: monospace;
}
```

```
<button onclick="console.clear();">Clear console</button>

<textarea id=before placeholder="before string"></textarea>

 */
#`#

<textarea id=after placeholder="after string"></textarea>

<button id=clicky>Evaluate</button>
```

# Answer
> 3 votes
# Scratch (1.x, except 1.2 beta), scratchblocks syntax, 26 bytes

```

when gf clicked
say(()/()

```

Leading new line ensures that "when gf clicked" will not be in a comment, so that what's below it will run.

This errors when run in the Stage, because the Stage cannot use the `say` block.

This errors when run in a sprite by itself, because a divide by zero is attempted. (When a number argument is blank, it is read as 0.)

This errors when run in a sprite when `)` or a new line is added after it, because it doesn't change what the existing code does.

This errors when run in a sprite when something else is added after it, because it creates an undefined block which causes an error when run.

---

1.2 beta is excluded because it featured comment blocks (different from modern comments), which supported multiline, which this could be put into.

Versions past 1.4, including the Experimental Viewer, are excluded because dividing by zero does not cause an error.

# Answer
> 3 votes
# Dis, 2 bytes.

```
))

```

## How it works

* `(` to the nearest `)` is a comment.
* But nothing can match the second `)` above in this syntax.
* Thus it is syntax error.

# Answer
> 3 votes
# Pip Classic, 10 bytes

```

;\"
;`
*;

```

Try it online!

I *think* this should be solid, but I welcome anyone to prove me wrong.

### How?

A semicolon at the start of a line begins a single-line comment, so our code is effectively

```
*;

```

and Pip complains because `*` is a binary operator and needs a left operand.

If we add any expression before the snippet, we still get an error because `*` needs a right operand. No operand can be supplied because `*` is followed by the expression terminator `;`.

We can't wrap the snippet in a string, because every possible string delimiter (`"`, `\"`, and ```) is matched by a delimiter in the snippet. (In a regular `"`-delimited string, the backslash is not an escape character, so it doesn't mess anything up.)

Finally, we can't comment out the last line of the snippet because Pip Classic doesn't have block comments.

# Answer
> 3 votes
# Knight, 7 bytes

Technically, knight programs aren't allowed to contain anything outside of `\r`, `\n` ,`\t`, or `<space>`-`~`, so you could just submit `<NUL>` for a one byte solution.

Additionally, each knight program is exactly a single expression; handling things after that experssion is up to the implementation. So, you could prefix any program with `TRUE`—a valid expression—after which anythign afterwards would be undefined behaviour. However, that kind of defeats the spirit of the question as well IMO, so let's assume that we're actually in some arbitrary expression:

```
#"'#'
$

```

The idea is since `$` is not a legal function, it cannot appear outside of strings.

* If there's no leading code, then the comment removes the rest of the first line.
* If we're embedded in a comment, our entire first line will be commented out, leaivng a lone `$`, which is illegal.
* If we're inside a `"` string, then the first `"` will close it, which is then followed by the legal `'#'` string
* If we're inside a `'` string, then the first `'` will close it, with the remaining `'` being commented out by the `#`, leaving `$` by itself.

# Answer
> 2 votes
# Fortran, 14 bytes

```

end program
e

```

No multiline comments or preprocessor directives in Fortran.

# Answer
> 2 votes
# Powershell, ~~10~~ ~~8~~ ~~12~~ ~~14~~ ~~13~~ ~~14~~ 16 bytes

-2 byte thanks to Mazzy finding a better way to break it
+4 -1 bytes thanks to IsItGreyOrGray

```
$#>
'@';
"@";
@=

```

I hope this works. `'` and `"` to guard against quotes, `#>` to break the block-comment, new lines to stop the single-line comment, both `'@` and `"@` to catch another style of strings, and then starts an improper array to throw a syntax error.

The logic being they can't use either set of quotes to get in, they can't block-comment it out, If `@"` is used, it'll create a here-string which can't have a token afterwards, and if they leave it alone, it'll try to make a broken array. This statement wants to live so hard, I keep finding even more holes in the armor.

# Answer
> 2 votes
# Scratch (scratchblocks2), 3 bytes

There's no such thing as an error in scratchblocks2 - just red-colored blocks - but this can't be expressed in actual Scratch, so I think it's OK.

```

<?
```

Leading newline to avoid this just being commented or ::ed out.

Then a predicate block with it's label starting with `?` \- there's no such block.

# Answer
> 2 votes
# PCRE Regex, ~~6~~ 7 bytes

```
\E
)](+

```

Try it on regex101

Any string not containing `\E` would be legal inside a `\Q`...`\E` literal sequence. By starting this one with `\E`, we break out of such a sequence if we were in one. And if we weren't in one, but are preceded by a `\`, then it will be treated as a literal `\E`, and we'll still be guaranteed not to be inside a `\Q`...`\E`.

`(+` is not part of any legal group structure, and will generate a compile-time error ("Incomplete group structure" and/or "The preceding token is not quantifiable" / "quantifier does not follow a repeatable item") anywhere other than:

1. Within a `\Q`...`\E`. We've handled this. We can't be inside one thanks to the `\E`.
2. Immediately after a `\`. But since we have it immediately after a `\E`, it can't be immediately after a `\`. Note that `\E` alone is valid, even if there was no `\Q` before it.
3. Inside a `#...` style comment. This can only happen in free-spacing mode, but this can be turned on by `(?x)` anywhere in a regex, so we need to handle it.
4. Inside a `(?#...)` style comment.
5. Inside a character class, e.g. `[(+]` or `[\Q\E(+]` – or even `[\Q\E](+]`, which will be treated as `[](+]`, which, since an empty character class is not part of PCRE syntax (except in PCRE2 with the PCRE2\_ALLOW\_EMPTY\_CLASS option enabled), is treated as a character class consisting of `](+` (the beginning of a character class is the only place where `]` does not need to be escaped).

Because of #3, we need a newline, to break out of any `#...` comment we may be in.

Because of #4, we need a `)`, to break out of any `(?#...)` comment we may be in.

And it is because of #5 that we need to put `]` in front of the `(+`. This closes any character class we might have been in. If we hadn't already put a newline and/or a `)` to close a potential comment, we'd need this to be `]]`, because a character class can't be empty and `]` is allowed to be the first character in a class without being escaped. In any case, thanks to having a character before our `]`, it even works if a range was started, e.g. `[!-\E)](+`.

*Edit: Silly me, didn't protect it from being inside comments. Fixed.*

# Answer
> 2 votes
# ECMAScript Regex, 4 bytes

```
]](+

```

Try it on regex101

This is a quite a bit easier than PCRE. There's no `\Q`...`\E`, no free-spacing mode, and no comments. But if we used just `](+` we could still be inside a character class and have our `]` escaped, as `[\](+]` which would be treated as a character class of `](+`. So we still need the double `]` to make sure we exit any character class we may have been in, which works even if a range was started, e.g. `[!-]](+`.

`(+` is illegal in any context other than a character class, and will give an error message such as "Nothing to repeat" or "Incomplete group structure" / "The preceding token is not quantifiable".

# Answer
> 2 votes
# Runic Enchantments, 3 bytes

One of many possible variations.

Try it online!

Runic utilizes unicode combining characters in a "`M` modifies the behavior of `C`" (where `C` is a command). As such, no two modifiers are allowed to modify the same command and the parser will throw an error if such an occurrence is found.

Similarly, certain commands that redirect the IP cannot be modified in any way, due to the existence of direction modifying modifier characters (and both in the same cell makes no sense).

There is no way to escape or literal-ize the string to make it valid. Tio link contains a `;` in order to bypass the higher-priority "no terminator" error.

# Answer
> 2 votes
## NDBall 2 bytes

specificly in NDBallSim V1.0.1

```
##

```

a hashtag is a memory cell instructor and requires a direction, two of them anywhere will cause the error

```
NDBall Parse ERROR @ LINE (whatever line): Memory cell requires a direction ex: #>12

```

this double character trick can actually be done with many more chars, to be exact all of these `)(,}{|><+-pP$%Y][E` and newline

This is actually all (discounting digits) of the useable chars in the lang itself because it never has a case where you use the same char twice

# Answer
> 2 votes
# C#, 6 bytes

```

"*/#

```

---

`#` is only used in C# to specify a preprocessor directive. Preprocessor directives are only valid if the `#` is the first non-whitespace character on its line. As a result, it doesn't even matter if the specified directive exists or not (so the shortest solution is to not specify any directive name).

The only way to prevent `#` being interpreted as a directive is to put it in a comment or string.

It is not possible to comment out `#` because `//` is prevented by preceeding newline and `/*` is prevented by `*/`. It is not possible to enclose it in a string because multiline strings must start with `@"`, but there is no way to put `@` in front of a string that would capture `#` (`@\n"` is not valid).

# Answer
> 2 votes
# Grass, 3 bytes

```
wWv

```

Try it online!

Grass programs are written using only `w`, `W`, and `v`; all other characters are ignored.

`w` is necessary because any characters placed before the program's first `w` are ignored.

`W` is expected to be followed by a sequence of `w` characters to form a function application; however, it is instead followed by a `v`, which causes a parse error.

# Answer
> 1 votes
# S.I.L.O.S, 4 bytes

Silos is competitive \o/

```

x+

```

S.I.L.O.S runs on a two pass interpreter / compiler. Before execution a "compiler" attempts to simplify the source into an array describing the sourc Each line is treated separately. x+a is an assignment operator that will add ea to the value of x and store it into x. However the "compiler" will break. Therefore, we take this string and add a new line before and after ensuring it's on its own line and breaks the compiler.

Try it online!

# Answer
> 1 votes
## AutoHotkey, 5 bytes

\` is the escape character. You can only escape a " when assigning it to a variable.

\n\*/ prevents it from being commented out or assigned to a variable.

```

*/`"

```

# Answer
> 1 votes
# Husk1, 3 bytes

Try it online!

### Explanation

The newlines force  to be parsed as a supposed built-in, however since it's not (yet) implemented the parsing fails with `unexpected "\9674"` or an error because of empty lines.

**Note:** Initially I tried to force an inference failure, but the type-checking is done lazily and one can easily "un-break" programs with adding a valid main function.

---

1: The code might work at some point in the future. So to be precise any version of Husk as of before the date of this post (ie. at least up to commit 0806b9d).

# Answer
> 1 votes
# Keg, ~~3~~ 4 bytes

Fixed a for loop bug noted by @Jono2906

```

)ø.

```

Try it online!

## Explanation

```
\n    Terminate a line-comment
)     End a for loop
 ø    Clear the stack
  .   Try to print the TOS item, which will create an error to the program.

```

# Answer
> 1 votes
# Unreadable, 2 bytes

```
''

```

Try it online!

All Unreadable commands must be of the form `'""…"`, with one `'` followed by 1 to 10 `"`s. Having two successive `'`s anywhere in the program leads to `error: parser failed: invalid command (0): '`.

# Answer
> 1 votes
# Lean Mean Bean Machine, 8 bytes

```
OO
0/
&

```

Try it online!

Begins with a leading newline.

Unfortunately this is basically an entire invalid program, but it can be inserted into larger programs, and there's no way to my knowledge to prevent the runtime error.

LMBM creates a 'marble' (aka instruction pointer) at every `O` in the code, and there is no way to prevent this (which now that I think about it causes some issues if you need an `O` in a string). `&` is the division operator in LMBM.

In short, this snippet causes a `ZeroDivisionError: division by zero` runtime error.

# Answer
> 1 votes
# Add++, ~~6~~ 3 bytes

```

";

```

Try it online!

# Answer
> 1 votes
# Chicken, 2 bytes

```
ih

```

Thanks to jimmy23013

# Answer
> 1 votes
# PowerPC for XBox 360, 19 bytes

```
~
J,e~
J,e~
J,e~
J,

```

The operative sequence is `~␊J,`, in which the linefeed may be replaced with any byte less than 32 and the J with any byte congruent to 2 mod 8.

If this sequence appears on a four-byte boundary (which it will, in the above string) on an executable page, it codes an `xdcbt` (prefetch to L1 cache, skipping L2); any (even speculative) jump to it will then break cache coherency, probably leading to a crash soon after. Since the branch predictor even predicts computed jump destinations, this will happen sooner or later, see here.

I wish I had been able to force an all-printable version, but LF is pretty close.

# Answer
> 1 votes
# Pyt, 2 bytes

```
ɬĹ

```

Just one amongst many.

Try it online!

It's pretty simple, actually: Pyt has no comment markers, so every valid character when using Pyt's proprietary encoding (not UTF-8) does something.

ɬ pushes the string "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" Ĺ returns the least common multiple of the top two elements on the stack You can replace ɬ with either ɫ or ʊ (only the lowercase and uppercase letters, respectively), and you can replace Ĺ with the vast majority of the functions in Pyt, as most of them only work on numbers.

There is another 2-byte family of solutions:

```
do

```

where d is any digit (0-9), and o is either ҏ or Ƒ. ҏ palindromizes a string or array and does not work on numbers, and Ƒ flattens the array at the top of the stack, but errors if the top of the stack isn't an array.

And there is a singleton (not in a family of solutions):

```
ɔŕ

```

ɔ clears the stack, and then ŕ pops the top of the stack (and errors out if it is empty).

# Answer
> 1 votes
# Perl, ~~12 bytes~~ 25 bytes

Tried to cut all strings. Not really short.

```

.
"'/%+)}]>#
=pod
=cut
.

```
* First newline to exit comments (there are no multiline comments)
* then `.` in first column to exit format sections
* end strings (there are strings like `"..."`, `'...'` and like `qw/.../` but instead of '/' other chars can be used
* start a POD section (`=pod` at the beginning of the line)
* end the POD section (`=cut` at the beginning of the line)
* `.` is not in any comment and is invalid.

After `__DATA__` or `__END__` there is no code. There starts a data section.

Hope this is correct (my first step on code golf ...)

# Answer
> 0 votes
# Gaia, 3 bytes

```

#“

```

Try it online!

Each line in Gaia is a separate function, so the newline ensures that the code starts at the beginning of a function. Even putting a newline in a string literal will start a new function, since Gaia allows omitting closing quotes. In addition, all functions are parsed before execution, so adding additional functions below won't help.

The `#` is a *meta*, which has to directly follow an operator. At the start of the function, there is no operator, so it's a syntax error.

The  is an opening quote for string literals. It's there because Gaia also allows omitting the opening quote of strings at the start of a function. If this opening quote wasn't here, you could write `#”` which is entirely legal.

# Answer
> 0 votes
# Ly, 6 bytes

```

\""{)

```

(note the leading newline)

The newline prevents line comments, Ly doesn't have block comments, the `\""` ensures that all open string literals will close, and the unmatched brackets raise the error.

# Answer
> 0 votes
# FRACTRAN, 2 bytes

```
()

```

Try it online!

Since FRACTRAN doesn't have any way of including comments or literals (AFAICT), this will always error any valid program, since all valid programs must be a valid fraction, and this string can never be part of a valid fraction.

# Answer
> 0 votes
# Ink, 5 bytes

```

*/{}
```

Leading newline ends single-line comments.
`*/` ends multi-line comments. Thanks to the leading newline, you can't put a `/` in front of it to make it the start of a comment rather than the end of one.
`{` and `}` enclose things meant to be parsed, rather than simply printed. If there's nothing between them, the compiler gets sad because it `Expected some kind of logic, conditional or sequence within braces: { ... } but saw '}'`. This happens even inside string literals, so there's no need to check if we're inside one of those.

# Answer
> 0 votes
# Turing Machine Code 5 bytes

Assuming block editing isn't allowed:

```
0

```

Or with the symbols showing:

```
< cr >< lf >
0
< cr >< lf >

```

Without block editing, it is impossible to stick this behind the comment symbol (';'), as the '0' will end up on the next line anyway. There is no block commenting in Turing Machine Code, a fact that is taken advantage of in other answers here as well. This patch of code would not only not run, it would kill the whole program before it can begin to execute, no matter where it is placed.

Try it online!

# Answer
> 0 votes
# Milky Way, 2 bytes

Tries to execute an undefined opcode. Milky Way does not have comments. The newline is for ending strings.

```

)

```

Try it online!

# Answer
> 0 votes
# Zig 0.6.0, 2 bytes

```

`

```

(`\n``)

A newline will reset the tokenizer state, escaping any comments or multiline strings and erroring for single line strings. Backticks are not a valid character except in strings.

Try it online!

# Answer
> 0 votes
# KonamiCode, 3 bytes

`]()`

Explanation:

First, the \] closes any comments this string might be placed in. Then, the () attempts to pass an empty number to the comment closing sign. Using the pynami interpreter, this will always result in an "This command doesn't have a parameter!" error, even if you put it inside a comment.

---
Tags: code-challenge, restricted-source
---