# Introduction

Everyone's first program outputs Hello World!. This program should be very simple, that's all you have to do.

# Challenge

Output the string Hello World! to the STDERR.

# Rules

1. If your language doesn't support STDERR or STDERR doesn't exist for it, you can output it to it's corresponding error system.
2. You can't output anything else to STDERR except for Hello World!.
3. You can't output anything to STDOUT or take any input from STDIN
4. You can't read any content from files.

This is , so the shortest answer in bytes wins.

• PHP has stderr. – user42682 Jan 24 '16 at 21:57
• @Mego I personally don't think it's a duplicate. Seeing as how the output method is required to be different, programs cannot just be stolen from that challenge. – ETHproductions Jan 24 '16 at 22:15
• @ETHproductions IMO the different output method (STDERR vs STDOUT) isn't sufficiently different enough to make it not a dupe. Most of the answers could be trivially transformed by writing to STDERR or file stream 1 instead of STDOUT. – user45941 Jan 24 '16 at 22:16
• I agree with @Mego and therefore closed this as duplicate, not unclear (despite what the banner says). The question is not unclear by any stretch of the imagination. – mınxomaτ Jan 24 '16 at 22:32
• Note: The comma in Hello, World! is not necessary. Please do yourself a favor and save a byte. – ETHproductions Jan 24 '16 at 22:59

# Japt, 17 bytes

Currently winning! Let's hope Jelly doesn't pop in with an 11-byte answer...

OxÈ*w'HÁM W?ld!'


The ? should be the literal byte 8E. Test it online!

(STDERR is found below the "Upload a file" line in red text.)

### How it works

  È*w'HÁM W?ld!'  // Decompress this string. Returns "throw'Hello World!'"
Ox                 // Evaluate as JavaScript code. Throws the error.
// Implicit: Error is caught by interpreter and sent to STDERR.


Alternate version:

$throw$HÁM W?ld!

• – Downgoat Jan 25 '16 at 2:13
• @Doᴡɴɢᴏᴀᴛ ew ham world. Or should I say "È*w"? – Cyoce Jan 25 '16 at 6:38

## zsh, 2120 19 bytes

<<<Hello\ World!>&2


This is a zsh-specific feature; won't work in bash.

Thanks to @FlagAsSpam and @Dennis for a byte each!

# JavaScript, 30 bytes

console.error("Hello, World!")


An alternative JavaScript answer, using console.error.

# Java 8, 75 37 bytes

Thanks to @GamrCorps for slicing the code size almost exactly in half and showing me how to use lambda!

()->System.err.print("Hello World!");

Using interface because it makes the main declaration shorter. c:

• darn it, you beat me to it! – GamrCorps Jan 24 '16 at 22:02
• Hint: Java 8 and use a lambda – GamrCorps Jan 24 '16 at 22:03
• @feersum I think we by default allow functions unless the question says "full program". – lirtosiast Jan 24 '16 at 22:06
• @FlagAsSpam ()->System.err.print("Hello, World!"); should work – GamrCorps Jan 24 '16 at 22:12
• Why the down vote? – Addison Crump Jan 24 '16 at 23:17

# JavaScript, 19 bytes

throw"Hello World!"


Yes. It's that simple. Try it in the browser console on any page.

• Would using bota be shorter (ie throw botaBase64 String Here)? idk, i haven't tried it. – MayorMonty Jan 24 '16 at 22:09
• @SpeedyNinja No, the ! and space will each cause an error if you try to compress it. It wouldn't be worth it anyway. – ETHproductions Jan 24 '16 at 22:09
• Oh ASCII, you're so helpless, ;) – MayorMonty Jan 24 '16 at 22:10
• whyyy doncha adda stack snippet!? :P – cat Jan 24 '16 at 22:57
• @cat It doesn't really work with a stack snippet, outputting instead uncaught exception: Hello World! to an error in the console. – ETHproductions Jan 24 '16 at 23:02

## C, 35 bytes

main(){write(2,"Hello World!",12);}


write writes to a file descriptor. STDERR is file descriptor 2, and 12 is the length of the string "Hello World!".

## AutoIt, 33 bytes

ConsoleWriteError("Hello World!")


# R, 23 bytes

message("Hello World!")


The message function writes to STDERR.

## Ruby, 18 bytes

warn"Hello World!"


This only works if warnings are on (which is the default).

• Works for me with irb. – user45941 Jan 24 '16 at 22:23

# C++, 53 bytes

#include<iostream>
main(){std::cerr<<"Hello World!";}


You can try it online if you feel so inclined.

# Python 2, 36 bytes

import os
os.write(2,'Hello World!')


Despite being based on a Unix syscall, this works as well on Windows.

# Bash, 2421 20 bytes

Saved 3 bytes thanks to @Neil, then another from @Dennis!

echo Hello World!>&2 

>&2 pushes the output to STDERR.

• Drop the comma, use backslash to quote the !, and move the >&2 to the end without the space, to save 3 bytes. – Neil Jan 24 '16 at 22:32
• Escaping the exclamation point is not required inside a script. – Dennis Jan 24 '16 at 22:33

## Rust, 73 72 bytes

use std::io::Write;fn main(){std::io::stderr().write(b"Hello, World!");}


Rust is as long as ever...

Thanks to @ICanHazHats for saving a byte!

• use std::io::Write;fn main(){std::io::stderr().write(b"Hello, World!");} is 72 bytes and is working with Rust 1.3 (I don't know how outdated that is) – Liam Jan 24 '16 at 23:10
• @ICanHazHats That does work on the nightly. Thanks! – Doorknob Jan 24 '16 at 23:12
• Don't thank me, I yanked it straight from stackoverflow stackoverflow.com/questions/27588416/… – Liam Jan 24 '16 at 23:14
• These days you can write fn main(){eprint!("Hello, World!")}, but not that it matters as this challenge is closed. – Konrad Borowski Jul 5 '18 at 4:43

# Matlab, 21 bytes

error('Hello World!')


# Julia, 28 bytes

print(STDERR,"Hello World!")


Does what it looks like it does. STDERR is a built-in constant that refers to the standard error stream and print takes an optional argument specifying the stream.

Note that using error() prints out a bunch of extra garbage.

# AppleScript, 19 bytes

error"Hello World!"

...pretty self-explanatory.

• Like AppleScript always is. – Elliot A. Jan 25 '16 at 0:46
• @ElliotA. Amen. – Addison Crump Jan 25 '16 at 0:49

# PHP, 36 bytes

I don't know much PHP, but here goes...

<?php fwrite(STDERR,"Hello World!");


Tested on ideone.com.

## Chapel, 29 bytes

stderr.write("Hello World!");


This language is probably overkill.

• This language is overkill, unless you have a SuperComputer. Do you have a supercomputer, Phi? – cat Jan 24 '16 at 22:56
• @cat "The only supercomputer I have is my mind." (As a serious answer, no, I just put Chapel on my laptop.) – PhiNotPi Jan 24 '16 at 23:14
• You shoulda used multithreading for this answer. One thread per character of output, because why not!? – cat Jan 24 '16 at 23:15

# Python 3, 33 bytes

open(2,'w').write('Hello World!')

• which py3 version are you running this on? When I try this I get an invalid handle error. (on second thoughts, it's more likely an OS problem) – FlipTack Dec 13 '16 at 23:09
• @Flp.Tkc It works on both Linux and Windows for me. The stderr = 2 is a feature from Unix, but Python developers ported this special case to Windows. – feersum Dec 13 '16 at 23:35

# C#, 95 bytes

using System;class M{public static void Main(string[]a){Console.Error.Write("Hello World!");}}


I'm trying to learn this langauge but god, it's verbose.

Ungolfed:

using System;

class MainClass {
public static void Main (string[] args) {
Console.Error.Write ("Hello World!");
}
}

• Congrats on exactly 1k rep! – ETHproductions Jan 24 '16 at 23:39
• @ETHproductions thanks! I previously had 1.2k but then I gave a bounty for an answer in SPL :P – cat Jan 24 '16 at 23:46

# Pascal (FP/GP), 51 bytes

program h;begin writeln(StdErr,'Hello World!');end.


# Pike, 35 bytes

int main(){werror("Hello World!");}


Looks like C, isn't C. Is interpreted.

We can make this compile as ANSI C like this:

#include <stdio.h>
# ifndef __PIKE__
#   define werror(x) fputs(x, stderr)
# endif

int main() {
werror("Hello World!");
}

• I count 35 bytes... – Addison Crump Jan 24 '16 at 23:03
• @FlagAsSpam I can count today!! – cat Jan 24 '16 at 23:11

## Perl, 25 24 bytes

say stderr"Hello World!"


Requires version 5.10 or later.

Thanks to @FlagAsSpam for a byte!

• Can you remove the space in stderr "Hello World!" (drop the comma). – Addison Crump Jan 24 '16 at 23:09
• Well, I got ninja'd! – cat Jan 24 '16 at 23:09
• @FlagAsSpam Nope. (This time for real.) – Doorknob Jan 24 '16 at 23:10
• Hmm. It's really weird - some languages parse " as a parenthetical as well, allowing for some interesting stuff (notably in return""). I just generally put that down, now, because it's a lot of langs that have that. – Addison Crump Jan 24 '16 at 23:11
• Actually, you can remove the space (tested on perl 5.18.2). – Addison Crump Jan 24 '16 at 23:13

# Forth, 65 bytes

Shorter than factor!

outfile-id stderr to outfile-id ." Hello World!" cr to outfile-id


# Moonscript, 40 bytes

io.stderr.write io.stderr,"Hello World!"


CoffeeScript for Lua... because Lua is ugly as hell!

# Lua5.2, 41 bytes

io.stderr.write(io.stderr,"Hello World!")


Cheeky golfed version of the transpilation of my Moonscript answer.

# Go, 39383770 69 bytes

package m;import."os";func main(){Stderr.WriteString("Hello World!")}

• This is 37 bytes. – Addison Crump Jan 24 '16 at 22:29
• @FlagAsSpam I forgot there was a trailing space, oops! The spec really isn't clear on whether I can give a snippet (this) or a full program -- the C++ one is a full program, this isn't, but it's not said. – cat Jan 24 '16 at 22:32
• Snippets are never a valid form of answer. Usually programs or functions are, but the question asks for a program. – feersum Jan 24 '16 at 22:33
• @feersum you're right, but it's only mentioned offhandedly, not in the actual spec list. – cat Jan 24 '16 at 22:34
• Drop the comma. – Addison Crump Jan 24 '16 at 22:38

# Mathematica, 35 bytes

"stderr"~WriteString~"Hello World!"


Quite simple.

• This doesn't output an error message. I think you need to use Message. Anyway, messages appear in red font so as to be easily distinguished from output. – DavidC Jan 25 '16 at 0:08
• @DavidC Run this as a script. – LegionMammal978 Jan 25 '16 at 0:53
• I do not know what a script is. – DavidC Jan 25 '16 at 3:32
• @DavidC Just put the code in a file, and run MathematicaScript -script <file>. – LegionMammal978 Jan 25 '16 at 11:41

# Microsoft Windows Batch (also works in Wine), 22 bytes

echo Hello World! 1>&2


# Factor, 67 bytes

"Let's use a modernisation of Forth", I said. "It will be fun!" I said.

Yea, the whitespace is needed.

error-stream get [ "Hello World!" print flush ] with-output-stream*
`