Hello world/Text: Difference between revisions
→{{header|Common Lisp}}: Added ColdFusion |
No edit summary |
||
Line 170:
{{works with|7Basic}}
{{works with|QBasic}}
{{works with|BASIC256}}
<lang qbasic>PRINT "Goodbye, World!"</lang>
|
Revision as of 16:49, 12 June 2012
You are encouraged to solve this task according to the task description, using any language you may know.
In this User Output task, the goal is to display the string "Goodbye, World!" [sic] on a text console.
See also
- Hello world/Graphical
- Hello world/Line Printer
- Hello world/Newline omission
- Hello world/Standard error
- Hello world/Web server
4DOS Batch
<lang 4dos>echo Goodbye, World!</lang>
6502 Assembly
<lang asm>; goodbyeworld.s for C= 8-bit machines, ca65 assembler format.
- String printing limited to strings of 256 characters or less.
a_cr = $0d ; Carriage return. bsout = $ffd2 ; KERNAL ROM, output a character to current device.
.code
ldx #0 ; Starting index 0 in X register. printnext: lda text,x ; Get character from string. beq done ; If we read a 0 we're done. jsr bsout ; Output character. inx ; Increment index to next character. bne printnext ; Repeat if index doesn't overflow to 0. done: rts ; Return from subroutine.
.rodata
text: .byte "Goodbye, world!", a_cr, 0</lang>
8086 Assembly
<lang masm>DOSSEG .MODEL TINY .DATA TXT DB "Goodbye, World!$" .CODE START: MOV ax, @DATA MOV ds, ax
MOV ah, 09h ;prepare output function MOV dx, OFFSET TXT ; set offset INT 21h ; output string TXT
MOV AX, 4C00h ; go back to DOS INT 21h END START</lang>
With A86 or NASM syntax:
org 100h mov dx, msg mov ah, 9 int 21h mov ax, 4c00h int 21h msg: db "Hello, World!$"
ABAP
<lang ABAP>REPORT zgoodbyeworld.
WRITE 'Goodbye, World!'.</lang>
ACL2
<lang lisp>(cw "Goodbye, world!~%")</lang>
ActionScript
<lang ActionScript>trace("Goodbye, World!");</lang>
Ada
<lang ada>with Ada.Text_IO; use Ada.Text_IO; procedure Main is begin
Put_Line ("Goodbye, World!");
end Main;</lang>
GLBasic
<lang GLBasic>STDOUT "GOODBYE, WORLD!"</lang>
Aime
<lang aime>o_text("GOODBYE, WORLD!\n");</lang>
or:
<lang aime> integer main(void) {
o_text("GOODBYE, WORLD!\n");
return 0;
} </lang>
Algae
<lang algae>printf("Goodbye, World\n");</lang>
ALGOL 68
<lang algol68>main: (
printf($"Goodbye, World!"l$)
)</lang>
Alore
<lang alore>Print('Goodbye, World!')</lang>
AmbientTalk
<lang ambienttalk>system.println("Goodbye, World!")</lang>
AmigaE
<lang amigae>PROC main()
WriteF('Goodbye, World!\n')
ENDPROC</lang>
AppleScript
To show in Script Editor Result pane: <lang applescript>"Goodbye, World!"</lang>
To show in Script Editor Event Log pane: <lang applescript>log "Goodbye, World!"</lang>
Applesoft BASIC
<lang Applesoft BASIC> PRINT "GOODBYE, WORLD!"</lang>
Argile
<lang Argile>use std print "Goodbye, World!"</lang> compile with: arc hello_world.arg -o hello_world.c && gcc -o hello_world hello_world.c
Asymptote
<lang asymptote>write('Goodbye, world!');</lang>
ATS
<lang ATS>implement main () = print "Goodbye, World!\n"</lang>
AutoHotkey
script launched from windows explorer <lang AutoHotkey>DllCall("AllocConsole") FileAppend, Goodbye`, World!, CONOUT$ FileReadLine, _, CONIN$, 1</lang> scripts run from shell [requires Windows XP or higher; older Versions of Windows don´t have the "AttachConsole" function] <lang AutoHotkey>DllCall("AttachConsole", "int", -1) FileAppend, Goodbye`, World!, CONOUT$</lang> <lang AutoHotkey>SendInput Goodbye, World{!}</lang>
AWK
<lang awk>BEGIN{print "Goodbye, World!"}</lang>
Here there is no significant difference between BEGIN
and END
, as the input is empty. So this version is shorter:
<lang awk>END{print"Hello, world!"}</lang>
Babel
<lang babel>main: { "Hello, world\n" << }</lang>
BASIC
<lang qbasic>10 print "Goodbye, World!"</lang>
<lang qbasic>PRINT "Goodbye, World!"</lang>
Batch File
Under normal circumstances, when delayed expansion is disabled <lang dos>echo Goodbye, World!</lang>
If delayed expansion is enabled, then the ! must be escaped twice <lang dos>setlocal enableDelayedExpansion echo Goodbye, World^^^!</lang>
BBC BASIC
<lang bbcbasic> PRINT "Goodbye, World!"</lang>
bc
<lang bc>"Goodbye, World! "</lang>
BCPL
<lang BCPL>GET "libhdr"
LET start() = VALOF { writef("Goodbye, World!")
RESULTIS 0
}</lang>
Befunge
<lang befunge>0"!dlrow ,eybdooG">:#,_@</lang>
Blast
<lang blast># This will display a goodbye message on the terminal screen .begin display "Goodbye, world!" return
- This is the end of the script.</lang>
Boo
<lang boo>print "Goodbye, World!"</lang>
Brace
<lang brace>#!/usr/bin/env bx use b Main: say("Goodbye, World!")</lang>
Brainf***
We wanna make a series of round numbers going like:
10 close to newline and carriage return 30 close to ! and SPACE 40 close to COMMA 70 close to G 80 close to W 90 close to b 100 is d and close to e and l 110 close to o 120 close to y
forming all the letters we need if we just add up a bit
Commented version: <lang bf>+++++ +++++ First cell 10 (its a counter and we will be "multiplying")
[ >+ 10 times 1 is 10 >+++ 10 times 3 is 30 >++++ etc etc >+++++ ++ >+++++ +++ >+++++ ++++ >+++++ +++++ >+++++ ++++++ >+++++ +++++++ <<<<<<<<< - go back to counter and subtract 1 ]
printing G >>>> + .
o twice >>>> + ..
d < .
b < +++++ +++ .
y >>> + .
e << + .
COMMA <<<< ++++ .
SPACE < ++ .
W >>> +++++ ++ .
o >>> .
r +++ .
l < +++++ ++ .
d
--- .
! <<<<< + .
CRLF < +++ . --- .</lang>
Uncommented: <lang bf>++++++++++[>+>+++>++++>+++++++>++++++++>+++++++++>++ ++++++++>+++++++++++>++++++++++++<<<<<<<<<-]>>>>+.>>> >+..<.<++++++++.>>>+.<<+.<<<<++++.<++.>>>+++++++.>>>.+++. <+++++++.--------.<<<<<+.<+++.---.</lang> It can most likely be optimized, but this is a nice way to show how character printing works in Brainf*** :)
Bracmat
<lang bracmat>put$"Goodbye, world!"</lang>
Brat
<lang brat>p "Goodbye, world!"</lang>
Brlcad
The mged utility can output text to the terminal:
<lang brlcad> echo Hello World! </lang>
C
<lang c>#include <stdlib.h>
- include <stdio.h>
int main(void) {
printf("Goodbye, World!\n"); return EXIT_SUCCESS;
}</lang> Or: <lang c>#include <stdlib.h>
- include <stdio.h>
int main(void) {
puts("Goodbye, World!"); return EXIT_SUCCESS;
}</lang>
C#
<lang csharp>System.Console.WriteLine("Goodbye, World!");</lang>
C++
<lang cpp>#include <iostream>
int main () {
std::cout << "Goodbye, World!" << std::endl; return std::cout.bad();
}</lang>
C++/CLI
<lang cpp>using namespace System; int main() {
Console::WriteLine("Goodbye, World!");
}</lang>
C0H
The smallest Hello World source code thinkable!
<lang C0H></lang>
C1R
A small Hello World program, that lists the significant part of the related task URL at the Rosetta Code web site
<lang C0H>Hello_world/Text</lang>
Cat
<lang Cat>"Goodbye, World!" writeln</lang>
Chef
<lang Chef>Hello World Souffle.
This recipe prints the immortal words "Hello world!", in a basically brute force way. It also makes a lot of food for one person.
Ingredients. 72 g haricot beans 101 eggs 108 g lard 111 cups oil 32 zucchinis 119 ml water 114 g red salmon 100 g dijon mustard 33 potatoes
Method. Put potatoes into the mixing bowl. Put dijon mustard into the mixing bowl. Put lard into the mixing bowl. Put red salmon into the mixing bowl. Put oil into the mixing bowl. Put water into the mixing bowl. Put zucchinis into the mixing bowl. Put oil into the mixing bowl. Put lard into the mixing bowl. Put lard into the mixing bowl. Put eggs into the mixing bowl. Put haricot beans into the mixing bowl. Liquefy contents of the mixing bowl. Pour contents of the mixing bowl into the baking dish.
Serves 1.</lang>
Clay
<lang clay>main() {
println("Goodbye, world!");
}</lang>
Clean
<lang clean>Start = "Goodbye, World!"</lang>
CLIPS
<lang clips>(printout t "Goodbye, World!" crlf)</lang>
Clojure
<lang lisp>(println "Goodbye, world!")</lang>
CMake
<lang cmake>message(STATUS "Goodbye, world!")</lang>
This outputs
-- Goodbye, world!
COBOL
Using fixed format.
<lang cobol> program-id. hello. procedure division. display "Goodbye, world!". stop run.</lang>
Cobra
<lang cobra>class Hello
def main print 'Goodbye, World'</lang>
CoffeeScript
<lang coffeescript>console.log "Goodbye, World!"</lang>
ColdFusion
<lang coldfusion><cfoutput>Hello world</cfoutput></lang>
Common Lisp
<lang lisp>(format t "Goodbye, world!~%")</lang>
Component Pascal
<lang oberon2> MODULE Hello; IMPORT Out;
PROCEDURE Do*; BEGIN Out.String("Hello, world!"); Out.Ln END Do; END Hello.</lang> Run command Hello.Do by commander.
Crack
<lang crack> import crack.io cout; cout `hello world!\n`; </lang>
D
<lang D>import std.stdio;
void main() {
writeln("Goodbye, World!");
}</lang>
Dao
<lang dao>io.writeln( 'Goodbye, World!' )</lang>
Dart
<lang dart>main() {
var bye = 'Goodbye, World!'; print("$bye");
}</lang>
dc
<lang dc>[Goodbye, World!]p</lang>
Delphi
<lang delphi> program ProjectGoodbye; {$APPTYPE CONSOLE} begin
WriteLn('Goodbye, World!');
end. </lang>
DWScript
<lang delphi> PrintLn('Goodbye, World!'); </lang>
Dylan
<lang Dylan> module: hello-world
format-out("%s\n", "Goodbye, World!"); </lang>
Dylan.NET
One Line version: <lang Dylan.NET>Console::WriteLine("Hello World!")</lang> Hello World Program: <lang Dylan.NET> //compile using the new dylan.NET v, 11.2.8.2 or later //use mono to run the compiler
- refstdasm mscorlib.dll
import System
assembly helloworld exe ver 1.2.0.0
class public auto ansi Module1
method public static void main() Console::WriteLine("Hello World!") end method
end class </lang>
E
<lang e>println("Goodbye, World!")
stdout.println("Goodbye, World!")</lang>
eC
<lang ec>class GoodByeApp : Application {
void Main() { PrintLn("Goodbye, World!"); }
}</lang>
Efene
short version (without a function)
<lang efene>io.format("Goodbye, world~n")</lang>
complete version (put this in a file and compile it)
<lang efene>@public run = fn () {
io.format("Goodbye, world~n")
}</lang>
Eiffel
This page uses content from Wikipedia. The original article was at Eiffel (programming language). The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance) |
<lang eiffel>class
HELLO_WORLD
create
make
feature
make do print ("Goodbye, world!%N") end
end</lang>
Ela
<lang ela>open Console writen "Goodbye, world"</lang>
elastiC
From the elastiC Manual.
<lang elastic>package hello;
// Import the `basic' package import basic;
// Define a simple function function hello() { // Print hello world basic.print( "Goodbye, world!\n" ); }
/* * Here we start to execute package code */
// Invoke the `hello' function hello();</lang>
Elena
<lang elena>#symbol Program => [
'program'output << "Goodbye, World!%n".
].</lang>
Elena VM Script
<lang elena>&eval &nil sys'dynamics'castvariable
&nil sys'dynamics'batch &sys'vm'routines'ereturnprop "Goodbye, World!%n" &wrap ~sys'dynamics'group_member ^append &write &nil 'program'output &wrap ~sys'dynamics'group_member ^append ~sys'dynamics'group_member ^append &get &nil 'program'input &wrap ~sys'dynamics'group_member ^append
&wrap &nil ^eval </lang>
Elisa
<lang elisa> "Goodbye,World!"? </lang>
Erlang
<lang erlang>io:format("Goodbye, world~n").</lang>
Euphoria
<lang Euphoria>puts(1,"Goodbye, world!\n")</lang>
F#
<lang fsharp>printfn "%s" "Goodbye, world"</lang> or using .Net classes directly <lang fsharp>System.Console.WriteLine("Goodbye, World!")</lang>
Factor
<lang factor>"Goodbye, world." print</lang>
Falcon
<lang false>> "Goodbye, World!"</lang>
FALSE
<lang false>"Goodbye, World! "</lang>
Fantom
<lang fantom> class HelloText {
public static Void main () { echo ("Goodbye, World!") }
} </lang>
ferite
<lang ferite>uses "console"; Console.println( "Goodby, World" );</lang>
Fexl
<lang Fexl>print "Hello, World!";nl;</lang>
Fish
Standard Hello, world example, modified for this task: <lang Fish>!v"Goodbye, world"r!
>l?!;o</lang>
Explanation of the code:
!v" jumps over the v character with the ! sign, then starts the string mode with " .
Then the characters Goodbye, world are added, and string mode is closed with ".
The stack is reversed for printing (r), and a jump (!) is executed to jump over the ! at the beginning of the line and execute the v. (Fish is torical)
After going down by v, it goes rightwards again by > and this line is being executed.
This line pushes the stack size (l), and stops (;) if the top item on the stack is equal to 0 (?). Else it executes the ! directly after it and jumps to the o, which outputs the top item in ASCII. Then the line is executed again. It effectively prints the stack until it's empty, then it terminates.
Forth
<lang forth>." Goodbye, World!"</lang>
Or as a whole program:
<lang forth>: goodbye ( -- ) ." Goodbye, World!" CR ;</lang>
Fortran
Simplest case - display using default formatting:
<lang fortran>print *,"Goodbye, world"</lang>
Use explicit output format:
<lang fortran>100 format (5X,A,"!")
print 100,"Goodbye, world"</lang>
Output to channels other than stdout goes like this:
<lang fortran>write (89,100) "Goodbye, world"</lang>
uses the format given at label 100 to output to unit 89. If output unit with this number exists yet (no "OPEN" statement or processor-specific external unit setting), a new file will be created and the output sent there. On most UNIX/Linux systems that file will be named "fort.89".
Fortress
<lang fortress>export Executable
run() = println("Goodbye, world!")</lang>
Frink
<lang frink> println["Hello, World!"] </lang>
Gambas
<lang gambas> PRINT "Goodbye, World!" </lang>
GAP
<lang gap># Several ways to do it "Hello, World!";
Print("Hello, World!\n"); # No EOL appended
Display("Hello, World!");
f := OutputTextUser(); WriteLine(f, "Hello, World!\n"); CloseStream(f);</lang>
gecho
<lang gecho>'Hello, <> 'world! print</lang>
Gema
Gema ia a preprocessor that reads an input file and writes an output file. This code will write "Goodby, World!' no natter what input is given.
<lang gema>*= ! ignore off content of input \B=Goodby, World\! ! Start output with this text.</lang>
Glee
<lang glee>"Goodbye, World!"</lang>
Go
<lang go>package main
import "fmt"
func main() { fmt.Println("Goodbye, World!") }</lang>
Golfscript
<lang golfscript>"Goodbye, World!"</lang>
Gosu
<lang gosu>print("Goodbye, World")</lang>
Groovy
<lang groovy>println "Goodbye, World"</lang>
GW-BASIC
<lang qbasic>10 PRINT "Goodbye World!"</lang>
Haskell
<lang haskell>main = putStrLn "Goodbye, world"</lang>
HicEst
<lang hicest>WRITE() 'Goodbye, World!'</lang>
HLA
<lang HLA>program goodbyeWorld;
- include("stdlib.hhf")
begin goodbyeWorld;
stdout.put( "Goodbye, World!" nl );
end goodbyeWorld;</lang>
HQ9+
<lang hq9plus>H</lang>
Icon and Unicon
<lang icon>procedure main()
write( "Goodbye World" )
end</lang>
IDL
<lang idl>print,'Goodbye World'</lang>
Inform 6
<lang Inform 6>[Main;
print "Goodbye, World!^";
];</lang>
Integer BASIC
<lang Integer BASIC> 10 PRINT "GOODBYE, WORLD!"
20 END</lang>
Io
<lang Io>"Goodbye, world!" println</lang>
Ioke
<lang ioke>"Goodbye, World!" println</lang>
J
<lang j> 'Goodbye, World!' Goodbye, World!</lang>
Here are some redundant alternatives: <lang J> [data=. 'Goodbye, World!' Goodbye, World!
data
Goodbye, World!
smoutput data
Goodbye, World!</lang>
Java
<lang java>public class HelloWorld {
public static void main(String[] args) { System.out.println("Goodbye, World!"); }
}</lang>
Jacquard Loom
This weaves the string "Goodbye, World!" <lang jacquard>+---------------+ | | | * * | |* * * * | |* * *| |* * *| |* * * | | * * * | | * | +---------------+
+---------------+ | | |* * * | |* * * | | * *| | * *| |* * * | |* * * * | | * | +---------------+
+---------------+ | | |* ** * * | |******* *** * | | **** * * ***| | **** * ******| | ****** ** * | | * * * * | | * | +---------------+
+---------------+ | | |******* *** * | |******* *** * | | ** *| |* * * *| |******* ** * | |******* *** * | | * | +---------------+
+---------------+ | | |******* *** * | |******* *** * | | * * * *| | * * * *| |******* ** * | |******* ** * | | * | +---------------+
+---------------+ | | |***** * *** * | |******* *** * | | * * * * | | * * * | |****** ** * | |****** ** * | | * | +---------------+
+---------------+ | | | * * * | |***** * ***** | |***** ** * ***| |***** ** * ***| |******* * ** | | * * * * | | * | +---------------+
+---------------+ | | | | | * * | | * * | | * | | * | | | | | +---------------+</lang>
JavaScript
<lang javascript>document.write("Goodbye, World!");</lang>
<lang javascript>print('Hello, World!');</lang>
<lang javascript>WScript.Echo("Hello, World!");</lang>
<lang javascript>console.log("Goodbye, World!")</lang>
Joy
<lang joy>"Goodbye, World!" putchars.</lang>
Kdf9 Usercode
<lang joy>
V2; W0; RESTART; J999; J999; PROGRAM; (main program);
V0 = Q0/AV1/AV2; V1 = B0750064554545700; ("Hello" in Flexowriter code); V2 = B0767065762544477; ("World" in Flexowriter code); V0; =Q9; POAQ9; (write "Hello World" to Flexowriter);
999; OUT;
FINISH;
</lang>
Kite
simply a single line <lang Kite>"#!/usr/local/bin/kite
"Hello World"|print;</lang>
KonsolScript
Displays it in a text file or console/terminal. <lang KonsolScript>function main() {
Konsol:Log("Hello World")
}</lang>
Liberty BASIC
<lang lb>print "Goodbye, World!"</lang>
Limbo
<lang limbo>implement Command;
include "sys.m"; sys: Sys; include "draw.m"; include "sh.m"; init(nil: ref Draw->Context, nil: list of string) { sys = load Sys Sys->PATH; sys->print("Goodby, World!\n"); }</lang>
Lisaac
You can print to standard output in Lisaac by calling STRING.print or INTEGER.print:
<lang lisaac>Section Header // The Header section is required.
+ name := GOODBYE; // Define the name of this object.
Section Public
- main <- ("Goodbye, World!\n".print;);</lang>
However, it may be more straightforward to use IO.print_string instead:
<lang lisaac>Section Header // The Header section is required.
+ name := GOODBYE2; // Define the name of this object.
Section Public
- main <- (IO.put_string "Goodbye, World!\n";);</lang>
Logo
Print includes a line feed: <lang logo>print [Goodbye, world!]</lang> Type does not: <lang logo>type [Goodbye, world!]</lang>
Logtalk
<lang logtalk>:- object(hello_world).
% the initialization/1 directive argument is automatically executed % when the object is loaded into memory: :- initialization((nl, write('Goodbye, world!'), nl)).
- - end_object.</lang>
LotusScript
<lang lotusscript>:- object(hello_world).
'This will send the output to the status bar at the bottom of the Notes client screen print "Goodbye, world"
- - end_object.</lang>
LSE64
<lang lse64>" Goodbye, World!" ,t nl</lang>
Lua
Function calls with either a string literal or a table constructor passed as their only argument do not require parentheses. <lang lua>print "Goodbye, World!"</lang>
M4
For the particular nature of m4, this is simply: <lang m4>`Goodbye, World'</lang>
Mathematica
<lang mathematica>Print["Goodbye, World!"]</lang>
MATLAB
<lang MATLAB>>> 'Goodbye, World!'
ans =
Goodbye, World!</lang>
MAXScript
<lang maxscript>print "Goodbye, World!"</lang> or: <lang maxscript>format "%" "Goodbye, World!"</lang>
Mercury
<lang mecury>:- module hello.
- - interface.
- - import_module io.
- - pred main(io::di, io::uo) is det.
- - implementation.
main(!IO) :-
io.write_string("Goodbye, World!\n", !IO).</lang>
Metafont
<lang metafont>message "Goodbye, World"; end</lang>
MIPS Assembly
and
<lang mips> .data hello: .asciiz "Goodbye, world!"
.text
main:
la $a0, hello li $v0, 4 syscall li $v0, 10 syscall</lang>
mIRC Scripting Language
<lang mirc>alias saygoodbye { echo -a Goodbye! }</lang>
Modula-2
<lang modula2>MODULE Hello; IMPORT InOut;
BEGIN
InOut.WriteString('Hello World!'); InOut.WriteLn
END Hello.</lang>
ML/I
<lang ML/I>Goodbye, World!</lang>
Modula-3
<lang modula3>MODULE Goodbye EXPORTS Main;
IMPORT IO;
BEGIN
IO.Put("Goodbye, World!\n");
END Goodbye.</lang>
MUMPS
<lang MUMPS>Write "Goodbye, World.",!</lang>
Mythryl
<lang Mythryl>print "Goodbye, World!\n";</lang>
Neat
<lang Neat>void main() writeln "Goodbye, World!";</lang>
Nemerle
<lang Nemerle> class Hello {
static Main () : void { System.Console.WriteLine ("Hello, world!"); }
} </lang> Easier method: <lang Nemerle> System.Console.WriteLine("Hello, world!"); </lang>
NetRexx
<lang NetRexx>say 'Goodbye, World!'</lang>
newLISP
<lang lisp>(println "Goodbye, World!")</lang>
Nimrod
<lang python>echo("Goodbye, World!")</lang>
Node.js
<lang javascript>console.log("Goodbye, World!");</lang>
Objeck
<lang objeck>bundle Default {
class SayHello { function : Main(args : String[]) ~ Nil { "Hello World!"->PrintLine(); } }
}</lang>
Objective-C
To print to stdout: <lang objc>printf("Goodbye, World!");</lang>
To print an Objective-C NSString
to stdout, here are some options:
<lang objc>printf("%s", [@"Goodbye, World!" UTF8String]);</lang>
<lang objc>[@"Goodbye, World!" writeToFile:@"/dev/stdout" atomically:NO encoding:NSUTF8StringEncoding error:NULL];</lang>
<lang objc>[[NSFileHandle fileHandleWithStandardOutput] writeData:[@"Goodbye, World!" dataUsingEncoding:NSUTF8StringEncoding]];</lang>
To log a time-stamped message to stderr: <lang objc>NSLog(@"Goodbye, World!");</lang>
OCaml
<lang ocaml>print_endline "Goodbye, World!"</lang>
Occam
<lang occam>#INCLUDE "course.module" PROC main (CHAN BYTE keyboard?, screen!, error!)
out.string ("Hello World*c*n",0,screen!)
- </lang>
Octave
<lang octave>disp("Goodbye, world");</lang>
Or, using C-style function printf:
<lang octave>printf("Goodbye, world\n");</lang>
Onyx
<lang onyx>`Hello world!\n' print</lang>
OOC
<lang ooc>main: func {
"Hello world!" println()
}</lang>
Openscad
<lang openscad> echo("Goodbye, World!"); </lang>
Oxygene
From http://en.wikipedia.org/wiki/Oxygene_%28programming_language%29 modified for the strange (sic) required by this task! <lang oxygene> namespace HelloWorld;
interface
type
HelloClass = class public class method Main; end;
implementation
class method HelloClass.Main; begin
System.Console.WriteLine('Farewell, cruel world!');
end;
end. </lang>
>HelloWorld.exe Farewell, cruel world!
Oz
<lang oz>{Show "Goodbye, World!"}</lang>
PARI/GP
<lang parigp>print("Goodbye, world!")</lang>
Pascal
<lang pascal>program byeworld; begin
writeln('Goodbye, World!');
end.</lang>
PASM
<lang pasm>print "Goodbye World!\n" end</lang>
PDP-11 Assembly
This is tested on Unix v7 Prints "Goodbye, World!" to stdout:
<lang assembly>.globl start .text start:
mov $1,r0
sys 4; outtext; outlen sys 1 rts pc
.data outtext: <Goodbye, World!\n> outlen = . - outtext</lang>
Perl
<lang perl>print "Goodbye, World!\n";</lang>
Backported from Perl 6: <lang perl>use feature 'say'; say 'Goodbye, World!';</lang>
or: <lang perl>use 5.010; say 'Goodbye, World!';</lang>
Perl 6
<lang perl6>say 'Goodbye, World!';</lang>
PHP
<lang php><?php
echo "Goodbye, World!\n";
?></lang>
Alternatively, any text outside of the <?php ?>
tags will be automatically echoed:
<lang php>Goodbye, World!</lang>
PicoLisp
<lang PicoLisp>(prinl "Goodbye, World!")</lang>
PIR
<lang pir>.sub hello_world_text :main print "Goodbye, World!\n" .end</lang>
Pike
<lang pike>int main(){
write("Goodbye, world!\n");
}</lang>
PL/I
<lang PL/I>put ('Goodbye, World');</lang>
Pop11
<lang pop11>printf('Goodbye, World!\n');</lang>
PostScript
The "==" and "=" operators display the topmost element of the stack with or without processing, followed by a newline. Thus:
<lang postscript>(Goodbye, World!) ==</lang>
will display the string "(Goodbye, World!)" while
<lang postscript>(Goodbye, World!) =</lang>
will display the content of the string "(Goodbye, World!)"; that is, "Goodbye, World!".
To print a string without the following newline, use
<lang postscript>(Goodbye, World!) print</lang>
PowerShell
<lang powershell>Write-Host "Goodbye, World!"
- For extra flair, you can specify colored output
Write-Host "Goodbye, World!" -foregroundcolor red</lang>
ProDOS
<lang ProDOS>printline Goodbye, World!</lang>
Prolog
<lang prolog>:- write('Goodbye, World', nl).</lang>
PSQL
EXECUTE BLOCK RETURNS(S VARCHAR(40)) AS BEGIN S = 'Hello World!'; SUSPEND; END
Pure
<lang pure> using system;
puts "Goodbye, World!\n" ; </lang>
PureBasic
<lang PureBasic>OpenConsole() PrintN("Goodbye, World!") Input() ; Wait for enter</lang>
Python
<lang python>print "Goodbye, World!"</lang>
The same using sys.stdout <lang python>import sys sys.stdout.write("Goodbye, World!\n")</lang>
In Python 3.0, print is being changed from a statement to a function.
<lang python>print("Goodbye, World!")</lang>
Quill
<lang quill>"Goodbye, World!" print</lang>
R
<lang R> cat("Goodbye, World!\n")</lang>
Racket
<lang racket>(display "Goodbye, World!\n")</lang>
Raven
<lang raven>'Goodbye, World!' print</lang>
REALbasic
This requires a console application.
<lang realbasic>Function Run(args() as String) As Integer
Print "Goodbye, World!" Quit
End Function</lang>
REBOL
<lang REBOL>print "Goodbye, World!"</lang>
Retro
<lang Retro> "Goodbye, World!" puts </lang>
REXX
<lang rexx> /* goodbye program */ say 'Goodbye, World!'
/*another version:*/
call lineout ,"Goodbye, World!" </lang>
RTL/2
<lang RTL/2>TITLE Goodbye World;
LET NL=10;
EXT PROC(REF ARRAY BYTE) TWRT;
ENT PROC INT RRJOB();
TWRT("Goodbye, World!#NL#"); RETURN(1);
ENDPROC;</lang>
Ruby
<lang ruby>puts "Goodbye, World!"</lang> or <lang ruby>$stdout.puts "Goodbye, World!"</lang>
Run BASIC
<lang Runbasic>print "Goodbye World!"</lang>
Rust
<lang Rust>use std; import std::io;
fn main(){ io::println("hello world"); }</lang>
Salmon
<lang Salmon>"Goodbye, World!"!</lang>
or
<lang Salmon>print("Goodbye, World!\n");</lang>
or
<lang Salmon>standard_output.print("Goodbye, World!\n");</lang>
SAS
<lang sas>/* Using a data step. Will print the string in the log window */ data _null_; put "Goodbye, World!"; run;</lang>
Sather
<lang sather>class GOODBYE_WORLD is
main is #OUT+"Goodbye, World!\n"; end;
end;</lang>
Scala
<lang scala>println("Goodbye, World!")</lang>
Scheme
<lang scheme>(display "Goodbye, world!") (newline)</lang>
<lang scheme>(print "Goodbye, world!")</lang> or just: <lang scheme>"Goodbye, World!"</lang> (should work on any scheme)
sed
<lang sed>cGoodbye, World!</lang>
Seed7
<lang seed7>$ include "seed7_05.s7i";
const proc: main is func
begin writeln("Goodbye, World!"); end func;</lang>
Self
<lang self>'Goodbye, World!' printLine.</lang>
Shiny
<lang shiny>say 'Hello World!'</lang>
SIMPOL
<lang simpol>function main() end function "Goodbye, world!{d}{a}"</lang>
Sisal
<lang sisal>define main
% Sisal doesn't yet have a string built-in. % Let's define one as an array of characters.
type string = array[character];
function main(returns string)
"Hello world!"
end function</lang>
Slate
<lang slate>inform: 'Goodbye, world!'.</lang>
Smalltalk
<lang smalltalk>Transcript show: 'Goodbye, world!'; cr.</lang>
(as does the above code)
<lang smalltalk>'Goodbye, world!' printNl.</lang>
SNOBOL4
Using CSnobol4 dialect <lang snobol4> OUTPUT = "Hello World" END</lang>
SNUSP
<lang snusp>@\G.@\o.o.@\d.--b.@\y.@\e.>@\comma.@\.<-@\W.+@\o.+++r.------l.@\d.>+.! #
| | \@------|# | \@@+@@++|+++#- \\ - | \@@@@=+++++# | \===--------!\===!\-----|-------#-------/ \@@+@@@+++++# \!#+++++++++++++++++++++++#!/</lang>
Standard ML
<lang sml>print "Goodbye, World!\n"</lang>
Suneido
<lang Suneido>Print("Hello World!")</lang>
Teco
Outputting to terminal. Please note that ^A means control-A, not a caret followed by 'A', and that $ represent the ESC key. <lang teco>^AGoodbye, World^A$$</lang>
Tcl
Output to terminal: <lang tcl>puts "Goodbye, World"</lang>
Output to arbitrary open, writable file: <lang tcl>puts $fileID "Goodbye, World"</lang>
TI-83 BASIC
See TI-89 BASIC.
TI-89 BASIC
<lang ti89b>Disp "Goodbye, World!"</lang>
TorqueScript
<lang tqs>echo("Goodbye, World!");</lang>
Transact-SQL
<lang sql>PRINT "Goodbye, world!"</lang>
Trith
<lang trith>"Goodbye, World!" print</lang>
TUSCRIPT
<lang tuscript> $$ MODE TUSCRIPT PRINT "hello world" text="goodbye world" PRINT text </lang> Output:
hello world goodbye world
UNIX Shell
<lang bash>#!/bin/sh echo "Goodbye World!"</lang>
C Shell
<lang csh>#!/bin/csh -f echo "Goodbye World\!"</lang>
We use \! to prevent history substitution. Plain ! at end of string seems to be safe, but we use \! to be sure.
Unlambda
<lang unlambda>`r``````````````.G.o.o.d.b.y.e.,. .W.o.r.l.di</lang>
Ursala
output as a side effect of compilation <lang Ursala>#show+
main = -[Goodbye, World!]-</lang> output by a compiled executable <lang Ursala>#import std
- executable ('parameterized',)
main = <file[contents: -[Goodbye, World!]-]>!</lang>
V
<lang v>"Goodbye! world" puts</lang>
Vala
<lang vala>void main(){ stdout.printf("Hello World!\n"); }</lang>
VBScript
<lang VBScript>WScript.Echo("Goodbye, World!")</lang>
Vedit macro language
<lang vedit>Message("Goodbye, World!")</lang>
Whenever
<lang whenever>1 print("Goodbye, world!");</lang>
X86 Assembly
This is known to work on Linux, it may or may not work on other Unix-like systems
Prints "Goodbye, World!" to stdout (and there is probably an even simpler version): <lang asm>section .data msg db 'Goodbye, World!', 0AH len equ $-msg
section .text global _start _start: mov edx, len
mov ecx, msg mov ebx, 1 mov eax, 4 int 80h
mov ebx, 0 mov eax, 1 int 80h</lang>
XL
<lang XL> use XL.UI.CONSOLE WriteLn "Hello World" </lang>
XPL0
<lang XPL0>code Text=12; Text(0, "Goodbye, World! ")</lang>
XSLT
<lang xml><xsl:text>Goodbye, World! </xsl:text></lang>
Yorick
<lang yorick>write, "Goodbye, World!"</lang>
Z80 Assembly
Using the Amstrad CPC firmware:
<lang z80>org $4000
txt_output: equ $bb5a
push hl ld hl,world
print: ld a,(hl) cp 0 jr z,end call txt_output inc hl jr print
end: pop hl ret
world: defm "Goodbye, World!\r\n\0"</lang>
- Programming Tasks
- Basic language learning
- Selection/Short Circuit/Console Program Basics
- 4DOS Batch
- 6502 Assembly
- 8086 Assembly
- ABAP
- ACL2
- ActionScript
- Ada
- GLBasic
- Aime
- Algae
- ALGOL 68
- Alore
- AmbientTalk
- AmigaE
- AppleScript
- Applesoft BASIC
- Argile
- Asymptote
- ATS
- AutoHotkey
- AWK
- Babel
- BASIC
- Batch File
- BBC BASIC
- Bc
- BCPL
- Befunge
- Blast
- Boo
- Brace
- Brainf***
- Bracmat
- Brat
- Brlcad
- C
- C sharp
- C++
- C++/CLI
- C0H
- C1R
- Cat
- Chef
- Clay
- Clean
- CLIPS
- Clojure
- CMake
- COBOL
- Cobra
- CoffeeScript
- ColdFusion
- Common Lisp
- Component Pascal
- Crack
- D
- Dao
- Dart
- Dc
- Delphi
- DWScript
- Dylan
- Dylan.NET
- E
- EC
- Efene
- Eiffel
- WikipediaSourced
- Ela
- ElastiC
- Elena
- Elisa
- Erlang
- Euphoria
- F Sharp
- Factor
- Falcon
- FALSE
- Fantom
- Ferite
- Fexl
- Fish
- Forth
- Fortran
- Fortress
- Frink
- Gambas
- GAP
- Gecho
- Gema
- Glee
- Go
- Golfscript
- Gosu
- Groovy
- GW-BASIC
- Haskell
- HicEst
- HLA
- HQ9+
- Icon
- Unicon
- IDL
- Inform 6
- Integer BASIC
- Io
- Ioke
- J
- Java
- Jacquard Loom
- JavaScript
- Joy
- Kdf9 Usercode
- Kite
- KonsolScript
- Liberty BASIC
- Limbo
- Lisaac
- Logo
- Logtalk
- LotusScript
- LSE64
- Lua
- M4
- Mathematica
- MATLAB
- MAXScript
- Mercury
- Metafont
- MIPS Assembly
- MIRC Scripting Language
- Modula-2
- ML/I
- Modula-3
- MUMPS
- Mythryl
- Neat
- Nemerle
- NetRexx
- NewLISP
- Nimrod
- Node.js
- Objeck
- Objective-C
- OCaml
- Occam
- Octave
- Onyx
- OOC
- Openscad
- Oxygene
- Oz
- PARI/GP
- Pascal
- PASM
- PDP-11 Assembly
- Perl
- Perl 6
- PHP
- PicoLisp
- PIR
- Pike
- PL/I
- Pop11
- PostScript
- PowerShell
- ProDOS
- Prolog
- PSQL
- Pure
- PureBasic
- Python
- Quill
- R
- Racket
- Raven
- REALbasic
- REBOL
- Retro
- REXX
- RTL/2
- Ruby
- Run BASIC
- Rust
- Salmon
- SAS
- Sather
- Scala
- Scheme
- Sed
- Seed7
- Self
- Shiny
- SIMPOL
- Sisal
- Slate
- Smalltalk
- SNOBOL4
- SNUSP
- Standard ML
- Suneido
- Teco
- Tcl
- TI-83 BASIC
- TI-89 BASIC
- TorqueScript
- Transact-SQL
- Trith
- TUSCRIPT
- UNIX Shell
- C Shell
- Unlambda
- Ursala
- V
- Vala
- VBScript
- Vedit macro language
- Whenever
- X86 Assembly
- XL
- XPL0
- XSLT
- Yorick
- Z80 Assembly