Hello world/Standard error: Difference between revisions

(Add Zig example)
 
(39 intermediate revisions by 26 users not shown)
Line 6:
{{omit from|Brainf***}}
{{omit from|dc|Always prints to standard output.}}
{{omit from|EasyLang|EasyLang has an error variable, but it cannot be set manually. And it always prints to standard output.}}
{{omit from|GUISS|Cannot customize error messages}}
{{omit from|Integer BASIC}}
Line 31 ⟶ 32:
{{trans|Python}}
 
<langsyntaxhighlight lang="11l">:stderr.write("Goodbye, World!\n")</langsyntaxhighlight>
 
=={{header|4DOS Batch}}==
<syntaxhighlight lang ="4dos">echoerr Goodbye, World!</langsyntaxhighlight>
 
=={{header|AArch64 Assembly}}==
<langsyntaxhighlight ARM_Assemblylang="arm_assembly">.equ STDERR, 2
.equ SVC_WRITE, 64
.equ SVC_EXIT, 93
Line 57 ⟶ 58:
svc #0 // exit(0);
 
msg: .ascii "Goodbye World!\n"</langsyntaxhighlight>
 
=={{header|Ada}}==
<langsyntaxhighlight lang="ada">with Ada.Text_IO; use Ada.Text_IO;
 
procedure Goodbye_World is
begin
Put_Line (Standard_Error, "Goodbye, World!");
end Goodbye_World;</langsyntaxhighlight>
 
=={{header|Agena}}==
<langsyntaxhighlight lang="agena">io.write( io.stderr, "Goodbye, World!\n" )</langsyntaxhighlight>
 
=={{header|Aime}}==
<langsyntaxhighlight lang="aime">v_text("Goodbye, World!\n");</langsyntaxhighlight>
 
=={{header|ALGOL 68}}==
Line 82 ⟶ 83:
 
{{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download 1.8-8d] - note that printf and putf were not ported into ELLA's libraries.}}
<langsyntaxhighlight lang="algol68">main:(
put(stand error, ("Goodbye, World!", new line))
)</langsyntaxhighlight>
{{out}}
<pre>
Line 91 ⟶ 92:
 
=={{header|Argile}}==
<langsyntaxhighlight Argilelang="argile">use std
eprint "Goodbye, World!"</langsyntaxhighlight>
or
<langsyntaxhighlight Argilelang="argile">use std
eprintf "Goodbye, World!\n"</langsyntaxhighlight>
or
<langsyntaxhighlight Argilelang="argile">use std
fprintf stderr "Goodbye, World!\n"</langsyntaxhighlight>
 
=={{header|ARM Assembly}}==
{{works with|as|Raspberry Pi}}
 
<syntaxhighlight lang="arm assembly">
<lang ARM Assembly>
/* ARM assembly Raspberry PI */
/* program hellowordLP.s */
Line 123 ⟶ 125:
iAdrMessage: .int szMessage
 
</syntaxhighlight>
</lang>
 
=={{header|Arturo}}==
<langsyntaxhighlight lang="arturo">panic "Goodbye, World!"</langsyntaxhighlight>
 
=={{header|ATS}}==
<langsyntaxhighlight ATSlang="ats">implement main0 () = fprint (stderr_ref, "Goodbye, World!\n")</langsyntaxhighlight>
 
=={{header|AutoHotkey}}==
requires [http://github.com/tinku99/ahkdll/tree/master AutoHotkey_N]
implementation.
<langsyntaxhighlight lang="autohotkey">; c:\> autohotkey.exe stderr.ahk 2> error.txt
FileAppend, Goodbye`, World!, stderr ; requires AutoHotkey_N</langsyntaxhighlight>
 
Or with the current AutoHotkey_L:
{{works with|AutoHotkey_L}}
(documentation on this behavior: http://www.autohotkey.net/~Lexikos/AutoHotkey_L/docs/commands/FileAppend.htm)
<langsyntaxhighlight AutoHotkeylang="autohotkey">FileAppend, Goodbye`, World!, *</langsyntaxhighlight>
 
=={{header|AutoIt}}==
<langsyntaxhighlight AutoItlang="autoit">ConsoleWriteError("Goodbye, World!" & @CRLF)</langsyntaxhighlight>
 
=={{header|Avail}}==
<syntaxhighlight lang="avail">Error: "Goodbye, World!";</syntaxhighlight>
 
=={{header|AWK}}==
Line 149 ⟶ 154:
pipe it through a shell command:
 
<langsyntaxhighlight lang="awk">BEGIN {
print "Goodbye, World!"| "cat 1>&2"
}</langsyntaxhighlight>
 
Or write to /dev/stderr:
Line 158 ⟶ 163:
{{works with|mawk}}
{{works with|nawk}}
<langsyntaxhighlight lang="awk">BEGIN {
print "Goodbye, World!" > "/dev/stderr"
}</langsyntaxhighlight>
 
With ''gawk'', ''mawk'' and ''nawk'': a special feature
Line 174 ⟶ 179:
 
=={{header|BASIC}}==
==={{header|Applesoft BASIC}}===
 
<syntaxhighlight lang="basic">REM FILE-BASED OUTPUT REDIRECTION
0 D$ = CHR$ (4):F$ = "DEV/STDERR": PRINT D$"OPEN"F$: PRINT D$"CLOSE"F$: PRINT D$"APPEND"F$: PRINT D$"WRITE"F$
1 PRINT "GOODBYE, WORLD!"
2 PRINT D$"CLOSE"F$</syntaxhighlight><syntaxhighlight lang="basic">REM OUTPUT ROUTINE REDIRECTION
3 FOR I = 768 TO 802: READ B: POKE I,B: NEXT : POKE 54,0: POKE 55,3: CALL 1002: DATA 72,173,34,3,208,8,169,191,141,34,3,32,240,253,104,201,141,208,12,169,0,141,34,3,169,135,32,240,253,169,141,76,240,253,0
4 O$ = CHR$ (111):D$ = CHR$ (100): PRINT "G" + O$ + O$ + D$ + CHR$ (98) + CHR$ (121) + CHR$ (101) + ", W" + O$ + CHR$ (114) + CHR$ (108) + D$ + "!"
5 POKE 54,240: POKE 55,253: CALL 1002</syntaxhighlight>
==={{header|BaCon}}===
<langsyntaxhighlight lang="freebasic">EPRINT "Goodbye, World!"</langsyntaxhighlight>
 
==={{header|ZX Spectrum BasicBASIC256}}===
<syntaxhighlight lang="basic256">onerror errortrap
throwerror 99
end
 
errortrap:
print "Goodbye World!"
return</syntaxhighlight>
 
==={{header|Chipmunk Basic}}===
{{works with|Chipmunk Basic|3.6.4}}
<syntaxhighlight lang="qbasic">10 cls
20 on error goto 50
30 error 99 : we force an error
40 end
50 rem ManejoErrores
60 print "Goodbye World!"
70 cont</syntaxhighlight>
 
==={{header|QBasic}}===
<syntaxhighlight lang="basic">ON ERROR GOTO ManejoErrores
ERROR 99
END
 
ManejoErrores:
PRINT "Googbye World!"
RESUME</syntaxhighlight>
 
==={{header|ZX Spectrum Basic}}===
On the ZX Spectrum, standard error is on stream 1:
 
<syntaxhighlight lang="zxbasic">10 PRINT #1;"Goodbye, World!"
<lang zxbasic>
20 PAUSE 50: REM allow time for the user to see the error message</syntaxhighlight>
10 PRINT #1;"Goodbye, World!"
20 PAUSE 50: REM allow time for the user to see the error message
</lang>
 
=={{header|Batch File}}==
<langsyntaxhighlight lang="dos">1>&2 echo Goodbye, World!</langsyntaxhighlight>
The redirection operator <code>1>&2</code> causes all output on stream 1 (standard out) to be redirected to stream 2 (standard error).
The redirection can be moved to the end of the line, too.
Line 195 ⟶ 232:
{{works with|BBC BASIC for Windows}}
The program must be compiled as a console application for this to work.
<langsyntaxhighlight lang="bbcbasic"> STD_ERROR_HANDLE = -12
SYS "GetStdHandle", STD_ERROR_HANDLE TO @hfile%(1)
PRINT #13, "Goodbye, World!"
QUIT</langsyntaxhighlight>
 
=={{header|Blade}}==
<syntaxhighlight lang="blade">import io
io.stderr.write('Goodbye, World!')</syntaxhighlight>
 
=={{header|C}}==
Unlike puts(), fputs() does not append a terminal newline.
<langsyntaxhighlight lang="c">#include <stdio.h>
 
int main()
Line 210 ⟶ 251:
 
return 0;
}</langsyntaxhighlight>
 
=={{header|C sharp|C#}}==
<langsyntaxhighlight lang="csharp">static class StdErr
{
static void Main(string[] args)
Line 219 ⟶ 260:
Console.Error.WriteLine("Goodbye, World!");
}
}</langsyntaxhighlight>
 
=={{header|C++}}==
<langsyntaxhighlight lang="cpp">#include <iostream>
 
int main() {
std::cerr << "Goodbye, World!\n";
}</langsyntaxhighlight>
 
=={{header|Clojure}}==
<langsyntaxhighlight lang="lisp">(binding [*out* *err*]
(println "Goodbye, world!"))</langsyntaxhighlight>
 
=={{header|CLU}}==
<syntaxhighlight lang="clu">start_up = proc ()
stream$putl(stream$error_output(), "Goodbye, World!")
end start_up</syntaxhighlight>
 
=={{header|CMake}}==
Most messages go to standard error.
 
<langsyntaxhighlight lang="cmake">message("Goodbye, World!")</langsyntaxhighlight>
 
The message cannot be a keyword; <code>message("STATUS")</code> never prints "STATUS", but <code>message("" "STATUS")</code> does work.
Line 243 ⟶ 289:
{{works with|OpenCOBOL}}
 
<langsyntaxhighlight lang="cobol"> program-id. ehello.
procedure division.
display "Goodbye, world!" upon syserr.
stop run.</langsyntaxhighlight>
 
=={{header|CoffeeScript}}==
{{trans|JavaScript}}
{{works with|Node.js}}
<langsyntaxhighlight lang="coffeescript">console.warn "Goodbye, World!"</langsyntaxhighlight>
 
=={{header|Common Lisp}}==
<langsyntaxhighlight lang="lisp">(format *error-output* "Goodbye, world!~%")</langsyntaxhighlight>
 
=={{header|D}}==
<langsyntaxhighlight lang="d">import std.stdio;
 
void main () {
stderr.writeln("Goodbye, World!");
}</langsyntaxhighlight>
===Alternative Version===
{{libheader|tango}}
 
<langsyntaxhighlight lang="d">import tango.io.Stdout;
 
void main () {
Stderr("Goodbye, World!").newline;
}</langsyntaxhighlight>
 
=={{header|Déjà VuDart}}==
<syntaxhighlight lang="dart">import 'dart:io';
<lang dejavu>!write-fragment!stderr !encode!utf-8 "Goodbye, World!\n"</lang>
 
void main() {
stderr.writeln('Goodbye, World!');
}</syntaxhighlight>
 
=={{header|Delphi}}==
<langsyntaxhighlight Delphilang="delphi">program Project1;
 
{$APPTYPE CONSOLE}
Line 281 ⟶ 331:
begin
WriteLn(ErrOutput, 'Goodbye, World!');
end.</langsyntaxhighlight>
 
=={{header|dt}}==
<syntaxhighlight lang="dt">"Goodbye, World!" epl</syntaxhighlight>
 
=={{header|Dylan.NET}}==
Line 292 ⟶ 345:
{{works with|.NET|4.5}}
One Line version:
<langsyntaxhighlight Dylanlang="dylan.NETnet">Console::get_Error()::WriteLine("Goodbye World!")</langsyntaxhighlight>
Goodbye World Program:
<syntaxhighlight lang="dylan.net">
<lang Dylan.NET>
//compile using the new dylan.NET v, 11.5.1.2 or later
//use mono to run the compiler
Line 311 ⟶ 364:
 
end class
</syntaxhighlight>
</lang>
 
=={{header|Déjà Vu}}==
<syntaxhighlight lang="dejavu">!write-fragment!stderr !encode!utf-8 "Goodbye, World!\n"</syntaxhighlight>
 
=={{header|E}}==
 
<langsyntaxhighlight lang="e">stderr.println("Goodbye, World!")</langsyntaxhighlight>
 
=={{header|Elixir}}==
<langsyntaxhighlight lang="elixir">IO.puts :stderr, "Goodbye, World!"</langsyntaxhighlight>
 
=={{header|Emacs Lisp}}==
 
<lang Emacs Lisp>
In batch mode, <code>message</code> actually prints to standard error:
(error "Goodbye, World!")
 
</lang>
<syntaxhighlight lang="lisp">(message "Goodbye, World!")</syntaxhighlight>
<b>Output:</b>
 
<pre>
For greater control, <code>princ</code> can be used with a special printing function:
Goodbye, World!
 
</pre>
<syntaxhighlight lang="lisp">(princ "Goodbye, World!\n" 'external-debugging-output)</syntaxhighlight>
 
=={{header|EMal}}==
<syntaxhighlight lang="emal">logLine("Goodbye, World!")</syntaxhighlight>
<syntaxhighlight lang="emal">log("Goodbye, World!")</syntaxhighlight>
 
=={{header|Erlang}}==
<langsyntaxhighlight lang="erlang">io:put_chars(standard_error, "Goodbye, World!\n").</langsyntaxhighlight>
 
=={{header|Euphoria}}==
<langsyntaxhighlight Euphorialang="euphoria">puts(2,"Goodbye, world!\n") -- 2 means output to 'standard error'</langsyntaxhighlight>
 
=={{header|F_Sharp|F#}}==
<langsyntaxhighlight lang="fsharp">eprintfn "%s" "Goodbye, World!"</langsyntaxhighlight>
or you can use the .Net classes
<langsyntaxhighlight lang="fsharp">System.Console.Error.WriteLine("Goodbye, World!");</langsyntaxhighlight>
 
=={{header|Factor}}==
Start Factor in a terminal for this:
<langsyntaxhighlight lang="factor">error-stream get [ "Goodbye, World! bbl, crashing" print flush ] with-output-stream*</langsyntaxhighlight>
 
=={{header|Fantom}}==
 
<langsyntaxhighlight lang="fantom">
class Main
{
Line 354 ⟶ 415:
}
}
</syntaxhighlight>
</lang>
 
=={{header|Forth}}==
{{works with|GNU Forth}}
<langsyntaxhighlight lang="forth">outfile-id
stderr to outfile-id
." Goodbye, World!" cr
to outfile-id</langsyntaxhighlight>
 
=={{header|Fortran}}==
Line 370 ⟶ 431:
which defines the parameter ERROR_UNIT.
 
<langsyntaxhighlight lang="fortran">program StdErr
! Fortran 2003
use iso_fortran_env
Line 378 ⟶ 439:
write (ERROR_UNIT, *) "Goodbye, World!"
end program StdErr</langsyntaxhighlight>
 
=={{header|FreeBASIC}}==
<langsyntaxhighlight lang="freebasic">' FB 1.05.0 Win64
 
Open Err As #1
Print #1, "Goodbye World!"
Close #1
Sleep</langsyntaxhighlight>
 
=={{header|Frink}}==
<langsyntaxhighlight lang="frink">
staticJava["java.lang.System","err"].println["Goodbye, World!"]
</syntaxhighlight>
</lang>
 
=={{header|Genie}}==
<langsyntaxhighlight lang="genie">[indent=4]
/*
Hello, to Standard error, in Genie
Line 401 ⟶ 462:
 
init
stderr.printf("%s\n", "Goodbye, World!")</langsyntaxhighlight>
 
{{out}}
Line 410 ⟶ 471:
=={{header|Go}}==
Built in println now goes to stderr.
<langsyntaxhighlight lang="go">package main
func main() { println("Goodbye, World!") }</langsyntaxhighlight>
but the builtin print() and println() functions are not guaranteed to stay in the language. So you should probably use
<langsyntaxhighlight lang="go">package main
import ("fmt"; "os")
func main() { fmt.Fprintln(os.Stderr, "Goodbye, World!") }</langsyntaxhighlight>
 
=={{header|Groovy}}==
<langsyntaxhighlight lang="groovy">System.err.println("Goodbye, World!")</langsyntaxhighlight>
 
=={{header|Haskell}}==
<langsyntaxhighlight lang="haskell">import System.IO
main = hPutStrLn stderr "Goodbye, World!"</langsyntaxhighlight>
 
=={{header|Huginn}}==
<langsyntaxhighlight lang="huginn">#! /bin/sh
exec huginn --no-argv -E "${0}" "${@}"
#! huginn
Line 434 ⟶ 495:
os.stderr().write( "Goodbye, World!\n" );
return ( 0 );
}</langsyntaxhighlight>
 
=={{header|Icon}} and {{header|Unicon}}==
<langsyntaxhighlight lang="icon">procedure main()
write(&errout, "Goodbye World" )
end</langsyntaxhighlight>
 
=={{header|J}}==
<syntaxhighlight lang="j"> stderr
<lang j>stderr =: 1!:2&4
1!:2&5
stderr 'Goodbye, World!'</lang>
 
0 0 $ stderr 'Goodbye, World!'</syntaxhighlight>
 
=={{header|Java}}==
<langsyntaxhighlight lang="java">public class Err{
public static void main(String[] args){
System.err.println("Goodbye, World!");
}
}</langsyntaxhighlight>
 
=={{header|JavaScript}}==
{{works with|JScript}} and only with <code>cscript.exe</code>
<langsyntaxhighlight lang="javascript">WScript.StdErr.WriteLine("Goodbye, World!");</langsyntaxhighlight>
 
{{works with|Node.js}}
<langsyntaxhighlight lang="javascript">console.warn("Goodbye, World!")</langsyntaxhighlight>
 
{{works with|Firefox}}
<langsyntaxhighlight lang="javascript">console.error("Goodbye, World!")//only works if console object exists</langsyntaxhighlight>
OR
<langsyntaxhighlight lang="javascript">throw new Error("Goodbye, World!")//Should work in any browser</langsyntaxhighlight>
 
=={{header|jqJoy}}==
<syntaxhighlight lang="joy">stderr "Goodbye, World!\n" fputchars pop.</syntaxhighlight>
 
<lang jq>jq -n —-arg s 'Goodbye, World!' '$s | stderr | empty'</lang>
 
=={{header|jq}}==
<syntaxhighlight lang="jq">jq -n —-arg s 'Goodbye, World!' '$s | stderr | empty'</syntaxhighlight>
`stderr` copies its input to STDERR before passing it along the pipeline, and hence the occurrence of `empty` above.
 
=={{header|Julia}}==
 
<lang julia>println(STDERR, "Goodbye, World!")</lang>
Julia 0.7 or newer:
 
<syntaxhighlight lang="julia">println(stderr, "Goodbye, World!")</syntaxhighlight>
 
In versions prior to Julia 0.7, the standard I/O streams were capitalized:
 
<syntaxhighlight lang="julia">println(STDERR, "Goodbye, World!")</syntaxhighlight>
 
=={{header|Kotlin}}==
<langsyntaxhighlight lang="scala">fun main(args: Array<String>) {
System.err.println("Goodbye, World!")
}</langsyntaxhighlight>
 
=={{header|Lang}}==
<syntaxhighlight lang="lang">fn.errorln(Goodbye, World!)</syntaxhighlight>
 
=={{header|langur}}==
<langsyntaxhighlight lang="langur">writelnErr "goodbyeGoodbye, peopleworld."</langsyntaxhighlight>
 
=={{header|Lasso}}==
<langsyntaxhighlight Lassolang="lasso">define stderr(s::string) => {
file_stderr->writeBytes(#s->asBytes)
}
 
stderr('Goodbye, World!')</langsyntaxhighlight>
 
=={{header|Lingo}}==
*Windows:
{{libheader|CommandLine Xtra}}
<langsyntaxhighlight lang="lingo">-- print to standard error
stdErr("Goodbye, World!", TRUE)
 
-- print to the Windows debug console (shown in realtime e.g. in Systernal's DebugView)
dbgPrint("Goodbye, World!")</langsyntaxhighlight>
 
*Mac OS X:
{{libheader|Shell Xtra}}
<langsyntaxhighlight lang="lingo">sx = xtra("Shell").new()
 
-- print to standard error
Line 505 ⟶ 579:
 
-- print to system.log (shown in realtime e.g. in Konsole.app)
sx.shell_cmd("logger Goodbye, World!")</langsyntaxhighlight>
 
=={{header|Lean}}==
In lean4
<syntaxhighlight lang="lean4">
def main : IO Unit := do
let stderr ← IO.getStderr
stderr.putStrLn s!"Goodbye, World!"
</syntaxhighlight>
=={{header|LLVM}}==
<langsyntaxhighlight lang="llvm">; This is not strictly LLVM, as it uses the C library function "printf".
; LLVM does not provide a way to print values, so the alternative would be
; to just load the string into memory, and that would be boring.
Line 532 ⟶ 613:
;-- exit
ret i32 0
}</langsyntaxhighlight>
{{out}}
<pre>Goodbye, world!</pre>
Line 538 ⟶ 619:
=={{header|Logtalk}}==
The stream alias "user_error" can be used to print to the "standard error" stream.
<langsyntaxhighlight lang="logtalk">
:- object(error_message).
 
Line 546 ⟶ 627:
 
:- end_object.
</syntaxhighlight>
</lang>
 
=={{header|Lua}}==
<langsyntaxhighlight lang="lua">io.stderr:write("Goodbye, World!\n")</langsyntaxhighlight>
 
=={{header|m4}}==
<langsyntaxhighlight lang="m4">errprint(`Goodbye, World!
')dnl</langsyntaxhighlight>
 
=={{header|MANOOL}}==
<langsyntaxhighlight MANOOLlang="manool">{{extern "manool.org.18/std/0.3/all"} in Err.WriteLine["Goodbye, World!"]}</langsyntaxhighlight>
 
=={{header|Maple}}==
<syntaxhighlight lang="maple">
<lang Maple>
error "Goodbye World"
</syntaxhighlight>
</lang>
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">Write[Streams["stderr"], "Goodbye, World!"]</langsyntaxhighlight>
 
=={{header|MATLAB}} / {{header|Octave}}==
This prints to standard error, and continues execution
<langsyntaxhighlight MATLABlang="matlab">fprintf(2,'Goodbye, World!')</langsyntaxhighlight>
This will not stop further execution, if called from within a script or function.
<syntaxhighlight lang MATLAB="matlab">error 'Goodbye, World!'</langsyntaxhighlight>
 
=={{header|Mercury}}==
<syntaxhighlight lang="text">
:- module hello_error.
:- interface.
Line 585 ⟶ 666:
io.stderr_stream(Stderr, !IO),
io.write_string(Stderr, "Goodbye, World!\n", !IO).
</syntaxhighlight>
</lang>
 
=={{header|Metafont}}==
Metafont has no a real way to send a text to the standard output/error nor to a file. Anyway it exists the <code>errmessage</code> command which will output an error message and prompt the user for action (suspending the interpretation of the source).
 
<langsyntaxhighlight lang="metafont">errmessage "Error";
message "...going on..."; % if the user decides to go on and not to stop
% the program because of the error.</langsyntaxhighlight>
 
=={{header|min}}==
{{works with|min|0.37.0}}
Currently, ''min'' has three possibilities for outputting to stderr:
<syntaxhighlight lang="min">"Goodbye, World!" warn!
"Goodbye, World!" error!
"Goodbye, World!" fatal!</syntaxhighlight>
The first two depend on the current log level (and are enabled by default). The last one additionally terminates the program.
 
=={{header|ML/I}}==
<langsyntaxhighlight MLlang="ml/Ii">MCSET S4=1
MCNOTE Goodbye, World!</langsyntaxhighlight>
 
=={{header|Miranda}}==
<syntaxhighlight lang="miranda">main :: [sys_message]
main = [Stderr "Hello, world!\n"]</syntaxhighlight>
 
=={{header|Modula-2}}==
<langsyntaxhighlight lang="modula2">MODULE HelloErr;
IMPORT StdError;
 
Line 605 ⟶ 698:
StdError.WriteString('Goodbye, World!');
StdError.WriteLn
END HelloErr.</langsyntaxhighlight>
 
=={{header|Modula-3}}==
<langsyntaxhighlight lang="modula3">MODULE Stderr EXPORTS Main;
 
IMPORT Wr, Stdio;
Line 614 ⟶ 707:
BEGIN
Wr.PutText(Stdio.stderr, "Goodbye, World!\n");
END Stderr.</langsyntaxhighlight>
 
=={{header|N/t/roff}}==
Line 620 ⟶ 713:
The request <code>.tm</code> prints whatever after it, until and including the newline character, to the standard error. The string parsed to it need not be quoted and will never appear on standard output.
 
<langsyntaxhighlight Nlang="n/t/roff">
.tm Goodbye, World!
</syntaxhighlight>
</lang>
 
=={{header|Neko}}==
<syntaxhighlight lang="actionscript">/**
<lang ActionScript>/**
Hello world, to standard error, in Neko
Tectonics:
Line 638 ⟶ 731:
var stderr = $loader.loadprim("std@file_stderr", 0)();
 
file_write(stderr, "Goodbye, World!\n", 0, 16);</langsyntaxhighlight>
 
{{out}}
Line 648 ⟶ 741:
 
=={{header|Nemerle}}==
<langsyntaxhighlight Nemerlelang="nemerle">System.Console.Error.WriteLine("Goodbye, World!");</langsyntaxhighlight>
 
=={{header|NetRexx}}==
<langsyntaxhighlight NetRexxlang="netrexx">/* NetRexx */
 
options replace format comments java crossref savelog symbols binary
 
System.err.println("Goodbye, World!")
</syntaxhighlight>
</lang>
 
=={{header|Nim}}==
<langsyntaxhighlight lang="nim">stderr.writelnwriteLine "Hello World"</langsyntaxhighlight>
 
=={{header|Nu}}==
<syntaxhighlight lang="nu">
print -e "Goodbye, World!"
</syntaxhighlight>
 
=={{header|Oberon-2}}==
Oxford Oberon-2
<langsyntaxhighlight lang="oberon2">
MODULE HelloErr;
IMPORT Err;
Line 669 ⟶ 767:
Err.String("Goodbye, World!");Err.Ln
END HelloErr.
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 683 ⟶ 781:
is an NSString object, and it also prepends a timestamp.
 
<langsyntaxhighlight lang="objc">#import <Foundation/Foundation.h>
 
int main()
Line 691 ⟶ 789:
NSLog(@"Goodbye, World!");
return 0;
}</langsyntaxhighlight>
 
=={{header|OCaml}}==
<langsyntaxhighlight lang="ocaml">prerr_endline "Goodbye, World!"; (* this is how you print a string with newline to stderr *)
Printf.eprintf "Goodbye, World!\n"; (* this is how you would use printf with stderr *)</langsyntaxhighlight>
 
we can also use the ''out_channel'' '''stderr''':
 
<langsyntaxhighlight lang="ocaml">output_string stderr "Goodbye, World!\n";
Printf.fprintf stderr "Goodbye, World!\n";</langsyntaxhighlight>
 
finally the [http://caml.inria.fr/pub/docs/manual-ocaml/libref/Unix.html Unix] module also provides unbuffered write functions:
 
<langsyntaxhighlight lang="ocaml">let msg = "Goodbye, World!\n" in
ignore(Unix.write Unix.stderr msg 0 (String.length msg)) ;;</langsyntaxhighlight>
 
=={{header|Octave}}==
<langsyntaxhighlight lang="octave">fprintf(stderr, "Goodbye, World!\n");</langsyntaxhighlight>
 
=={{header|Oforth}}==
<langsyntaxhighlight Oforthlang="oforth">System.Err "Goodbye, World!" << cr</langsyntaxhighlight>
 
=={{header|Ol}}==
<langsyntaxhighlight lang="scheme">
(print-to stderr "Goodbye, World!")
</syntaxhighlight>
</lang>
 
=={{header|ooRexx}}==
ooRexx provides a .error object that writes output to the standard error stream.
<langsyntaxhighlight ooRexxlang="oorexx">.error~lineout("Goodbye, World!")</langsyntaxhighlight>
The .error object is a proxy that delegates to a backing stream, so this might be redirected.
By default, this delegates to the .stderr object, which can also be used directly.
<langsyntaxhighlight ooRexxlang="oorexx">.stderr~lineout("Goodbye, World!")</langsyntaxhighlight>
or in 'Classic REXX style'
<langsyntaxhighlight ooRexxlang="oorexx">/* REXX ---------------------------------------------------------------
* 07.07.2014 Walter Pachl
* 12.07.2014 WP see Discussion where redirection from within the program is shown
Line 733 ⟶ 831:
Call lineout ,'Hello, world!'
Say 'and this is the error output:'
'type err.txt' </langsyntaxhighlight>
 
=={{header|Oz}}==
<langsyntaxhighlight lang="oz">functor
import Application System
define
{System.showError "Goodbye, World!"}
{Application.exit 0}
end</langsyntaxhighlight>
 
=={{header|PARI/GP}}==
<langsyntaxhighlight lang="parigp">error("Goodbye, World!")</langsyntaxhighlight>
 
=={{header|Pascal}}==
{{Works with|Free Pascal}}
<langsyntaxhighlight lang="pascal">program byeworld;
begin
writeln(StdErr, 'Goodbye, World!');
end.</langsyntaxhighlight>
 
=={{header|Perl}}==
<langsyntaxhighlight lang="perl">warn "Goodbye, World!\n";</langsyntaxhighlight>
 
Or:
 
<langsyntaxhighlight lang="perl">print STDERR "Goodbye, World!\n";</langsyntaxhighlight>
 
=={{header|Perl 6}}==
<lang perl6>note "Goodbye, World!";</lang>
 
=={{header|Phix}}==
<!--<syntaxhighlight lang="phix">-->
<lang Phix>puts(2,"Goodbye, World!\n")</lang>
<span style="color: #7060A8;">puts</span><span style="color: #0000FF;">(</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Goodbye, World!"</span><span style="color: #0000FF;">)</span>
<!--</syntaxhighlight>-->
 
=={{header|PHP}}==
<langsyntaxhighlight lang="php">fprintf(STDERR, "Goodbye, World!\n");</langsyntaxhighlight>
or
<langsyntaxhighlight lang="php">file_put_contents("php://stderr","Hello World!\n");</langsyntaxhighlight>
 
=={{header|Picat}}==
<syntaxhighlight lang="picat">println(stderr,"Goodbye, World!")</syntaxhighlight>
 
=={{header|PicoLisp}}==
<langsyntaxhighlight PicoLisplang="picolisp">(out 2 (prinl "Goodbye, World!"))</langsyntaxhighlight>
 
=={{header|Pike}}==
<langsyntaxhighlight Pikelang="pike">werror("Goodbye, World!");</langsyntaxhighlight>
 
=={{header|PL/I}}==
<langsyntaxhighlight PLlang="pl/Ii">display ('Goodbye, World');</langsyntaxhighlight>
 
=={{header|PostScript}}==
<langsyntaxhighlight lang="postscript">(%stderr) (w) file dup
(Goodbye, World!
) writestring
closefile</langsyntaxhighlight>
 
=={{header|PowerBASIC}}==
{{works with|PowerBASIC Console Compiler}}
 
<langsyntaxhighlight lang="powerbasic">STDERR "Goodbye, World!"</langsyntaxhighlight>
 
=={{header|PowerShell}}==
Line 797 ⟶ 897:
standard Write-Error cmdlet is mainly for sending annotated error messages
to the host:
<langsyntaxhighlight lang="powershell">Write-Error "Goodbye, World!"</langsyntaxhighlight>
Note that this outputs more than just the message,
because behind the scenes it is an uncaught exception:
Line 804 ⟶ 904:
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException</pre>
To accurately reproduce the behavior of other languages one has to resort to .NET in this case:
<langsyntaxhighlight lang="powershell">[Console]::Error.WriteLine("Goodbye, World!")</langsyntaxhighlight>
 
=={{header|PureBasic}}==
Line 812 ⟶ 912:
Standard error output can be used in conjunction with [http://www.purebasic.com/documentation/process/readprogramerror.html ReadProgramError()] to reads a line from an other programs error output (stderr).
 
<langsyntaxhighlight PureBasiclang="purebasic">ConsoleError("Goodbye, World!")</langsyntaxhighlight>
 
=={{header|Python}}==
{{works with|Python|2.x}}
<langsyntaxhighlight lang="python">import sys
 
print >> sys.stderr, "Goodbye, World!"</langsyntaxhighlight>
 
{{works with|Python|3.x}}
<langsyntaxhighlight lang="python">import sys
 
print("Goodbye, World!", file=sys.stderr)</langsyntaxhighlight>
 
Works with either:
<langsyntaxhighlight lang="python">import sys
 
sys.stderr.write("Goodbye, World!\n")</langsyntaxhighlight>
 
=={{header|R}}==
<langsyntaxhighlight Rlang="r">cat("Goodbye, World!", file=stderr())</langsyntaxhighlight>
 
=={{header|Ra}}==
<syntaxhighlight lang="ra">
<lang Ra>
class HelloWorld
**Prints "Goodbye, World!" to standard error**
Line 841 ⟶ 941:
 
print to Console.error made !, "Goodbye, World!"
</syntaxhighlight>
</lang>
 
=={{header|Racket}}==
<syntaxhighlight lang="racket">
<lang Racket>
(eprintf "Goodbye, World!\n")
</syntaxhighlight>
</lang>
 
=={{header|Raku}}==
(formerly Perl 6)
<syntaxhighlight lang="raku" line>note "Goodbye, World!";</syntaxhighlight>
 
=={{header|Retro}}==
<langsyntaxhighlight Retrolang="retro">'Goodbye,_World! '/dev/stderr file:spew</langsyntaxhighlight>
 
=={{header|REXX}}==
Line 858 ⟶ 962:
<br>If the &nbsp; '''stderr''' &nbsp; name is supported and enabled, the output is written to the terminal.
<br>If not supported or disabled, the output is written to a (disk) file named &nbsp; '''STDERR'''.
<langsyntaxhighlight lang="rexx">call lineout 'STDERR', "Goodbye, World!"</langsyntaxhighlight>
 
===version 2===
Same as above, but uses a different style and also invokes &nbsp; '''charout''' &nbsp; instead of &nbsp; '''lineout'''.
<langsyntaxhighlight lang="rexx">msgText = 'Goodbye, World!'
call charout 'STDERR', msgText</langsyntaxhighlight>
 
===version 3===
thisThis works on Windows 7 and ooRexx and REGINA
<langsyntaxhighlight lang="rexx">/* REXX ---------------------------------------------------------------
* 07.07.2014 Walter Pachl
* enter the appropriate command shown in a command prompt.
Line 880 ⟶ 984:
Call lineout ,'Hello, world!'
Say 'and this is the error output:'
'type err.txt'</langsyntaxhighlight>
 
===version 4===
ARexx with tracing console
<syntaxhighlight lang="rexx">/**/
Address command tco
Call writeln stderr,'Good bye, world!'
Call writeln stdout,'Hello, world!'</syntaxhighlight>
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">fputs(stderr,"Goodbye, World!")</langsyntaxhighlight>
 
=={{header|RPL}}==
There is no error console in RPL but all error messages are displayed at the top two lines of the display, which freezes until a key is pressed.
This can be mimicked with the <code>DISP</code> instruction:
≪ "Hello world!" 1 DISP ≫
 
=={{header|Ruby}}==
<langsyntaxhighlight lang="ruby">$stderrSTDERR.puts "Goodbye, World!"</langsyntaxhighlight>
The following also works, unless you have disabled warnings (ruby command line option "-W0" or set <code>$VERBOSE=nil</code>)
<langsyntaxhighlight lang="ruby">warn "Goodbye, World!"</langsyntaxhighlight>
 
=={{header|Run BASIC}}==
<langsyntaxhighlight lang="runbasic">html "<script>
window.open('','error_msg','');
document.write('Goodbye, World!');
</script>""</langsyntaxhighlight>
Run Basic runs in a browser.
This opens a new browser window,
Line 900 ⟶ 1,016:
 
=={{header|Rust}}==
<langsyntaxhighlight lang="rust">fn main() {
eprintln!("Hello, {}!", "world");
}</langsyntaxhighlight>
or
<langsyntaxhighlight lang="rust">fn main() {
use ::std::io::Write;
let (stderr, errmsg) = (&mut ::std::io::stderr(), "Error writing to stderr");
Line 911 ⟶ 1,027:
let (goodbye, world) = ("Goodbye", "world");
writeln!(stderr, "{}, {}!", goodbye, world).expect(errmsg);
}</langsyntaxhighlight>
or
<langsyntaxhighlight lang="rust">fn main() {
use std::io::{self, Write};
 
Line 922 ⟶ 1,038:
io::stderr().write(&*format!("{}, {}!", goodbye, world).as_bytes()).expect("Could not write to stderr");
// Clearly, if you want formatted strings there's no reason not to just use writeln!
}</langsyntaxhighlight>
 
=={{header|S-lang}}==
<langsyntaxhighlight Slang="s-lang">() = fputs("Goodbye, World!\n", stderr);</langsyntaxhighlight>
 
=={{header|Salmon}}==
 
<syntaxhighlight lang="salmon">
<lang Salmon>
standard_error.print("Goodbye, World!\n");
</syntaxhighlight>
</lang>
 
or
 
<syntaxhighlight lang="salmon">
<lang Salmon>
include "short.salm";
stderr.print("Goodbye, World!\n");
</syntaxhighlight>
</lang>
 
or
 
<syntaxhighlight lang="salmon">
<lang Salmon>
include "shorter.salm";
err.print("Goodbye, World!\n");
</syntaxhighlight>
</lang>
or
 
<syntaxhighlight lang="salmon">
<lang Salmon>
include "shorter.salm";
se.print("Goodbye, World!\n");
</syntaxhighlight>
</lang>
 
=={{header|Sather}}==
<langsyntaxhighlight lang="sather">class MAIN is
main is
#ERR + "Hello World!\n";
end;
end;</langsyntaxhighlight>
 
=={{header|Scala}}==
Line 965 ⟶ 1,081:
===Ad hoc REPL solution===
Ad hoc solution as [http://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop REPL] script:
<langsyntaxhighlight Scalalang="scala">Console.err.println("Goodbye, World!")</langsyntaxhighlight>
 
===Via Java runtime===
This is a call to the Java run-time library. '''Not recommendated'''.
<langsyntaxhighlight Scalalang="scala">System.err.println("Goodbye, World!")</langsyntaxhighlight>
 
===Via Scala Console API===
This is a call to the Scala API. '''Recommendated'''.
<langsyntaxhighlight Scalalang="scala">Console.err.println("Goodbye, World!")</langsyntaxhighlight>
 
===Short term deviation to err===
<langsyntaxhighlight Scalalang="scala">Console.withOut(Console.err) { println("This goes to default _err_") }</langsyntaxhighlight>
 
===Long term deviation to err===
<langsyntaxhighlight Scalalang="scala"> println ("Out not deviated")
Console.setOut(Console.err)
println ("Out deviated")
Console.setOut(Console.out) // Reset to normal</langsyntaxhighlight>
 
=={{header|Scheme}}==
<syntaxhighlight lang="scheme">(error "Goodbye, World!")</syntaxhighlight>
 
=={{header|Scilab}}==
<langsyntaxhighlight lang="scilab">error("Goodbye, World!")</langsyntaxhighlight>
 
=={{header|Scheme}}==
<lang scheme>(error "Goodbye, World!")</lang>
 
=={{header|sed}}==
Requires <tt>/dev/stderr</tt>
 
<langsyntaxhighlight lang="sed">#n
1 {
s/.*/Goodbye, World!/w /dev/stderr
}</langsyntaxhighlight>
 
This program requires at least 1 line of input.
Line 1,004 ⟶ 1,120:
 
{{out|Test output}}
<langsyntaxhighlight lang="bash">$ echo a | sed -f error.sed >/dev/null
Goodbye, World!</langsyntaxhighlight>
 
=={{header|Seed7}}==
<langsyntaxhighlight lang="seed7">$ include "seed7_05.s7i";
 
const proc: main is func
begin
writeln(STD_ERR, "Goodbye, World!");
end func;</langsyntaxhighlight>
 
=={{header|Sidef}}==
<langsyntaxhighlight lang="ruby">STDERR.println("Goodbye, World!");</langsyntaxhighlight>
 
=={{header|Slate}}==
<langsyntaxhighlight lang="slate">inform: 'Goodbye, World!' &target: DebugConsole.</langsyntaxhighlight>
 
=={{header|Slope}}==
<syntaxhighlight lang="slope">(write "Goodbye, world!" stderr)</syntaxhighlight>
 
=={{header|Smalltalk}}==
The details on to which name stderr is bound may vary between Smalltalk dialects. If different, a "Smalltalk at:#Stderr put:<name your stream here>" should provide compatibility.
<syntaxhighlight lang="smalltalk">Stderr nextPutAll: 'Goodbye, World!'</syntaxhighlight>
 
However, all Smalltalks provide a console named "Transcript", where diagnostics is usually sent to (which is convenient, if there is no stderr to look at, as when started in Windows as an exe, vs. a com).<br>Thus:
<lang smalltalk>Stderr nextPutAll: 'Goodbye, World!'</lang>
<syntaxhighlight lang="smalltalk">Transcript show: 'Goodbye, World!'</syntaxhighlight>
 
However, all smalltalks provide a console named "Transcript", where diagnostics is usually sent to. Thus:
 
<lang smalltalk>Transcript show: 'Goodbye, World!'</lang>
 
will work on all, and is the preferred way to do this.
And<br>(and yes, when operatingrunning UI-less as a console program, the global "Transcript" is usually bound to the stderr stream).
 
The above tells the stream to write a string;
you can also tell the string to print itself onto some stream:
<syntaxhighlight lang="smalltalk">'Goodbye, World!' printOn: Stderr</syntaxhighlight>
Both have the same effect.
 
=={{header|SNOBOL4}}==
<langsyntaxhighlight lang="snobol4"> terminal = "Error"
output = "Normal text"
end</langsyntaxhighlight>
 
=={{header|Standard ML}}==
<langsyntaxhighlight lang="sml">TextIO.output (TextIO.stdErr, "Goodbye, World!\n")</langsyntaxhighlight>
 
=={{header|Swift}}==
<langsyntaxhighlight Swiftlang="swift">import Foundation
 
let out = NSOutputStream(toFileAtPath: "/dev/stderr", append: true)
Line 1,052 ⟶ 1,174:
if let bytes = success {
println("\nWrote \(bytes) bytes")
}</langsyntaxhighlight>
{{out}}
<pre>
Line 1,060 ⟶ 1,182:
 
=={{header|Tcl}}==
<langsyntaxhighlight lang="tcl">puts stderr "Goodbye, World!"</langsyntaxhighlight>
 
=={{header|Transact-SQL}}==
<langsyntaxhighlight Transactlang="transact-SQLsql"> RAISERROR 'Goodbye, World!', 16, 1 </langsyntaxhighlight>
 
=={{header|True BASIC}}==
<syntaxhighlight lang="basic">
CAUSE error 1, "Goodbye World!"
END
</syntaxhighlight>
 
=={{header|TUSCRIPT}}==
<langsyntaxhighlight lang="tuscript">
$$ MODE TUSCRIPT
PRINT/ERROR "hello world"
text="goodbye world"
PRINT/ERROR text
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,080 ⟶ 1,208:
=={{header|UNIX Shell}}==
{{works with|Bourne Shell}}
<langsyntaxhighlight lang="bash">echo "Goodbye, World!" >&2</langsyntaxhighlight>
 
==={{header|C Shell}}===
<langsyntaxhighlight lang="csh">echo "Goodbye, World!" >/dev/stderr</langsyntaxhighlight>
 
This requires <code>/dev/stderr</code>, a device node from [[BSD]]
Line 1,090 ⟶ 1,218:
 
=={{header|Ursa}}==
<langsyntaxhighlight lang="ursa">out "goodbye, world!" endl console.err</langsyntaxhighlight>
 
=={{header|VBA}}==
<syntaxhighlight lang="vb">
<lang VB>
Sub StandardError()
Debug.Print "Goodbye World!"
End Sub
</syntaxhighlight>
</lang>
 
=={{header|VBScript}}==
Must work in cscript.exe
<langsyntaxhighlight lang="vb">WScript.StdErr.WriteLine "Goodbye, World!"</langsyntaxhighlight>
 
=={{header|Verbexx}}==
<langsyntaxhighlight lang="verbexx">@STDERR "Goodbye, World!\n";</langsyntaxhighlight>
 
=={{header|Visual Basic .NET}}==
<langsyntaxhighlight lang="vbnet">Module Module1
 
Sub Main()
Line 1,113 ⟶ 1,241:
End Sub
 
End Module</langsyntaxhighlight>
 
=={{header|WDTE}}==
<langsyntaxhighlight WDTElang="wdte">io.writeln io.stderr 'Goodbye, World!';</langsyntaxhighlight>
 
=={{header|Wren}}==
<syntaxhighlight lang="wren">Fiber.abort("Goodbye, World!")</syntaxhighlight>
 
=={{header|X86 Assembly}}==
Line 1,126 ⟶ 1,257:
 
Prints "Goodbye, World!" to stderr (and there is probably an even simpler version):
<langsyntaxhighlight lang="asm">section .data
msg db 'Goodbye, World!', 0AH
len equ $-msg
Line 1,140 ⟶ 1,271:
mov ebx, 1
mov eax, 1
int 80h</langsyntaxhighlight>
 
=={{header|XLISP}}==
<langsyntaxhighlight lang="xlisp">(DISPLAY "Goodbye, World!" *ERROR-OUTPUT*)</langsyntaxhighlight>
 
=={{header|XPL0}}==
Line 1,153 ⟶ 1,284:
which is device 2.
 
<langsyntaxhighlight XPL0lang="xpl0">code Text=12;
Text(2, "Goodbye, World!")</langsyntaxhighlight>
 
 
=={{header|Yabasic}}==
<syntaxhighlight lang="yabasic">
error "Goodbye World!"
</syntaxhighlight>
 
 
=={{header|Zig}}==
'''Works with:''' 0.10.x, 0.11.x, 0.12.0-dev.1357+10d03acdb
<lang zig>const std = @import("std");
 
Variant with error handling:
<syntaxhighlight lang="zig">const std = @import("std");
 
pub fn main() std.fs.File.WriteError!void {
const stderr = std.io.getStdErr();
 
try stderr.writeAll("Goodbye, World!\n");
const debug = std.debug;
}</syntaxhighlight>
const io = std.io;
'''Works with:''' 0.10.x, 0.11.x, 0.12.0-dev.1357+10d03acdb
 
Variant with no error handling (useful when debugging):
test "hello world/standard error" {
<syntaxhighlight lang="zig">const std = @import("std");
const stderr = &io.getStdErr().outStream().stream;
try stderr.write("\nGoodbye, World!\n");
try stderr.print("Goodbye, {}\n", .{"World!"});
 
pub fn main() void {
// Simpler API; any errors occured when writing to stderr are dismissed.
// Silently returns if writing to stderr fails.
debug.warn("Goodbye, World!\n", .{});
std.debug.print("Goodbye, World!\n", .{});
}</lang>
}</syntaxhighlight>
 
=={{header|zkl}}==
<langsyntaxhighlight lang="zkl">File.stderr.writeln("Goodbye, World!")</langsyntaxhighlight>
885

edits