"Hello, World!" program: Difference between revisions

Content deleted Content added
m Remove extra semicolons from JS program
deduplicate contents already present in this encyclopedia: replace →‎Examples: with →‎Wikipedia articles containing "Hello, World!" programs: and expand said list so the temptation to insert code again is smaller [it’s September the 10962nd, 1993]
Line 65:
"Time to hello world" (TTHW) is the time it takes to author a "Hello, World!" program in a given programming language. This is one measure of a programming language's ease of use; since the program is meant as an introduction for people unfamiliar with the language, a more complex "Hello, World!" program may indicate that the programming language is less approachable.<ref name="ODwyer">{{cite book |last1=O'Dwyer |first1=Arthur |title=Mastering the C++17 STL: Make full use of the standard library components in C++17 |date=September 2017 |publisher=[[Packt Publishing Ltd]] | isbn=978-1-78728-823-2 |page=251 |url=https://books.google.com/books?id=zJlGDwAAQBAJ&q=%22TTHW%22&pg=PA251 |access-date=4 December 2019 |language=en}}</ref> The concept has been extended beyond programming languages to [[Application programming interface|APIs]], as a measure of how simple it is for a new developer to get a basic example working; a shorter time indicates an easier API for developers to adopt.<ref>{{cite web |last1=Wiegers |first1=Harold |title=The importance of "Time to First Hello, World!" an efficient API program |date=28 June 2018 |url=https://apifriends.com/api-management/api-program-time-first-hello-world/}}</ref><ref>{{cite book |last1=Jin |first1=Brenda |last2=Sahni |first2=Saurabh |last3=Shevat |first3=Amir |title=Designing Web APIs: Building APIs That Developers Love |url=https://books.google.com/books?id=Dg1rDwAAQBAJ&q=%22time%20to%20hello%20world%22&pg=PT150 |date=29 August 2018 |publisher=O'Reilly Media |isbn=9781492026877 |access-date=19 February 2020}}</ref>
 
==Wikipedia articles containing "Hello, World!" programs==
==Examples==
 
{{columns-list|colwidth=20em|
: ''Please consult the respective programming language's Wikipedia article for an example. Following examples are a subset of [[:Category: Programming languages with an ISO standard|programming languages with an ISO standard]].''
*[[ABAP#Hello world|ABAP]]
 
===*[[Ada (programming language)#"Hello, world!" in Ada|Ada]]===
*[[Aldor#Examples|Aldor]]
 
*[[ALGOL#Timeline: Hello world|ALGOL]]
<syntaxhighlight lang="ada">
*[[ALGOL 60]]
with Ada.Text_IO;
*[[AmbientTalk#Hello world|AmbientTalk]]
procedure Hello is
*[[Amiga E#"Hello, world" example|Amiga E]]
begin
*[[Apache Click#Example|Apache Click]]
Ada.Text_IO.Put_Line ("Hello, World!");
*[[Apache Jelly#Usage|Apache Jelly]]
end Hello;
*[[Apache Wicket#Example|Apache Wicket]]
</syntaxhighlight>
*[[AppJar#Example|AppJar]]
 
*[[AppleScript#Hello, world!|AppleScript]]
===[[ALGOL 60]]===
*[[Applesoft BASIC#Sample code|Applesoft BASIC]]
 
*[[Arc (programming language)#Examples|Arc]]
{{sxhl|2=m2|1= BEGIN DISPLAY("Hello, World!") END.}}
*[[Atari Assembler Editor#Example code|Atari Assembler Editor]]
 
*[[AutoLISP#Examples|AutoLISP]]
===[[BASIC]]===
*[[AviSynth#"Hello World"|AviSynth]]
 
*[[AWK#Hello World|AWK]]
<syntaxhighlight lang="basic">
*[[BASIC#Examples|BASIC]]
10 PRINT "Hello, World!"
*[[Basic Assembly Language#Examples|Basic Assembly Language]]
 
*[[Beatnik (programming language)#Hello World|Beatnik]]
</syntaxhighlight>
*[[Befunge#Sample Befunge-93 code|Befunge]]
 
===*[[CBETA (programming language)#Hello world!|CBETA]]===
*[[Blitz BASIC#Examples|Blitz BASIC]]
 
*[[Brainfuck#Hello World!|Brainfuck]]
<syntaxhighlight lang="c">
*[[C (programming language)#"Hello, world" example|C]]
#include <stdio.h>
*[[Caché ObjectScript#Caché programming examples|Caché ObjectScript]]
 
*[[Cairo (graphics)#Example|Cairo]]
int main(void)
*[[C/AL#Hello World|C/AL]]
{
*[[Carbon (programming language)#Example|Carbon]]
printf("Hello, World!\n");
*[[Casio BASIC#Examples|Casio BASIC]]
}
*[[Charm (programming language)#Example|Charm]]
</syntaxhighlight>
*[[CherryPy#Pythonic interface|CherryPy]]
 
*[[Clean (programming language)#Examples|Clean]]
===[[C++]]===
*[[Clipper (programming language)#Programming in Clipper|Clipper]]
 
*[[C++#Language|C++]]
<syntaxhighlight lang="c++">
*[[C Sharp (programming language)#Hello World|C#]]
#include <iostream>
*[[COBOL#Hello, world|COBOL]]
 
*[[Cobra (programming language)#Hello World|Cobra]]
int main()
*[[Common Intermediate Language#Example|Common Intermediate Language]]
{
*[[Crystal (programming_language)#Hello World|Crystal]]
std::cout << "Hello, World!" << std::endl;
*[[Cython#Example|Cython]]
}
*[[Dart (programming language)#Example|Dart]]
</syntaxhighlight>
*[[Darwin (programming language)#Example Code|Darwin]]
<!-- Note "return 0;" is implicit in main, I believe in at least C++20 if not all versions. -->
*[[Data General Nova#Hello world program|Data General Nova]]
 
*[[Deno (software)#Examples|Deno]]
;C++23
*[[DOORS Extension Language#"Hello, World" example|DOORS Extension Language]]
 
*[[Easy Programming Language#Programming examples|Easy Programming Language]]
Also allowed in [[C++23]]:<ref>{{Cite web |title=C++23: “Hello World!” with Modern C++23 « Marc Gregoire's Blog |url=https://www.nuonsoft.com/blog/2023/01/14/hello-world-with-modern-c23/ |access-date=2023-05-04}}</ref>
*[[EC (programming language)#Hello world|eC]]
 
*[[El-76#Program sample|Эль-76]]
<syntaxhighlight lang="c++">
*[[Elixir (programming language)#Examples|Elixir]]
import std;
*[[Enyo (software)#Examples|Enyo]]
*[[Extensible Embeddable Language#Example code|Extensible Embeddable Language]]
int main()
*[[Ezhil (programming language)#Hello world|எழில்]]
{
*[[Fantom (programming language)#"Hello World" example|Fantom]]
std::print("Hello world!\n");
*[[FastAPI#Example|FastAPI]]
}
*[[Fjölnir (programming language)#Code examples|Fjölnir]]
</syntaxhighlight>
*[[Flask (web framework)#Example|Flask]]
 
===*[[C SharpFlix (programming language)|C#Hello world|Flix]]===
*[[Forth (programming language)#“Hello, World!”|Forth]]
 
*[[Fortran#"Hello, World!" example|FORTRAN]]
<syntaxhighlight lang="c#">
*[[Fortress (programming language)#Example: Hello world!|Fortress]]
using System;
*[[FreeBASIC#Example code|FreeBASIC]]
 
*[[Godot (game engine)#GDScript|Godot]]
class Program
*[[Google Gadgets#Technology|Google Gadgets]]
{
*[[GNU Smalltalk#Examples|GNU Smalltalk]]
static void Main()
*[[Harbour (programming language)#Sample code|Harbour]]
{
*[[Haskell#Code examples|Haskell]]
Console.WriteLine("Hello, World!");
*[[Hollywood (programming language)#Hello World program|Hollywood]]
}
*[[HTML#Markup|HTML]]
}
*[[HTML Application#Example|HTML Application]]
 
*[[IBM Open Class#Examples|IBM Open Class]]
</syntaxhighlight>or, using top-level statements (starting in C# 9):<ref>{{Cite web |title=Top-level statements - programs without Main methods |url=https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/program-structure/top-level-statements |access-date=2022-09-08 |website=Microsoft Docs |language=en-us}}</ref><syntaxhighlight lang="c#">
*[[Idris (programming language)#Features|Idris]]
using System;
*[[INTERCAL#Hello, world|INTERCAL]]
 
*[[Internet Foundation Classes#Hello World|Internet Foundation Classes]]
Console.WriteLine("Hello, World!");
*[[Io (programming language)#Examples|Io]]
</syntaxhighlight>
*[[IRAF#IRAF specific languages|IRAF]]
 
*[[J (programming language)#Examples|J]]
===[[COBOL]]===
*[[JADE (programming language)#Hello World!|JADE]]
 
*[[Jam.py (web framework)#Example|Jam.py]]
<syntaxhighlight lang="cobolfree">
*[[Java (programming language)#Hello world example|Java]]
IDENTIFICATION DIVISION.
*[[JavaFX Script#Syntax|JavaFX Script]]
PROGRAM-ID. HELLO-WORLD.
*[[JavaScript#Simple examples|JavaScript]]
PROCEDURE DIVISION.
*[[JFace#Example|JFace]]
DISPLAY 'Hello, World!'.
*[[JUDO (software)#Syntax|JUDO]]
STOP RUN.
*[[K (programming language)#Examples|K]]
</syntaxhighlight>
*[[KERNAL#Example|KERNAL]]
 
*[[Kivy (framework)#Code example|Kivy]]
===[[Forth (programming language)|Forth]]===
*[[K-Meleon#Customization|K-Meleon]]
 
*[[LibreLogo#Hello world example|LibreLogo]]
<syntaxhighlight lang="forth">
*[[Lisp (programming language)#Examples|Lisp]]
." Hello, World!" CR
*[[LiveScript (programming language)#Syntax|LiveScript]]
</syntaxhighlight>
*[[LOLCODE#Language structure and examples|LOLCODE]]
 
*[[Lua (programming language)#Syntax|Lua]]
===[[Fortran]]===
*[[MAC/65#MAC/65 ToolKit|MAC/65]]
 
*[[MACRO-10#Programming examples|MACRO-10]]
<syntaxhighlight lang="fortran">
*[[MACRO-11#Programming example|MACRO-11]]
program Hello
*[[MAD (programming language)#"Hello, world" example|MAD]]
print *, "Hello, World!"
*[[Magik (programming language)#Hello World example|Magik]]
end program Hello
*[[Malbolge#Hello, World!|Malbolge]]
</syntaxhighlight>
*[[Mercury (programming language)#Examples|Mercury]]
 
*[[MicroPython|MicroPython]]
===[[JavaScript]]===
*[[Microsoft Small Basic#Language|Microsoft Small Basic]]
 
*[[MIDletPascal#Hello World|MIDletPascal]]
For browser console/JavaScript runtime (such as [[Node.js]]):<syntaxhighlight lang="javascript">
*[[mIRC scripting language#Code examples|mIRC scripting language]]
console.log("Hello, World!")
*[[MMIX#Architecture|MMIX]]
</syntaxhighlight>
*[[Mockito#Example|Mockito]]
For HTML document:
*[[Modula-3#Syntax|Modula-3]]
<syntaxhighlight lang="javascript">
*[[Mojo (programming language)#Programming examples|Mojo]]
document.write("Hello, World!")
*[[Monad (functional programming)#IO monad (Haskell)|Monad]]
</syntaxhighlight>
*[[MUMPS#Hello, World! example|MUMPS]]
or
*[[MXML#Example source code|MXML]]
<syntaxhighlight lang="javascript">
alert("*[[Nemerle#Hello, World!")|Nemerle]]
*[[Netwide Assembler#Sample programs|Netwide Assembler]]
</syntaxhighlight>
*[[Newspeak (programming language)#"Hello World" example|Newspeak]]
 
===*[[PascalNim (programming language)#Hello world|PascalNim]]===
*[[NWScript#Hello world|NWScript]]
 
*[[OmniMark#Example code|OmniMark]]
<syntaxhighlight lang="pascal">
*[[Opa (programming language)#Hello world|Opa]]
program hello(output);
*[[OpenEdge Advanced Business Language#Hello World|OpenEdge Advanced Business Language]]
begin
*[[Open Programming Language#Examples|Open Programming Language]]
writeln('Hello, World!');
*[[Oriel (scripting language)#Examples|Oriel]]
end.
*[[ParaSail (programming language)#Examples|ParaSail]]
</syntaxhighlight>
*[[Parrot assembly language]]
 
*[[Parrot intermediate representation#Example|Parrot intermediate representation]]
===[[Prolog]]===
*[[Pascal (programming language)#Language constructs|Pascal]]
 
*[[PCASTL#Hello world|PCASTL]]
<syntaxhighlight lang="prolog">
*[[PDP-8#String output|PDP-8]]
main() :- write("Hello, World!"), nl.
*[[Perl language structure#Basic syntax|Perl]]
</syntaxhighlight>
*[[Perl module#Examples|Perl module]]
 
*[[PHP#Syntax|PHP]]
===[[Python (programming language)|Python]]===
*[[Plack (software)#Examples|Plack]]
 
*[[Plua#Sample code, Plua 1|Plua]]
<syntaxhighlight lang="python">
*[[Plus (programming language)#"Hello, world" example|Plus]]
print("Hello, World!")
*[[PostScript#"Hello world"|PostScript]]
</syntaxhighlight>
*[[PowerBASIC#Hello world|PowerBASIC]]
 
*[[Prolog#Hello World|Prolog]]
===[[Ruby (programming language)|Ruby]]===
*[[PureBasic#Hello World example|PureBasic]]
 
*[[Pure Data#Code examples|Pure Data]]
<syntaxhighlight lang="ruby">
*[[PureScript#Examples|PureScript]]
puts "Hello, World!"
*[[PyGTK#Syntax|PyGTK]]
</syntaxhighlight>
*[[Python (programming language)#Programming examples|Python]]
 
===*[[RustQ (programming language from Kx Systems)#Examples|RustQ]]===
*[[QB64#Syntax|QB64]]
 
*[[QuickBASIC#Syntax example|QuickBASIC]]
<syntaxhighlight lang="rust">
*[[Rack (web server interface)#Example application|Rack]]
fn main() {
*[[Racket (programming language)#Code examples|Racket]]
println!("Hello, World!");
*[[Raku (programming language)#Hello world|Raku]]
}
*[[React (software)#Basic usage|React]]
</syntaxhighlight>
*[[React Native#Hello World example|React Native]]
===[[Scala (programming language)|Scala]]===
*[[Rebol#Design|Rebol]]
<syntaxhighlight lang="scala">
*[[Refal#Basics|Refal]]
object HelloWorld:
*[[RGtk2#Syntax|RGtk2]]
def main(args: Array[String]): Unit =
*[[Robot Framework#Examples|Robot Framework]]
println("Hello, world!")
*[[Ruby syntax#Interactive sessions|Ruby]]
*[[Rust (programming language)#Hello World program|Rust]]
</syntaxhighlight>
*[[SARL (programming language)#Hello, World!|SARL]]
*[[Scala (programming language)#"Hello World" example|Scala]]
*[[Scilab#Syntax|Scilab]]
*[[Scratch (programming language)|Scratch]]
*[[Sed#Hello, world! example|Sed]]
*[[Self (programming language)#Basic syntax|Self]]
*[[Shakespeare Programming Language#Example code|Shakespeare]]
*[[Silex (web framework)#Example|Silex]]
*[[Simula#Classic Hello world|Simula]]
*[[SmallBASIC#Syntax|SmallBASIC]]
*[[Smalltalk#Hello World example|Smalltalk]]
*[[Standard ML#Hello world|Standard ML]]
*[[Standard Widget Toolkit#Programming|Standard Widget Toolkit]]
*[[TeX#How it is run|TeX]]
*[[TI-990#Assembly Language Programming Example|TI-990]]
*[[TI-BASIC#Hello world|TI‑BASIC]]
*[[Tornado (web server)#Example|Tornado]]
*[[Turbo Pascal#Syntax|Turbo Pascal]]
*[[Turing (programming language)#Syntax|Turing]]
*[[UCBLogo#Syntax|UCBLogo]]
*[[UEFI#Applications development|UEFI]]
*[[Umple#Examples|Umple]]
*[[Unit.js#Usage|Unit.js]]
*[[Unlambda#Basic principles|Unlambda]]
*[[Vala (programming language)#Hello world|Vala]]
*[[Visual Basic (.NET)#Hello_World!|Visual Basic]]
*[[Visual IRC#Code examples|Visual IRC]]
*[[web2py]]
*[[Web Server Gateway Interface#Example application|Web Server Gateway Interface]]
*[[Whitespace (programming language)#Sample code|Whitespace]]
*[[Wt (web toolkit)#Code example|Wt]]
*[[XBLite#Sample Code|XBLite]]
*[[XHarbour#Hello, world!|XHarbour]]
*[[Xojo#Example code|Xojo]]
*[[XULJet#Examples|XULJet]]
}}
 
==See also==
Line 230 ⟶ 266:
*[[99 Bottles of Beer#References in computer science|"99 Bottles of Beer" as used in computer science]]
*{{slink|Bad Apple!!|Use as a graphical and audio test}} (graphic equivalent to "Hello, World!" for old hardware)
*{{slink|C (programming language)|"Hello, world" example}}
*[[Foobar]]
*[[Java BluePrints|Java Pet Store]]