各种语言的Hello World程序 1. Ada 2. ALGOL68 3. AmigaE 4. awk 5. BCPL 6. Boo 7. Brainfuck 8. C 9. C++ 10. Clean 11. COBOL ENVIRONMENT DIVISION. DATA DIVISION. PROCEDURE DIVISION. 12. Common Lisp 13. D 14. Eiffel 15. Erlang 16. Forth 17. Fortran 18. Haskell 19. Icon 20. INTERCAL 21. Iptscrae 22. Java // 图形界面: 23. Lua 24. MIXAL 25. MSIL 26. OCaml 27. OPL 28. oz 29. Pascal Perl 30. Pike //图形界面 31. PL/I 32. PostScript 33. PowerBASIC 34. Prolog 35. Python 36. Rexx 37. Ruby 38. Sather 39. Scheme 40. sed 41. Self 42. Smalltalk 43. SML 44. SNOBOL 45. TCL 46. TeX 47. Turing 48. VB 49. VC++ 50. Win32汇编 51. 汇编 53. C# 54. FOXBASE @0,0 say "Hello World!" 55. Groovy 56. PHP |
VB .MET: imports System module Hello sub main() Console.WriteLine("Hello World!") end sub end module JScript: import System; Console.Write("Hello World!/n"); 或 print("Hello World!"); |
易语言: |
Delphi: DOS Batch: |
一个没有main方法的Java版Hello World程序: |
Xaml: SQL: SML: 另一个版本的标准C++: C99风格: |
我编写的不用输出函数的C语言版Hello World程序: void main() { int far *x; x=(int far*)0xb8000000; *x++=0x0e48; *x++=0x0e65; *x++=0x0e6c; *x++=0x0e6c; *x++=0x0e6f; *x++=0x0e20; *x++=0x0e57; *x++=0x0e6f; *x++=0x0e72; *x++=0x0e6c; *x++=0x0e64; *x++=0x0e21; } |
C语言的10种Hello World程序: #include <stdio.h> #include <conio.h> #include <stdio.h> #include <stdio.h> #include <stdio.h> #include <stdio.h> #include <stdio.h> #include <stdio.h> #include <conio.h> #include <conio.h> |
Heron: Scala: SPARK: |
PureBASIC: MessageRequester("PureBASIC - Hello", "Hello World!", 0) sub Main() |
Modula-2 Oberon |
另一个版本的C++: #include <iostream> using namespace std; int main(int argc,char *argv[]) { cout<<"Hello World!/n"; return 0; } |
VC++ .NET #include <stdafx.h> #using <mscorlib.dll> using namespace System; int main() { Console::Write("Hello World!/n"); return 0; } |
VJ# .NET } |
Cω using System; class Hello { public static void Main(string[] args) { Console.Write("Hello World!/n"); } } |
BLISS: %TITLE /'HELLO_WORLD/' MODULE HELLO_WORLD (IDENT=/'V1.0/', MAIN=HELLO_WORLD, ADDRESSING_MODE (EXTERNAL=GENERAL)) = BEGIN LIBRARY /'SYS$LIBRARY:STARLET/'; EXTERNAL ROUTINE LIB$PUT_OUTPUT; GLOBAL ROUTINE HELLO_WORLD = BEGIN LIB$PUT_OUTPUT(%ASCID %STRING(/'Hello World!/')) END; END ELUDOM |
SPARK with Spark_IO; --# inherit Spark_IO; --# main_program; procedure Hello_World --# global in out Spark_IO.Outputs; --# derives Spark_IO.Outputs from Spark_IO.Outputs; is begin Spark_IO.Put_Line (Spark_IO.Standard_Output, "Hello World!", 0); end Hello_World; |
Gambas PUBLIC SUB Main() Print "Hello World!" END |
Expanded accumulator machine: Intel x86, Linux, GAS .data msg: .ascii "Hello, world!/n" len = . - msg .text .global _start _start: movl $len,%edx movl $msg,%ecx movl ,%ebx movl ,%eax int x80 movl ,%ebx movl ,%eax int x80 |
General-purpose-register CISC: DEC PDP-11, RT-11, MACRO-11 .MCALL .REGDEF,.TTYOUT,.EXIT .REGDEF HELL MOV #MSG,R1 MOVB (R1),R0 LOOP: .TTYOUT MOVB +(R1),R0 BNE LOOP .EXIT MSG: .ASCIZ /HELLO, WORLD!/ .END HELLO |
CISC on advanced multiprocessing OS: DEC VAX, VMS, MACRO-32 .title hello .psect data, wrt, noexe chan: .blkw 1 iosb: .blkq 1 term: .ascid "SYS$OUTPUT" msg: .ascii "Hello, world!" len = . - msg .psect code, nowrt, exe .entry hello, ^m<> ; Establish a channel for terminal I/O $assign_s devnam=term, - chan=chan blbc r0, end ; Queue the I/O request $qiow_s chan=chan, - func=#io$_writevblk, - iosb=iosb, - p1=msg, - p2=#len ; Check the status and the IOSB status blbc r0, end movzwl iosb, r0 ; Return to operating system end: ret .end hello |
RISC processor: ARM, RISC OS, BBC BASIC/'s in-line assembler "OS_WriteS":EQUS"Hello, world!":EQUB0:ALIGN:MOVPC,R14 |
TI-BASIC |
Commodore BASIC (unstructured) 10 ?"Hello, world!" 20 END |
DCL batch $ write sys$output "Hello, world!" |
Ed and Ex (Ed extended) echo -e /'a/nhello world!/n./np/'|ed |
EUPHORIA puts(1, "Hello, world!") |
Forte TOOL begin TOOL HelloWorld; includes Framework; HAS PROPERTY IsLibrary = FALSE; forward Hello; -- START CLASS DEFINITIONS class Hello inherits from Framework.Object has public method Init; has property shared=(allow=off, override=on); transactional=(allow=off, override=on); monitored=(allow=off, override=on); distributed=(allow=off, override=on); end class; -- END CLASS DEFINITIONS -- START METHOD DEFINITIONS ------------------------------------------------------------ method Hello.Init begin super.Init(); task.Part.LogMgr.PutLine(/'HelloWorld!/'); end method; -- END METHOD DEFINITIONS HAS PROPERTY CompatibilityLevel = 0; ProjectType = APPLICATION; Restricted = FALSE; MultiThreaded = TRUE; Internal = FALSE; LibraryName = /'hellowor/'; StartingMethod = (class = Hello, method = Init); end HelloWorld; |
Frink println["Hello, world!"] |
Game Maker draw_text(x,y,"Hello World"); |
HP-41 & HP-42S
|
Io write("Hello world!/n") |
JVM public class Hello extends java.lang.Object { Method Hello() Method void main(java.lang.String[]) |
kogut WriteLine "Hello, world!" |
MUF : main me @ "Hello, world!" notify ; |
POV-Ray #include "colors.inc" camera { location <3, 1, -10> look_at <3,0,0> } light_source { <500,500,-1000> White } text { ttf "timrom.ttf" "Hello world!" 1, 0 pigment { White } } |
Processing println("Hello world!"); |
RPL (On Hewlett-Packard HP-28, HP-48 and HP-49 series graphing calculators.) << |
XHTML 1.1 <?xml version="1.0" encoding="UTF-8"?> |
XUL <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <box align="center"> <label value="Hello, world!" /> </box> </window> |
LaTeX /documentclass /begin Hello, world! /end |
Ruby with WxWidgets require /'wxruby/' class HelloWorldApp < Wx::App HelloWorldApp.new.main_loop |
SWT public class SWTHello { |
RTML Hello () TEXT "Hello, world!" |
Qt toolkit (in C++) #include <qapplication.h> #include <qpushbutton.h> #include <qwidget.h> #include <iostream> class HelloWorld : public QWidget { Q_OBJECT public: HelloWorld(); virtual ~HelloWorld(); public slots: void handleButtonClicked(); QPushButton *mPushButton; }; HelloWorld::HelloWorld() : QWidget(), mPushButton(new QPushButton("Hello, World!", this)) { connect(mPushButton, SIGNAL(clicked()), this, SLOT(handleButtonClicked())); } HelloWorld::~HelloWorld() {} void HelloWorld::handleButtonClicked() { std::cout << "Hello, World!" << std::endl; } int main(int argc, char *argv[]) { QApplication app(argc, argv); HelloWorld helloWorld; app.setMainWidget(&helloWorld); helloWorld.show(); return app.exec(); } |
又一个Java 版的Hello World: import javaxng.JOptionPane; |
GTK 2.x (in Euphoria)
|
GTK# (in C#) class Hello { static void Main() Window window = new Window ("helloworld"); Application.Run (); } |
GTK toolkit (in C++) #include <iostream> #include <gtkmm/main.h> #include <gtkmm/button.h> #include <gtkmm/window.h> using namespace std; class HelloWorld : public Gtk::Window { public: HelloWorld(); virtual ~HelloWorld(); protected: Gtk::Button m_button; virtual void on_button_clicked(); }; HelloWorld::HelloWorld() : m_button("Hello, world!") { set_border_width(10); m_button.signal_clicked().connect(SigC::slot(*this, &HelloWorld::on_button_clicked)); add(m_button); m_button.show(); } HelloWorld::~HelloWorld() {} void HelloWorld::on_button_clicked() { cout << "Hello, world!" << endl; } int main (int argc, char *argv[]) { Gtk::Main kit(argc, argv); HelloWorld helloworld; Gtk::Main::run(helloworld); return 0; } |
Cocoa or GNUStep (In Objective C) #import <Cocoa/Cocoa.h> @interface hello : NSObject { } @end @implementation hello -(void)awakeFromNib { NSBeep(); // we don/'t need this but it/'s conventional to beep when you show an alert NSRunAlertPanel(@"Message from your Computer", @"Hello, world!", @"Hi!", nil, nil); } @end |
TACL #OUTPUT Hello, world! |
STARLET RACINE: HELLO_WORLD. NOTIONS: HELLO_WORLD : ecrire("Hello, world!"). |
POV-Ray #include "colors.inc" camera { location <3, 1, -10> look_at <3,0,0> } light_source { <500,500,-1000> White } text { ttf "timrom.ttf" "Hello world!" 1, 0 pigment { White } } |
OPS5 (object-class request ^action) (startup (strategy MEA) (make request ^action hello) ) (rule hello (request ^action hello) --> (write |Hello World!| (crlf)) ) |
Malbolge (=<`:9876Z4321UT.-Q+*)M/'&%$H"!~}|Bzy?=|/.zHGwEDCBA@98/6543W10/.R,+O< |
第一代COCO语言 |