Programa Olá Mundo
O "Olá Mundo" ou "Alô Mundo" é um famoso programa de computador que imprime "Olá, Mundo!" (ou "Hello, World!"), usualmente seguido de uma quebra de linha, com algumas variações como inexistência do ponto de exclamação e letras em minúscula, no dispositivo de saída. É utilizado como um teste ou como um exemplo de código minimalista de uma linguagem de programação.[1] Um programa de propósito semelhante é o algoritmo de Trabb Pardo-Knuth.[2][3]
O primeiro programa Olá Mundo de que se tem conhecimento foi implementado na linguagem B, para o livro A Tutorial Introduction to the Language B.[4]
[editar] Linguagens de programação comuns
Exemplos de programas Olá Mundo em linguagens de programação comuns:[1]
[editar] ABAP
REPORT OlaMundo. WRITE 'Olá, Mundo!'.
[editar] Ada
with Ada.Text_IO; procedure OlaMundo is begin Ada.Text_IO.Put_Line("Olá, Mundo!"); Ada.Text_IO.New_Line; end OlaMundo;
[editar] ActionScript
trace ("Olá, Mundo!")
[editar] AppleScript
display dialog "Olá, Mundo"
[editar] Assembly
variable: .message db "Olá, Mundo!$" code: mov ah, 9 mov dx, offset .message int 0x21 ret
[editar] Awk
BEGIN { print("Olá, Mundo!") }
[editar] B
O primeiro programa Olá Mundo de que se tem conhecimento foi implementado na linguagem B, para o livro A Tutorial Introduction to the Language B.[4]
main( ) { extrn a, b, c; putchar(a); putchar(b); putchar(c); putchar('!*n'); } a 'hell'; b 'o, w'; c 'orld';
Ou, equivalente:
main() { putchar('Olá, Mundo!*n'); }
[editar] Bash
echo "Olá, Mundo!"
[editar] BASIC
PRINT "Olá, Mundo!"
[editar] Boo
print("Olá, Mundo!")
[editar] C
[editar] K&R C
#include <stdio.h> int main(void) { puts("Olá, Mundo!"); return 0; }
[editar] C99
int main() { puts("Olá, Mundo!"); }
[editar] C++
#include <iostream> int main() { std::cout << "Olá, Mundo!" << std::endl; return 0; }
Ou, equivalente:
#include <iostream> using namespace std; int main() { cout << "Olá, Mundo!" << endl; return 0; }
[editar] C♯
using System; namespace Teste { class OlaMundo { static void Main() { Console.WriteLine("Olá, Mundo!"); } } }
[editar] Clipper / dBase / xBase / Visual FoxPro
? "Olá, Mundo!"
[editar] Clojure
(println "Olá, Mundo!")
[editar] COBOL
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO-WORLD. ENVIRONMENT DIVISION. DATA DIVISION. PROCEDURE DIVISION. DISPLAY "Olá, Mundo!". STOP RUN.
Ou, equivalente:
DISPLAY "Olá, Mundo!".
[editar] D
import std.stdio; void main() { writefln("Olá, Mundo!"); }
[editar] Dart
main() { print('Olá, Mundo!'); }
[editar] Delphi
Program Ola_Mundo; {$APPTYPE CONSOLE} begin WriteLn('Olá, Mundo!'); end.
Ou, equivalente:
Program Ola_Mundo; begin ShowMessage('Olá, Mundo!'); end.
Ou, equivalente:
Program Ola_Mundo; begin MessageDlg('Olá, Mundo!', mtinformation, [mbok], 0); end.
[editar] Erlang
-module(ola). -export([ola/0]). ola() -> io:format("Olá, Mundo!~n", []).
[editar] Euphoria
puts(1, "Olá, Mundo!\n")
[editar] F♯
printfn "Olá, Mundo!"
[editar] Fantom
class OlaMundo { static Void main() { echo("Olá, Mundo!") } }
[editar] Forth
: OLA ."Olá, Mundo!" CR ;
[editar] Fortran
PROGRAM HELLO WRITE(*,10) 10 FORMAT('Olá, Mundo!') STOP END
[editar] Game Maker Language
draw_text(x,y,"Olá, Mundo!");
Ou, equivalente:
show_message("Olá, Mundo!");
[editar] Go
package main import "fmt" func main() { fmt.Printf("Olá, Mundo!\n") }
[editar] Groovy
println("Olá, Mundo!")
[editar] Haskell
olamundo :: IO() olamundo = putStrLn "Olá, Mundo!"
[editar] Icon / Unicon
[editar] Java
public class OlaMundo { public static void main(String[] args) { System.out.println("Olá, Mundo!"); } }
[editar] JavaScript
document.write( 'Olá, mundo!' );
ou
alert( 'Olá, mundo!' );
ou
console.log( 'Olá, mundo!' );
[editar] Linden Scripting Language
default { state_entry() { llSay(0, "Olá, Mundo!"); } }
[editar] Lisp
(print "Olá, Mundo!\n")
[editar] Logo
print [Olá, Mundo!]
[editar] Lua
print "Olá, Mundo!"
[editar] Objective-C
#import <stdio.h> int main(void) { puts("Olá, Mundo!"); return 0; }
[editar] Pascal
program OlaMundo(output); begin WriteLn('Olá, Mundo!'); end.
Ou, se estiver sendo usado o compilador Borland Pascal 7 para Windows:
PROGRAM OlaMundo; USES WinCRT; BEGIN InitWinCRT; WriteLn('Olá, Mundo!'); ReadLn; DoneWinCRT; END.
[editar] Perl
print "Olá, Mundo!";
[editar] PHP
<?php echo "Olá, Mundo!"; ?>
Ou, equivalente:
<?php print "Olá, Mundo!"; ?>
[editar] PL/SQL
SET ServerOutPut ON Size[sc_sql] } BEGIN SYS.DBMS_OUTPUT.PUT_LINE('Olá, Mundo!'); END;
[editar] Portugol
algoritmo OlaMundo
inicio escreva("Olá, Mundo!") fim
[editar] Prolog
write('Olá, Mundo!').
[editar] Python
print("Olá, Mundo!")
[editar] Ruby
puts "Olá, Mundo!"
[editar] Scala
object OlaMundo { def main(args: Array[String]) { println("Olá, Mundo!") } }
Ou, equivalente:
object OlaMundo extends Application { println("Olá, Mundo!") }
[editar] Scheme
(display "Olá, Mundo!") (newline)
[editar] Smalltalk
Transcript show: 'Olá, Mundo!'.
[editar] SQL
SELECT 'Olá, Mundo!';
[editar] Tcl
puts "Olá, Mundo!"
[editar] Visual Basic / Visual Basic .NET
Private Sub Form_Load() Print "Olá, Mundo!" End Sub
Ou, equivalente em Visual Basic .NET (VB.NET):
Imports System.Console Class OlaMundo Public Shared Sub Main() WriteLine("Olá, Mundo!") End Sub End Class
[editar] Ver também
- Algoritmo de Trabb Pardo-Knuth
- Anexo:Lista de linguagens de programação
- Programa Olá Mundo em linguagens de programação esotéricas
Referências
- ↑ a b Wolfram Rösler (25 de setembro de 2010). The Hello World Collection (em inglês). helloworldsite.he.funpic.de. Página visitada em 6 de dezembro de 2011.
- ↑ Tpk Algorithm (em inglês). Página visitada em 6 de dezembro de 2011.
- ↑ Ryan Stansifer (12 de julho de 2011). TPK Algorithm in Different Programming Languages (em inglês). cs.fit.edu. Página visitada em 6 de dezembro de 2011.
- ↑ a b Brian W. Kernighan (1996). A Tutorial Introduction to the Language B (em inglês). Lucent Technologies Inc.. Página visitada em 7 de dezembro de 2011.