跳轉到內容

計算機程式設計/Hello world

來自 Wikibooks,開放書籍,開放世界
(重定向自 Hello world 程式)

以下列出了 Hello, world! 程式。

Hello, world! 程式使文字 "Hello, world!" 呈現在電腦螢幕上。 它通常是學習程式語言時遇到的第一個程式。 否則,它就是對新程式語言安裝的基本完整性檢查。 如果 "Hello World" 無法執行,在解決安裝問題之前,不能嘗試開發複雜程式。

要檢視更多語言,請檢視 Hello World 合集

4DOS 批處理

[編輯 | 編輯原始碼]

需要注意的是,4DOS/4NT 批處理語言是 MS-DOS 批處理語言的超集。

 @echo Hello, world!

Ingres 4GL

[編輯 | 編輯原始碼]
message "Hello, world!" with style = popup;

ABAP/4 - SAP AG

[編輯 | 編輯原始碼]
 REPORT ZHELLO.
 START-OF-SELECTION.
   WRITE "Hello, world!".

ABAP 物件 (NetWeaver 7)

[編輯 | 編輯原始碼]

下面的示例使用單例模式,在訊息框中輸出文字,而不是傳統的列表輸出。

 REPORT ZHELLO.
 CLASS lcl_hello DEFINITION CREATE PRIVATE FINAL.
   PUBLIC SECTION.
     CLASS-DATA self TYPE REF TO lcl_hello READ-ONLY.
     CLASS-METHODS class_constructor.
     METHODS say_hello.
   PRIVATE SECTION.
     CONSTANTS con_hello_world TYPE c LENGTH 13 VALUE 'Hello, World!'.
 ENDCLASS.
 CLASS lcl_hello IMPLEMENTATION.
   METHOD class_constructor.
     CREATE OBJECT lcl_hello=>self.
   ENDMETHOD.
   METHOD say_hello.
     MESSAGE con_hello_world TYPE 'I'.
   ENDMETHOD.
 ENDCLASS.
 START-OF-SELECTION.
   lcl_hello=>self->say_hello( ).
WRITE "Hello, world!" 

ActionScript

[編輯 | 編輯原始碼]

ActionScript 1.0 和 2.0

[編輯 | 編輯原始碼]

這將僅輸出到輸出視窗,終端使用者不會看到。

trace("Hello, world!");

此版本將對終端使用者可見。

var helloWorld:TextField = this.createTextField( "helloWorld", this.getNextHighestDepth(), 1, 1, 100, 20 );
helloWorld.text = "Hello, world!";

ActionScript 3

[編輯 | 編輯原始碼]
package
{
    public class HelloWorld
    {
        public function HelloWorld()
        {
            trace("Hello, world!");
        }
    }
}
with Ada.Text_IO;

procedure Hello is
begin
   Ada.Text_IO.Put_Line ("Hello, world!");
end Hello;

ALGOL 68 標準要求保留字型別運算子使用不同的字型。 因此,程式通常以粗體下劃線字型釋出,例如

begin
    printf($"Hello, world!"l$)
end

在流行的粗體單詞大寫斷行約定中

BEGIN
    printf($"Hello, world!"l$)
END

或使用類似維基文字的引用斷行,這在只有 6 位字元的計算機上特別有用(因此只有大寫字母)

'BEGIN'
    PRINTF($"HELLO, WORLD!"L$)
'END'

或者最少使用beginend 的“簡寫符號”形式。

( printf($"Hello, world!"l$) )
PROC main()
   WriteF('Hello, world!');
ENDPROC

AMX NetLinx

[編輯 | 編輯原始碼]

此程式在啟動後透過診斷介面傳送訊息。

program_name = 'Hello'
define_start
send_string 0,'Hello World!'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project>
<project default="helloworld">
	<target name="helloworld">
		<echo message="Hello, World!" />
	</target>
</project>
    RHWΔPGM 
[1] R'HELLO WORLD!'
    
  • 第一行中的 Del 開始定義名為 HWΔPGM 的程式的函式定義。它是一個零元函式(沒有引數,與一元或二元函式相反),它將返回一個顯式結果,允許其他函式或 APL 運算子使用返回值作為輸入。
  • 標記為 1 的行將文字向量 'Hello, world!!' 分配給變數 R。
  • 最後一行是另一個 Del,它結束函式定義。

當函式透過鍵入其名稱來執行時,APL 直譯器將文字向量分配給變數 R,但是由於我們在另一個函式、運算子或賦值語句中沒有使用此值,直譯器將其返回到終端,從而在函式呼叫下方顯示下一行的單詞。

會話將如下所示

      HWΔPGM
Hello, world!!

雖然不是程式,但如果只是將文字向量提供給直譯器而不將其分配給變數,它將將其作為輸出返回到終端。請注意,使用者輸入由直譯器自動縮排 6 個空格,而結果則顯示在新行的開頭。

      'Hello, world!'
Hello, world!!

AppleScript

[edit | edit source]
return "Hello, world!"

display dialog "Hello, world!"
<% Response.Write("Hello, world!") %>
或只是
<%= "Hello, world!" %>

ASP.NET

[edit | edit source]
// in the page behind using C#
protected void Page_Load(object sender, EventArgs e)
{
 Response.Write("Hello, world!");
}
' in the page behind using VB.NET
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    Response.Write("Hello, world!")
End Sub
// ASPX Page Template

<asp:Literal ID="Literal1" runat="server" Text="Hello World!"></asp:Literal>

<asp:Label ID="Label1" runat="server" Text="Hello World"></asp:Label>

Hello World!

組合語言

[edit | edit source]

僅累加器架構:DEC PDP-8,PAL-III 彙編器

[edit | edit source]

請參閱維基百科 PDP-8 文章中的 示例 程式。.

首次成功 uP/OS 組合:Intel 8080/Zilog Z80,CP/M,RMAC 彙編器

[edit | edit source]
 bdos    equ    0005H    ; BDOS entry point
 start:  mvi    c,9      ; BDOS function: output string
         lxi    d,msg$   ; address of msg
         call   bdos
         ret             ; return to CCP
 
 msg$:   db    'Hello, world!$'
 end     start
[edit | edit source]
  10          ORG #8000    ; Start address of the routine
  20 START    LD A,2       ; set the output channel
  30          CALL #1601   ; to channel 2 (main part of TV display)
  40          LD HL,MSG    ; Set HL register pair to address of the message
  50 LOOP     LD A,(HL)    ; De-reference HL and store in A
  60          AND A        ; Null terminator?
  70          RET Z        ; If so, return
  80          RST #10      ; Print the character in A
  90          INC HL       ; HL points at the next char to be printed
 100          JR LOOP
 110          RET
 120 MSG      DEFM "Hello, world!"
 130          DEFB 13      ; carriage return
 140          DEFB 0       ; null terminator

累加器 + 索引暫存器機器:MOS Technology 6502,CBM KERNEL,MOS 彙編器語法

[edit | edit source]
 A_CR  = $0D              ;carriage return
 BSOUT = $FFD2            ;kernel ROM sub, write to current output device
 ;
         LDX #$00         ;starting index in .X register
 ; 
 LOOP    LDA MSG,X        ;read message text
         BEQ LOOPEND      ;end of text
 ;
         JSR BSOUT        ;output char
         INX
         BNE LOOP         ;repeat
 ;
 LOOPEND RTS              ;return from subroutine
 ;
 MSG     .BYT 'Hello, world!',A_CR,$00

累加器/索引微碼機器:Data General Nova,RDOS

[edit | edit source]

請參閱 Nova 文章的 示例 部分。

擴充套件累加器機器:Intel x86,DOS,TASM

[edit | edit source]
MODEL   SMALL
IDEAL
STACK   100H
 
DATASEG
        MSG DB 'Hello, world!', 13, '$'
 
CODESEG
Start:
        MOV AX, @data
        MOV DS, AX
        MOV DX, OFFSET MSG
        MOV AH, 09H      ; DOS: output ASCII$
        INT 21H
        MOV AX, 4C00H
        INT 21H
END Start

彙編器 x86 (DOS,MASM)

[edit | edit source]
.MODEL Small
.STACK 100h
.DATA
   db msg 'Hello, world!$'
.CODE
start:
   mov ah, 09h
   lea dx, msg ; or mov dx, offset msg
   int 21h
   mov ax,4C00h
   int 21h
end start

彙編器 x86 (DOS,FASM)

[edit | edit source]
; FASM example of writing 16-bit DOS .COM program
; Compile: "FASM HELLO.ASM HELLO.COM" 
  org  $100
  use16    
  mov  ah,9
  mov  dx,xhello
  int  $21    ; DOS call: text output
  mov  ah,$4C
  int  $21    ; Return to DOS
xhello db 'Hello world !!!$'

擴充套件累加器機器:Intel x86,Microsoft Windows,FASM

[edit | edit source]

將 32 位 PE 程式作為原始程式碼和資料的示例

format PE GUI 
entry start
 
section '.code' code readable executable
 
    start:
 
        push   0
        push   _caption
        push   _message
        push   0
        call   [MessageBox]
 
        push   0
        call   [ExitProcess]
 
section '.data' data readable writeable
 
  _caption db 'Win32 assembly program',0
  _message db 'Hello, world!',0
 
section '.idata' import data readable writeable
 
  dd 0,0,0,RVA kernel_name,RVA kernel_table
  dd 0,0,0,RVA user_name,RVA user_table
  dd 0,0,0,0,0
 
  kernel_table:
    ExitProcess dd RVA _ExitProcess
    dd 0
  user_table:
    MessageBox dd RVA _MessageBoxA
    dd 0
 
  kernel_name db 'KERNEL32.DLL',0
  user_name db 'USER32.DLL',0

  _ExitProcess dw 0
     db 'ExitProcess',0
  _MessageBoxA dw 0
     db 'MessageBoxA',0
 
section '.reloc' fixups data readable discardable

使用 FASM 匯入宏,Unicode(MessageBoxW 是 Windows 9x/ME“支援”的少數幾個 Unicode 函式之一)和節共享,沒有重定位(對於 32 位 Windows NT 可執行檔案來說不是必需的,建議用於基於 DOS 的 Windows,對於 x64 來說是**必需的**),沒有堆 - 不是初學者的示例,但只有 1024 位元組,而不是 3072 位元組。

format PE GUI 4.0
heap 0
entry start
include 'win32a.inc'

section '.text' code import readable executable data
  library kernel, 'KERNEL32.DLL',\
    user,'USER32.DLL'

  import kernel,\
    ExitProcess, 'ExitProcess'
  import user,\
    MessageBoxW, 'MessageBoxW'

  start:
    xor ebx, ebx
    push ebx
    push ebx
    push _message
    push ebx
    call [MessageBoxW]

    push ebx
    call [ExitProcess]

_message du 'Hello, world!' ,0
section '.reloc' fixups data readable discardable

擴充套件累加器機器:Intel x86,Linux,FASM

[edit | edit source]
format ELF executable
entry _start
 
_start:
     mov eax, 4
     mov ebx, 1
     mov ecx, msg
     mov edx, msg_len
     int 80h

     mov ebx, 0
     mov eax, 1
     int 80h
 
     msg db 'Hello, world!', 0xA
     msg_len = $-msg

擴充套件累加器機器:Intel x86,Linux,GAS

[edit | edit source]
.data
msg:
    .ascii     "Hello, world!\n"
    len = . - msg
.text
    .global _start
_start:
    movl $len,%edx
    movl $msg,%ecx
    movl $1,%ebx
    movl $4,%eax
    int $0x80
    movl $0,%ebx
    movl $1,%eax
    int $0x80

擴充套件累加器機器:Intel x86,Linux,NASM

[edit | edit source]
    section .data
msg     db      'Hello, world!',0xA
len     equ     $-msg
 
    section .text
global  _start
_start:
        mov     edx,len
        mov     ecx,msg
        mov     ebx,1
        mov     eax,4
        int     0x80
 
        mov     ebx,0
        mov     eax,1
        int     0x80

擴充套件累加器機器:Intel x86,Linux,GLibC,NASM

[edit | edit source]
extern printf ; Request symbol "printf".
global main   ; Declare symbol "main".
 
section .data
  str: DB "Hello World!", 0x0A, 0x00
 
section .text
main:
  PUSH str    ; Push string pointer onto stack.
  CALL printf ; Call printf.
  POP eax     ; Remove value from stack.
  MOV eax,0x0 ; \_Return value 0.
  RET         ; /

通用虛構計算機:MIX,MIXAL

[edit | edit source]
TERM    EQU    19          console device no. (19 = typewriter)
        ORIG   1000        start address
START   OUT    MSG(TERM)   output data at address MSG
        HLT                halt execution
MSG     ALF    "HELLO"
        ALF    " WORL"
        ALF    "D    "
        END    START       end of program

通用虛構計算機:MMIX,MMIXAL

[edit | edit source]
string  BYTE   "Hello, world!",#a,0   string to be printed (#a is newline and 0 terminates the string)
  Main  GETA   $255,string            get the address of the string in register 255
        TRAP   0,Fputs,StdOut         put the string pointed to by register 255 to file StdOut
        TRAP   0,Halt,0               end process

通用暫存器 CISC:DEC PDP-11

[edit | edit source]

RT-11,MACRO-11

[edit | edit source]
         .MCALL  .REGDEF,.TTYOUT,.EXIT
         .REGDEF
 
 HELLO:  MOV    #MSG,R1
         MOVB   (R1)+,R0
         BEQ    EXIT
 LOOP:  .TTYOUT
         BR    LOOP
EXIT:
        .EXIT
 
 MSG:   .ASCIZ  /Hello, world!/
        .END    HELLO

使用 BIOS 函式的 Elektronika BK 變體,MICRO-11

[edit | edit source]
         MOV     #TXT,R1              ;Moving string address to R1
         CLR     R2                   ;String length=0, means null will be the termination character
         EMT     20                   ;Print the string
         HALT
 
 TXT:    .ASCIZ  /Hello, world!/
         .END

CISC Amiga (Workbench 2.0): Motorola 68000

[edit | edit source]
        include lvo/exec_lib.i
        include lvo/dos_lib.i
 
        ; open DOS library
        movea.l  4.w,a6
        lea      dosname(pc),a1
        moveq    #36,d0
        jsr      _LVOOpenLibrary(a6)
        movea.l  d0,a6
 
        ; actual print string
        lea      hellostr(pc),a0
        move.l   a0,d1
        jsr      _LVOPutStr(a6)
 
        ; close DOS library
        movea.l  a6,a1
        movea.l  4.w,a6
        jmp      _LVOCloseLibrary(a6)
 
dosname     dc.b 'dos.library',0
hellostr    dc.b 'Hello, world!',0

CISC Atari: Motorola 68000

[edit | edit source]
;print
     move.l   #Hello,-(A7)
     move.w   #9,-(A7)
     trap     #1
     addq.l   #6,A7
 
;wait for key
     move.w   #1,-(A7)
     trap     #1
     addq.l   #2,A7
 
;exit
     clr.w   -(A7)
     trap    #1
  
Hello
     dc.b    'Hello, world!',0

CISC Sharp X68000 (Human68K): Motorola 68000

[edit | edit source]
        pea (strign)    ; push string address onto stack
        dc.w $FF09      ; call DOS "print" by triggering an exception
        addq.l #4,a7    ; restore the stack pointer

        dc.w $FF00      ; call DOS "exit"

strign:
        dc.b "Hello, world!",13,10,0

CISC on advanced multiprocessing OS: DEC VAX, VMS, MACRO-32

[edit | edit source]
         .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

大型機:IBM z/Architecture 系列使用 BAL

[edit | edit source]
HELLO    CSECT               The name of this program is 'HELLO'
         USING *,12          Tell assembler what register we are using
         SAVE (14,12)        Save registers
         LR    12,15         Use Register 12 for this program  
         WTO   'Hello, world!' Write To Operator
         RETURN (14,12)      Return to calling party
         END  HELLO          This is the end of the program

RISC 處理器:ARM,RISC OS,BBC BASIC 的內聯彙編器

[edit | edit source]
 .program         
          ADR R0, message
          SWI "OS_Write0"
          SWI "OS_Exit"
 .message         
          EQUS "Hello, world!"
          EQUB 0
          ALIGN

或更小的版本(來自 qUE);

         SWI "OS_WriteS":EQUS "Hello, world!":EQUB0:ALIGN:MOV PC,R14

RISC 處理器:MIPS 架構

[edit | edit source]
          .data
 msg:     .asciiz "Hello, world!"
          .align 2
          .text
          .globl main      
 main:
          la $a0,msg
          li $v0,4
          syscall
          jr $ra

RISC 處理器:PowerPC,Mac OS X,GAS

[edit | edit source]
 .data
 msg:
     .ascii "Hello, world!\n"
     len = . - msg
 
 .text
     .globl _main
 
 _main:
     li r0, 4 ; write
     li r3, 1 ; stdout
     addis r4, 0, ha16(msg) ; high 16 bits of address
     addi r4, r4, lo16(msg) ; low 16 bits of address
     li r5, len ; length
     sc
 
     li r0, 1 ; exit
     li r3, 0 ; exit status
     sc

Sigma 6/7/8/9 METASYMBOL

[edit | edit source]
        SYSTEM   BPM
 START  M:PRINT (MESS,HW)
        M:EXIT
 HW     TEXTC    'HELLO WORLD'
        END      START

AutoHotkey

[edit | edit source]
MsgBox, Hello, world!

(命令名稱後的逗號是可選的。)

AutoIt

[edit | edit source]
MsgBox(0,'','Hello, world!')

Avenue(ArcView GIS 的指令碼語言)

[edit | edit source]
MsgBox("Hello, world!","aTitle")
BEGIN { print "Hello, world!" }

這是第一個已知的 Hello, world! 程式:[1]

 main( ) {
   extrn a, b, c;
   putchar(a); putchar(b); putchar(c); putchar('!*n');
 }
 a 'hell';
 b 'o, w';
 c 'orld';

Baan 工具

[edit | edit source]

在舊版本中也稱為 Triton 工具。在 Baan ERP 上,您可以建立 3GL 或 4GL 模式下的程式。

3GL 格式

[edit | edit source]
function main()
{
    message("Hello, world!")
}

4GL 格式

[edit | edit source]
choice.cont.process:
on.choice:
    message("Hello, world!")

在最後一種情況下,您應該按下“繼續”按鈕以顯示訊息。

Bash 或 sh

[edit | edit source]
echo 'Hello, world!'

printf 'Hello, world!\n'

或使用 C 預處理器

#!/bin/bash
#define cpp #
cpp $0 2> /dev/null | /bin/bash; exit $?
#undef cpp
#define HELLO_WORLD echo "hello, world"
HELLO_WORLD | tr a-z A-Z

BASIC

[edit | edit source]

通用

[edit | edit source]

以下示例適用於任何符合 ANSI/ISO 標準的 BASIC 實現,以及大多數內置於或與 1970 年代和 1980 年代微型計算機一起分發的實現(通常是 Microsoft BASIC 的某些變體)。

10 PRINT "Hello, world!"
20 END

請注意,“END”語句在許多 BASIC 實現中是可選的。

某些實現也可能在省略行號時以立即模式執行指令。以下示例無需 RUN 指令即可工作。

PRINT "Hello, world!"
? "Hello, world!"

後來的 BASIC 實現允許更好地支援結構化程式設計,並且不需要原始碼的行號。以下示例在 RUN 對於絕大多數現代 BASIC 而言。

PRINT "Hello, world!"
END

同樣,“END”語句在許多 BASIC 中是可選的。

BlitzBasic

[edit | edit source]
Print "Hello, world!"
WaitKey

DarkBASIC

[edit | edit source]
PRINT "Hello, world!"

TEXT 0,0,"Hello, world!"
WAIT KEY

注意:“經典”Dark Basic 中的 WAIT KEY 命令是可選的,因為控制檯在程式完成後會彈起。

FreeBasic

[edit | edit source]
PRINT "Hello World"
SLEEP
END

PRINT "Hello World"

? "Hello World"

'without a newline
? "Hello World";

CoolBasic

[edit | edit source]
AddText "Hello, world!"
DrawScreen
WaitKey

GW-BASIC

[edit | edit source]
10 PRINT "Hello, World!"
20 END

Liberty BASIC

[edit | edit source]

寫入主視窗

print "Hello, world"

或在圖形視窗中繪製

nomainwin
open "Hello, world!" for graphics as #main
print #main, "place 50 50"
print #main, "\Hello, world!"
print #main, "flush"
wait

Microsoft Small Basic

[edit | edit source]
TextWindow.WriteLine("Hello, world!")
DEBUG "Hello, world!", CR

或者,典型的微控制器“Hello, world!”程式等效項,唯一的輸出裝置是發光二極體(LED)(在這種情況下連線到第七個輸出引腳)

 DO
     HIGH 7 'Make the 7th pin go high (turn the LED on)
     PAUSE 500 'Sleep for half a second
     LOW 7 ' Make the 7th pin go low (turn the LED off)
     PAUSE 500 'Sleep for half a second
 LOOP
 END

StarOffice/OpenOffice Basic

[編輯 | 編輯原始碼]
 sub main
     print "Hello, world!"
 end sub

PureBasic

[編輯 | 編輯原始碼]
 OpenConsole()
 PrintN("Hello, world!")
 Input()

MessageRequester("Hello, World","Hello, World")

Debug "Hello, World"
PRINT "Hello, World"                                                                                                                                                                                                     END

QBasic 也一樣

在 TI-80 到 TI-86 範圍內的 TI 計算器上

:Disp "Hello, world!          (note the optional ending quotes)
:Output(X,Y,"Hello, world!    (note the optional ending parenthesis)
:Text(X,Y,"Hello, world!      (writes to the graph rather than home screen)
:Text(-1,X,Y,"Hello, world!   (only on the 83+ and higher, provides larger text, home screen size)
:"Hello, world!               (last line of program only)

注意:“!”字元不在鍵盤上。它可以透過“目錄”選單、“機率”選單或“數學”選單(作為階乘符號)訪問。

在 TI-89/TI-89 Titanium/TI-92(+)/Voyage 200 計算器上

:hellowld()
:Prgm
:Disp "Hello, world!"
:EndPrgm

Visual Basic

[編輯 | 編輯原始碼]
Public Sub Main()
    Debug.Print "Hello, world!"
End Sub

Public Sub Main()
  MsgBox "Hello, world!"
End Sub

Private Sub Form_Activate()
    Print "Hello, world!"
End Sub

或者,將此複製到一個新表單中

Private Sub Form_Click()
   Form1.Hide
   Dim HelloWorld As New Form1
   HelloWorld.Width = 2500: HelloWorld.Height = 1000: HelloWorld.Caption = "Hello, world!": HelloWorld.CurrentX = 500: HelloWorld.CurrentY = 75
   HelloWorld.Show: HelloWorld.Font = "Tahoma": HelloWorld.FontBold = True: HelloWorld.FontSize = 12: HelloWorld.Print "Hello, world!"
End Sub

Visual Basic .NET

[編輯 | 編輯原始碼]
Module HelloWorldApp
  Sub Main()
     System.Console.WriteLine("Hello, world!")
  End Sub
End Module

PICK/BASIC、DATA/BASIC、MV/BASIC

[編輯 | 編輯原始碼]

除了本文開頭處的 ANSI 語法之外,大多數 Pick 作業系統版本的 Dartmouth BASIC 還支援擴充套件語法,允許游標定位和其他用於 VDT 的 terminfo 型別功能

X、Y 定位(冒號“:”是連線指令)

  PRINT @(34,12) : "Hello, world!"

將在大約 80X24 CRT 中的中心位置顯示字串“Hello, world!”。

其他功能

  PRINT @(-1) : @(34,12) : "Hello, world!"

將在在大約 80X24 CRT 中的中心位置顯示字串“Hello, world!”之前清除螢幕。

語法變體

 CRT "Hello, world!"

在支援上述“@”功能的情況下,CRT 語句會忽略之前的 PRINTER 語句,並且始終將輸出傳送到螢幕。

某些 Pick 作業系統環境(如 OpenQM)支援 PRINT 的 DISPLAY 變體。除了“@”功能之外,此變體還根據 TERM 變數的設定維護分頁。

 DISPLAY "Hello, world!"

批處理 (MS-DOS)

[編輯 | 編輯原始碼]
@echo Hello World!

@echo off
set hellostring=Hello World!
echo %hellostring%

@echo off
echo Hello World!
pause
exit

@echo Hello World!
pause
exit

作為 CGI 檔案

[編輯 | 編輯原始碼]
@echo off
echo Content-type: text/plain >> sample.cgi
echo. >> sample.cgi
echo. >> sample.cgi
echo Hello, world! >> sample.cgi
"Hello, world!"

或者,使用換行符

 print "Hello, world!\n"
GET "LIBHDR"

LET START () BE
$(
    WRITES ("Hello, world!*N")
$)

BITGGAL AgileDog

[編輯 | 編輯原始碼]
T 
 1 "Hello, World"
 0

BITGGAL Jihwaja

[編輯 | 編輯原始碼]
J( 1 TM 5 ZV 3 "Hello, world" )
%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
 SuperStrict
 Graphics 640, 480, 0, 60
 
 Local running:Int = 1
 While running
 	Cls
 	DrawText "Hello World!", 1, 1
 	Flip
 
 	If GetChar()
 		running = 0
 	EndIf
 Wend
 
 End

另請參閱 GUI 部分.

print "Hello, world!"

Burning Sand 2

[編輯 | 編輯原始碼]
WRITE ELEMENT:Earth 210 230 40 CENTER TEXT "Hello World!"
#include <stdio.h>

int main()
{
    printf("Hello, world!\n");
    return 0;
}
#include <stdio.h>

int main(void) {
    printf("Hello, World!\n");

    return 0;
}

Caché 伺服器頁面 (CSP)

[編輯 | 編輯原始碼]
 Class Test.Hello Extends %CSP.Page [ ProcedureBlock ]
 {
    ClassMethod OnPage() As %Status
    {
        &html<<html>
        <head>
        </head>
        <body>>
        Write "Hello, world!",!
        &html<</body>
        </html>>
        Quit $$$OK
    }
 }

此程式將在 Avasmath 80 線上可程式設計計算器上執行。

#BTN A1
#PRI "HELLO WORLD!"
#END

C/AL - MBS Navision

[編輯 | 編輯原始碼]
OBJECT Codeunit 50000 HelloWorld
{
  PROPERTIES
  {
    OnRun=BEGIN
            MESSAGE(Txt001);
          END;
  }
  CODE
  {
    VAR
      Txt001@1000000000 : TextConst 'ENU=Hello, world!';
    BEGIN
    {
      Hello, world! in C/AL (Microsoft Business Solutions-Navision)
    }
    END.
  }
}

Casio FX-9750

[編輯 | 編輯原始碼]

此程式將在 fx-9750 圖形計算器及其相容機型上執行。

"Hello, world!"

Locate 1,1,"Hello, world!"
 call echo("Hello, world!")

上面的 C 程式碼 可在 Ch 中作為示例執行。Ch 中的簡單程式碼如下:

  printf("Hello, world!\n");
 <<<"Hello World">>>;
namespace HelloWorld;
 
interface
 
type
  HelloClass = class
  public
    class method Main; 
  end;
 
implementation
 
class method HelloClass.Main;
begin
  System.Console.WriteLine('Hello, world!');
end;
 
end.
.assembly Hello {}
.assembly extern mscorlib {}
.method static void Main()
{
     .entrypoint
     .maxstack 1
     ldstr "Hello, world!"
     call void [mscorlib]System.Console::WriteLine(string)
     ret
}

CintieFramework (VisualBasic.NET)

[編輯 | 編輯原始碼]
<Script>
	<References>
		<Reference>System.dll</Reference>
	</References>
	<Code Language="VisualBasic">
<![CDATA[
Public Class Plugin
	Public Function MainF(ByVal Ob As Object) As String
		'Script Code
		Return "Hello, World!"
	End Function
End Class
]]>
	</Code>
</Script>
 module hello
 
 Start = "Hello, world!"
 ? "Hello, world!"

 @1,1 say "Hello, world!"

 Qout("Hello, world")
PROC 0
WRITE Hello, world!
(println "Hello, world!")
start_up = proc ()
    po: stream := stream$primary_output ()
    stream$putl (po, "Hello, world!")
    end start_up
      IDENTIFICATION DIVISION.
      PROGRAM-ID.  HELLO-WORLD.
      PROCEDURE DIVISION.
          DISPLAY "Hello, world!".
          STOP RUN.

以上是一個非常簡略的版本,省略了作者姓名、來源和目標計算機型別。

CoffeeScript

[編輯 | 編輯原始碼]

CoffeeScript 是一種編譯成 JavaScript 的語言。與 JavaScript 一樣,它沒有原生(內建)的輸入或輸出例程,而是依賴於其宿主環境提供的功能。

使用標準 Web 瀏覽器視窗物件(window.alert)的 alert

alert 'Hello, world!'

或者,從 FirebugApple SafariGoogle Chrome 除錯控制檯,或 Node.js 控制檯

console.log 'Hello, world!'

ColdFusion (CFML)

[編輯 | 編輯原始碼]
<cfoutput>Hello, world!</cfoutput>

Hello, world!
 PRINT "Hello, world!"

Common Lisp

[編輯 | 編輯原始碼]
(princ "Hello, world!")
Function | Main  
WriteLine | "Hello, world"
End | Main

“|” 代表 Cube 標準 IDE 中兩個文字欄位的分隔符。

#include <iostream>

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}
int main() {
   System::Console::WriteLine("Hello, world!");
   return 0;
}

C++,託管(.NET)

[編輯 | 編輯原始碼]
#using <mscorlib.dll>

using namespace System;

int wmain()
{
    Console::WriteLine("Hello, world!");
    return 0;
}

另請參見 GUI 部分

using System;

internal static class HelloWorld
{
    private static void Main()
    {
        Console.WriteLine("Hello, world!");
    }
}
 import std.stdio ;
  
 void main () {
     writefln("Hello, world!");
 }

Tango 版本

 import tango.io.Stdout;

 void main() {
     Stdout ("Hello, world!").newline;
 }
main() {
  print('Hello, world!');
}

或者,

void main() {
  print('Hello, world!');
}

DC,任意精度計算器

[編輯 | 編輯原始碼]
[Hello, world!]p

1468369091346906859060166438166794P

在第二個示例中,DC 將十進位制數儲存為一系列位,然後“P”告訴 DC 將這些位解釋為字串並打印出來。

DCL 批處理

[編輯 | 編輯原始碼]
$ write sys$output "Hello, world!"
{$APPTYPE CONSOLE}
begin
  Write('Hello, world!');
end.
PROGRAM hello;
BEGIN
    write(0, 0, 0, 0, "Hello, world!");
    LOOP
        FRAME;
    END
END
this::operator()
{
 import system.cstdio;
 puts("Hello, world!");
}

Dream Maker

[編輯 | 編輯原始碼]
mob
    Login()
        ..()
        world << "Hello, world!"
 module: hello
 
 format-out("Hello, world!\n");

EAScripting

[編輯 | 編輯原始碼]
set disp to "Hello, world!"
set dispto to item unit 5 //5 = default screen
release disp into dispto.

這將是一個純粹的系統呼叫

import system ea.helloworld
wait

Ed 和 Ex(擴充套件的 Ed)

[編輯 | 編輯原始碼]
a
Hello, world!!
.
p

Ecstasy (xtclang)

[編輯 | 編輯原始碼]
module HelloWorld
    {
    void run()
        {
        @Inject Console console;
        console.print("Hello World!");
        }
    }
class HELLO_WORLD
 
create make
feature
    make is
    do
        io.put_string("Hello, world!%N")
    end -- make
end -- class HELLO_WORLD
IO.puts "Hello, world!"
import Html exposing (text)

main =
  text "Hello, World!"

另請參見 GUI 部分

-module(hello).

-export([hello/0]).

hello() -> io:format("Hello, world!~n").
puts(1, "Hello, world!")
 "Hello, world!" print

或 GUI 版本

 "Hello, world!" <label> "Hi" open-window
printl( "Hello world" )
uses "console";

Console.println("Hello, world!");
 @once:
   mesgbox "Hello, world!" ; exit
"halló" < main
{
   main ->
   stef(;)
   stofn
       skrifastreng(;"Halló, veröld!"),
   stofnlok
}
*
"GRUNNUR"
;
type "Hello, world!",!

t "Hello, world!",!
-TYPE 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('Hello, world!');
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;
 : HELLO  ( -- )  ." Hello, world!" CR ;
   HELLO

或者,除了編譯新的例程,也可以在 Forth 直譯器控制檯中直接輸入

 CR ." Hello, world!" CR

Fortran 77

[編輯 | 編輯原始碼]
00    program hello
      write(*,*) 'Hello World!'
      stop
      end

Fortran 90/95

[編輯 | 編輯原始碼]
program hello
    write(*,*) 'Hello, World!'
end program hello
printfn "Hello, world!"
?((pp "Hello, world!"))     

pp "Hello, world!"
println["Hello, world!"]

另請參見 GUI 部分

PUBLIC SUB Main()
  Print "Hello, world!"
END

GEMBase 4GL

[編輯 | 編輯原始碼]
procedure_form hello
  begin_block world
      print "Hello, world!"
  end_block
end_form
Msg("Hello World")


GML(遊戲製作語言)

[編輯 | 編輯原始碼]

在某個物件的繪製事件中

 draw_text(x,y,"Hello, world!")

或者,為了顯示啟動畫面資訊

 show_message("Hello, world!")

Go(來自 Google)

[編輯 | 編輯原始碼]
package main

import "fmt"

func main() {
  fmt.Println("Hello, world!")
}

GraalScript

[編輯 | 編輯原始碼]

GraalScript 1

[編輯 | 編輯原始碼]
 if (created) {
   echo Hello, world!;
 }

GraalScript 2

[編輯 | 編輯原始碼]
 function onCreated() {
   echo("Hello, world!");
 }
println "Hello, world!"
? "Hello, world!"

@1,1 say "Hello, world!"

Qout("Hello, world")
main = putStrLn "Hello, world!"
class HelloWorldApp
{
    static function main()
    {
        trace("Hello, world!");
    }
}
program HelloWorld;
functions {
  _main() {
    print_string("Hello, world!");
  }
}
end

(手持惠普基於RPN的科學計算器)

LBL H
SF 10
EQN
RCL H
RCL E
RCL L
RCL L
RCL O
R/S
RCL W
RCL O
RCL R
RCL L
RDL D
ENTER
R/S

HP-41 & HP-42S

[編輯 | 編輯原始碼]

(手持惠普基於RPN的字母數字工程計算器)

01 LBLTHELLO

02 THello, world!

03 PROMPT

HyperTalk (蘋果HyperCard的指令碼程式語言)

[編輯 | 編輯原始碼]
 put "Hello, world!"

 Answer "Hello, world!"
procedure main()
    write("Hello, world!")
end
 print,"Hello, world!"
"Hello, world!" println

writeln("Hello, world!")

Inform 5/6

[編輯 | 編輯原始碼]
 [ Main;
   "Hello, world!";
 ];
 Hello World is a room.  The printed name is "Hello, world!"
ON ENTER {
    "Hello, " "world!" & SAY
}
'Hello, world!' NB. echoes the string in interactive mode, doesn't work in script
'Hello World!' 1!:2(2) NB. prints it to (2) - screen, (4) - stdout
include 16f877_20
include hd447804
 
hd44780_clear
 
hd44780 = "H"
hd44780 = "e"
hd44780 = "l"
hd44780 = "l"
hd44780 = "o"
hd44780 = " "
hd44780 = "W"
hd44780 = "o"
hd44780 = "r"
hd44780 = "l"
hd44780 = "d"
hd44780 = "!"

另請參見 GUI 部分

class HelloWorld {
     public static void main(String[] args) {
          System.out.println("Hello, world!");
     }
}

Java 位元組碼

[編輯 | 編輯原始碼]

(javap -c HelloWorld 的反彙編輸出)

 public class HelloWorld extends java.lang.Object{
 public HelloWorld();
  Code:
   0:   aload_0
   1:   invokespecial   #1; //Method java/lang/Object."<init>":()V
   4:   return
 public static void main(java.lang.String[]);
  Code:
   0:   getstatic       #2; //Field java/lang/System.out:Ljava/io/PrintStream;
   3:   ldc     #3; //String Hello, world!
   5:   invokevirtual   #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
   8:   return
 }

Java 位元組碼 Jasmin 語法

[編輯 | 編輯原始碼]
.class HelloWorld
.super java/lang/Object
.method public static main([Ljava/lang/String;)V
  .limit stack 2
  getstatic java/lang/System/out Ljava/io/PrintStream;
  ldc "Hello, world!"
  invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
  return
.end method

JavaFX 指令碼

[編輯 | 編輯原始碼]

JavaFX 指令碼是一種指令碼語言,以前稱為 F3,代表“形式追隨功能”。它於 2010 年被 Oracle 停止使用。

 Frame {
    title: "Hello World JavaFX"
    width: 200
    content: Label {
       text: "Hello World"
    }
    visible: true
 }

這個程式也可以這樣編寫

 var win = new Frame();
 win.title = "Hello World JavaFX";
 win.width = 200;
 var label = new Label();
 label.text = "Hello World";
 win.content = label;
 win.visible = true;

一個簡單的控制檯輸出版本是

 import java.lang.System;
 System.out.println("Hello World");

或者更簡單(使用內建函式)

println("Hello World");

JavaScript

[編輯 | 編輯原始碼]

JavaScript 沒有本地(內建)輸入或輸出例程。相反,它依賴於其宿主環境提供的設施。

使用標準 Web 瀏覽器的文件物件

document.write('Hello, World!');

或使用警報,使用標準 Web 瀏覽器的視窗物件(window.alert)

alert('Hello, world!');

或者,從 Mozilla 命令列實現

print('Hello, world!');

或者,從 Windows 指令碼宿主

WScript.Echo('Hello, world!');

或者,從 FirebugApple SafariGoogle Chrome 除錯控制檯

console.log('Hello, world!');

JCL (大型機作業控制語言)

[編輯 | 編輯原始碼]
//HERIB    JOB  ,'HERIBERT OTTEN',PRTY=12
//* HELLO WORLD FOR MVS            
//HALLO    EXEC PGM=IEBGENER       
//SYSIN    DD DUMMY                
//SYSPRINT DD SYSOUT=*             
//SYSUT2   DD SYSOUT=T             
//SYSUT1   DD *                    
HELLO WORLD!                       
/*                                 
//
"Hello, world!\n" putchars .
 <%@ page contentType="text/html;charset=WINDOWS-1252"%>
 <HTML>
    <BODY>
         <% out.println(" Hello, world!"); %>
    </BODY>
 </HTML>

或只是

  <% out.println("Hello, world!"); %>

或者直接

 Hello, world!
 println("Hello, world!")
 `0:"Hello, world!\n"
`plain
'Hello World!' #echo #
fun main() {
   println("Hello World!")
}


WriteLine "Hello, world!"

KPL (兒童程式語言)

[編輯 | 編輯原始碼]
Program HelloWorld
   Method Main()
      ShowConsole()
      ConsoleWriteLine("Hello, world!")
   End Method
End Program
 Output: 'Hello, world!';

 Output('Hello, world!');

或只是

'Hello, world!';

Lexico Mobile(西班牙語)

[編輯 | 編輯原始碼]
tarea muestre "Hola mundo !"

clase Saludo derivada_de Form
publicos
mensajes
Saludo copie "Hola mundo !" en saludo.Text

Linden Scripting Language

[編輯 | 編輯原始碼]

Linden Scripting Language 是 Second Life 中使用的指令碼語言。

default
{
    state_entry()
    {
        llSetText("Hello, World!" , <0,0,0> , 1.0);
        //or...
        llSay(0,"Hello, World!");
    }
}
Livre : HelloWorld
 Paragraphe : Affichage
 Actions :
   "Hello, World !" !
Section Header
  + name := HELLO_WORLD_PROGRAM;

Section Public
  - main <-
  (
    "Hello world!\n".print;
  );

Lisp 在近 50 年的歷史中出現了許多方言。

Common Lisp

[編輯 | 編輯原始碼]
(format t "Hello, world!~%")

(write-line "Hello, world!")

或在 REPL 中

"Hello, world!"

(作為字串(用引號括起來),它評估為它本身,因此被列印。)

(display "Hello, world!\n")
(println "Hello, world!")

Emacs Lisp

[編輯 | 編輯原始碼]
(print "Hello, world!")

(message "Hello, world!")
(print "Hello, world!")
(print "Hello, world!")
(prn "Hello, world!")
(out "Hello, world!")
print [Hello, world!]

pr [Hello, world!]

僅在 MSWLogo 中

messagebox [Hi] [Hello, world!]
  void create()
  {
      write("Hello, world!\n");
  }
io.write("Hello, world!\n")

return "Hello, World!"

print("Hello, world")

LuaDEV(PSP 和 Wii)

[編輯 | 編輯原始碼]
 screen.print(10,10,"Hello, world!")

M(MUMPS)

[編輯 | 編輯原始碼]
W "Hello, world!"

Macsyma,Maxima

[編輯 | 編輯原始碼]
 print("Hello, world!")$
print("Hello, world!");

Mathematica

[編輯 | 編輯原始碼]
 Print["Hello, world!"]

或只是

"Hello, world!"

MATLAB / GNU Octave

[編輯 | 編輯原始碼]
disp('Hello, world!')

fprintf('Hello, world!\n')

或使用 GUI

 figure('Position',[100 100 200 200],'MenuBar','none','Name','Hello World');
 uicontrol('Style','text','Position',[15 100 150 15],'String','Hello world');

msgbox('Hello World!')
fmod HELLOWORLD is
protecting STRING .
  op helloworld : -> String .
  eq helloworld = "Hello, world!" .
endfm
red helloworld .
max v2;
#N vpatcher 10 59 610 459;
#P message 33 93 63 196617 Hello, world!!;
#P newex 33 73 45 196617 loadbang;
#P newex 33 111 31 196617 print;
#P connect 1 0 2 0;
#P connect 2 0 0 0;
#P pop;

Maya Embedded Language

[編輯 | 編輯原始碼]
print( "Hello, world!\n" );
var x:String::allocated[on[0]];
x:="Hello World";  // allocated on process 0 only
proc 1 {
   // This is displayed by process 1, auto communication done to achieve this
   print[x];
}
Hello, world!

mIRC 指令碼

[編輯 | 編輯原始碼]
helloworld echo Hello, world!
alias helloworld echo Hello, world!

彈出視窗

[編輯 | 編輯原始碼]
Hello World:echo Hello, world!

命令列

[編輯 | 編輯原始碼]
echo Hello, world!

模型 204

[編輯 | 編輯原始碼]
BEGIN
PRINT 'Hello, world!'
END
MODULE Hello;

FROM InOut IMPORT WriteLn, WriteString;

BEGIN
   WriteString ("Hello, world!");
   WriteLn
END Hello.
 Strict
 
 Function Main:Int()
  Print "Hello World!"
  
  Return 0
 End

這要求您是玩家或巫師

 notify(player, "Hello, world!");

這特定於用於 moo 的核心實現,但在大多數知名的 moo 中都有效,例如 LambdaCore 或 JH-Core

 player:tell("Hello, world!");
"Hello, World!"
$
#include <stdio.h>
#include <time.h>
#include <string.h>
#include "mpi.h"

int main ( int argc, char * argv[] )
{
    const int   maximum_message_length = 100;
    const int   master_rank            =   0;
    char        message[maximum_message_length+1];
    MPI_Status  status;      /* Info about receive status  */
    int         my_rank;     /* This process ID            */
    int         num_procs;   /* Number of processes in run */
    int         source;      /* Process ID to receive from */
    int         destination; /* Process ID to send to      */
    int         tag = 0;     /* Message ID                 */
    int         mpi_error;   /* Error code for MPI calls   */
    int         icount;
    char        processor_name[MPI_MAX_PROCESSOR_NAME];
    int         name_length;

    // Initialize the MPI execution environment.

    mpi_error = MPI_Init ( &argc, &argv );
    if ( mpi_error != MPI_SUCCESS )
    {
        fprintf ( stderr, "Error: %s: Unable to initialize MPI execution environment\nAborting ...\n", argv[0] );
        return ( 1 );
    }

    // Even though we capture the error value from the MPI calls, we will
    // not deal with any error except the last one.

    mpi_error = MPI_Comm_rank ( MPI_COMM_WORLD, &my_rank );
    mpi_error = MPI_Comm_size ( MPI_COMM_WORLD, &num_procs );
    if ( my_rank != master_rank )
    {
        mpi_error = MPI_Get_processor_name (processor_name, &name_length );
        sprintf ( message, "Greetings from process #%d running on %s\n", \
                  my_rank, processor_name );
        destination = master_rank;
        mpi_error = MPI_Send ( message, strlen(message) + 1, MPI_CHAR,  \
                        destination, tag, MPI_COMM_WORLD );
    }
    else
    {
        for ( source = 0; source < num_procs; source++ )
        {
            if ( source != master_rank )
            {
                mpi_error = MPI_Recv ( message, maximum_message_length + 1, \
                        MPI_CHAR, source, tag, MPI_COMM_WORLD, &status );
                printf ( "%s  \n", message );
            }
        }
    }

    mpi_error = MPI_Finalize();
    if ( MPI_SUCCESS != mpi_error )
        return ( mpi_error );
    else
        return ( 0 );
}

M# 虛構計算機語言

[編輯 | 編輯原始碼]

指令碼

[編輯 | 編輯原始碼]
main(std:string >>arg<< / OS.GetArg)
{
     std:stream >>CONSOLE<< / OS.Console;

     CONSOLE:Write([byte]{0048, 0065, 006C, 006C, 006F, 002C, 0058, 006F, 0072, 006C, 0064});
     //                    H     e     l     l     o     ,     W     o     r     l     d   //
}

命令 WI

[編輯 | 編輯原始碼]
# # DEFINE g >>CONSOLE<< / OS.Console
# % proc CONSOLE:Write([byte]{0048, 0065, 006C, 006C, 006F, 002C, 0058, 006F, 0072, 006C, 0064})

命令 WoI

[編輯 | 編輯原始碼]
# @ Write([byte]{0048, 0065, 006C, 006C, 006F, 002C, 0058, 006F, 0072, 006C, 0064})

MS-DOS 批處理

[編輯 | 編輯原始碼]

(使用標準的 command.com 直譯器。@ 符號是可選的,可阻止系統在執行命令之前重複該命令。在 MS-DOS 3.0 之前的版本中,必須省略 @ 符號)。批處理檔案通常以兩行“@echo off”和“cls”開頭。

@echo Hello, world!

適用於 MS-DOS 3.0 或更低版本

@echo off
cls
echo Hello, world!
: main
  me @ "Hello, world!" notify
;
WRITE 'Hello, world!'
END

WRITE 'Hello, world!'.
$print("Hello, world!!\n");

獲取 Nemerle 列印“Hello, world!” 的最簡單方法是

 System.Console.WriteLine("Hello, world!");

但是,在更大的應用程式中,以下程式碼可能更有用

 using System.Console;
 
 module HelloWorld
 {
    Main():void
    {
       WriteLine("Hello, world!");
    }
 }
echo "Hello, world!"

echo("Hello, world!")

NXT 2.1(樂高機器人程式)

[編輯 | 編輯原始碼]

Oberon 既是程式語言的名稱,也是作業系統的名稱。

為 Oberon 作業系統編寫的程式

MODULE Hello;
        IMPORT Oberon, Texts;
 VAR W: Texts.Writer;

 PROCEDURE World*;
 BEGIN
   Texts.WriteString(W, "Hello, world!");
   Texts.WriteLn(W);
   Texts.Append(Oberon.Log, W.buf)
 END World;

BEGIN
 Texts.OpenWriter(W)
END Hello.

使用標準 Oakwood 庫的獨立 Oberon 程式

MODULE Hello;
   IMPORT Out;
BEGIN
   Out.String("Hello, world!");
   Out.Ln
END Hello.
system.console.write_line ( "Hello, world!" )

ObjectGears

[編輯 | 編輯原始碼]

以以下形式傳送給使用者的訊息

OGForm.SetInfo('Hello world!');

日誌條目

OG.Log.Write('Hello world!');

Objective C

[編輯 | 編輯原始碼]

過程式 C 版本

[編輯 | 編輯原始碼]
#import <stdio.h>

int main (int argc, const char *argv[])
{
    printf ("Hello, world!\n");
    return 0;
}

面向物件 C 版本

[編輯 | 編輯原始碼]
#import <stdio.h>
#import <objc/Object.h> 

@interface Hello : Object
{
}
- hello;
@end 

@implementation Hello
- hello
{
   printf("Hello, world!\n");
}
@end 

int main(void)
{
   id obj;
   obj = [Hello new];
   [obj hello];
   [obj free];
   return 0;
}

OPENSTEP/Cocoa 版本

[編輯 | 編輯原始碼]
#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
   NSLog(@"Hello, world!");
   return 0;
}
print_endline "Hello, world!" ;;
#USE "course.lib"

PROC hello.world(CHAN OF BYTE screen!)
  out.string("Hello, world!*n", 0, screen!)
:

或者不使用 course.lib

PROC hello.world(CHAN OF BYTE screen!)
  SEQ
    screen ! 'H'
    screen ! 'e'
    screen ! 'l'
    screen ! 'l'
    screen ! 'o'
    screen ! ','
    screen ! ' '
    screen ! 'w'
    screen ! 'o'
    screen ! 'r'
    screen ! 'l'
    screen ! 'd'
    screen ! '!'
    screen ! '*n'
:

OpenScript

[編輯 | 編輯原始碼]
-- in a popup window
request "Hello world"

另請參閱 GUI 部分.

PROC hello:
  PRINT "Hello, world!"
ENDP
 (object-class request
          ^action)
 
 (startup
    (strategy MEA)
    (make request ^action hello)
 )
 
 (rule hello
    (request ^action hello)
    (write |Hello, world!| (crlf))
 )
module hello (main)
{  procedure main( )
   {
      write() |Hello, world!|, '\n';
   };
};
{Browse 'Hello, world!'}

Parrot 組合語言

[編輯 | 編輯原始碼]
 print "Hello, world!\n"
 end

Parrot 中間表示

[編輯 | 編輯原始碼]
 .sub hello :main
   print "Hello, world!!\n"
 .end
begin
   write('Hello, world!');
end.
main() {
    print("Hello, World!");
}

main() {
    new string[14];
    format string(sizeof(string), "Hello, World!);
    print(string);
}

作為 PL 檔案

[編輯 | 編輯原始碼]
 print "Hello, world!\n";

(分號是可選的)

 package Hello;
 sub new() { bless {} }
 sub Hello() { print "Hello, world! \n" }
 package main;
 my $hello = Hello->new();
 $hello->Hello();

作為 CGI 檔案

[編輯 | 編輯原始碼]
#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
print "<H1>Hello World!</H1>";
puts(1, "Hello, world!")

PHP 是一種模板語言,它會直接回顯不在 PHP 標記內的任何文字,因此最簡單的形式是

Hello, world!

使用實際的 PHP 語句,它可以寫成

<?php
    echo 'Hello, world!';
?>

或使用簡寫回顯,語法如下

<? echo "Hello, world!"?>

這也將起作用

<?= "Hello, world!" ?>
 int main() {
     write("Hello, world!\n");
     return 0;
 }
T:Hello, world!
set serveroutput on size 1000000;  -- this is a SQL*Plus command to enable the output buffer
begin
    dbms_output.put_line('Hello, world!'); 
end;
Test: proc options(main);
  put list('Hello, world!');
end Test;

PostScript

[編輯 | 編輯原始碼]

另見 頁面描述語言部分.

 (Hello, world!\n) print

PowerShell

[編輯 | 編輯原始碼]
"Hello, world!"

Write-Host "Hello, world!"

echo "Hello, world!"

[System.Console]::WriteLine("Hello, world!")

[void][System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
[System.Windows.Forms.MessageBox]::Show("Hello, World!")

Processing

[編輯 | 編輯原始碼]
println("Hello, world!");

Progress 4GL

[編輯 | 編輯原始碼]
 display "Hello, world!".
:- write('Hello, world!'),nl.

Pure Data

[編輯 | 編輯原始碼]
#N canvas 0 0 300 300 10;
#X obj 100 100 loadbang;
#X msg 100 150 Hello, world!;
#X obj 100 200 print;
#X connect 0 0 1 0;
#X connect 1 0 2 0;

作為指令碼/模組

[編輯 | 編輯原始碼]

Python 2 及更早版本

[編輯 | 編輯原始碼]
print "Hello, world!"
print("Hello, world!")

這在 Python 2.4 或更高版本上也能工作,但以一種不直觀的方式。在 Python 3 中,它呼叫了 print 函式,並傳入字串 "Hello, world!"。在 Python 2 中,它執行了 print 語句,其中包含表示式 ("Hello, world!"),該表示式計算結果為字串 "Hello, world!"

任何 Python 版本

[編輯 | 編輯原始碼]
import sys
sys.stdout.write("Hello, world!\n")

在 Python 2.6 或更高版本中

from __future__ import print_function
print("Hello, world!")

兩個彩蛋

[編輯 | 編輯原始碼]
import __hello__
import __phello__

使用 Curves

[編輯 | 編輯原始碼]
from math import cos, sin
 
def f(x):
    return int(round(96.75 + -21.98*cos(x*1.118) + 13.29*sin(x*1.118) + -8.387*cos(2*x*1.118)\
               + 17.94*sin(2*x*1.118) + 1.265*cos(3*x*1.118) + 16.58*sin(3*x*1.118)\
               + 3.988*cos(4*x*1.118) + 8.463*sin(4*x*1.118) + 0.3583*cos(5*x*1.118)\
               + 5.878*sin(5*x*1.118)))
 
print("".join([chr(f(x)) for x in range(12)]))

在 REPL 中

[編輯 | 編輯原始碼]

可以透過以下方式獲得“Hello, world!”(帶引號):

'Hello, world!'

作為 CGI 檔案

[編輯 | 編輯原始碼]
#!/usr/local/bin/python
print("Content-type: text/html\n\n")
print("Hello World!")

作為 Python 的 Flask 微型 Web 框架

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

app.run()
print('Hello, world!')
"Hello, world!".say

say "Hello, world!";

print "Hello, world!\n";

另請參見 GUI 部分

print "Hello, world!"

另請參見GUI 部分

print "Hello, world!"
 ; Should work with any MARS >= ICWS-86
 ; with 128x64 gfx core
 Start MOV 0,2455
       MOV 0,2458
       MOV 0,2459
       MOV 0,2459
       MOV 0,2459
       MOV 0,2459
       MOV 0,2459
       MOV 0,2460
       MOV 0,2465
       MOV 0,2471
       MOV 0,2471
       MOV 0,2471
       MOV 0,2479
       MOV 0,2482
       MOV 0,2484
       MOV 0,2484
       MOV 0,2484
       MOV 0,2486
       MOV 0,2486
       MOV 0,2486
       MOV 0,2486
       MOV 0,2488
       MOV 0,2493
       MOV 0,2493
       MOV 0,2493
       MOV 0,2493
       MOV 0,2497
       MOV 0,2556
       MOV 0,2559
       MOV 0,2560
       MOV 0,2565
       MOV 0,2570
       MOV 0,2575
       MOV 0,2578
       MOV 0,2585
       MOV 0,2588
       MOV 0,2589
       MOV 0,2592
       MOV 0,2593
       MOV 0,2596
       MOV 0,2597
       MOV 0,2603
       MOV 0,2605
       MOV 0,2608
       MOV 0,2667
       MOV 0,2670
       MOV 0,2671
       MOV 0,2676
       MOV 0,2681
       MOV 0,2686
       MOV 0,2689
       MOV 0,2696
       MOV 0,2699
       MOV 0,2700
       MOV 0,2703
       MOV 0,2704
       MOV 0,2707
       MOV 0,2708
       MOV 0,2714
       MOV 0,2716
       MOV 0,2719
       MOV 0,2778
       MOV 0,2778
       MOV 0,2778
       MOV 0,2778
       MOV 0,2778
       MOV 0,2779
       MOV 0,2779
       MOV 0,2779
       MOV 0,2782
       MOV 0,2787
       MOV 0,2792
       MOV 0,2795
       MOV 0,2802
       MOV 0,2805
       MOV 0,2806
       MOV 0,2809
       MOV 0,2810
       MOV 0,2810
       MOV 0,2810
       MOV 0,2810
       MOV 0,2812
       MOV 0,2818
       MOV 0,2820
       MOV 0,2823
       MOV 0,2882
       MOV 0,2885
       MOV 0,2886
       MOV 0,2891
       MOV 0,2896
       MOV 0,2901
       MOV 0,2904
       MOV 0,2911
       MOV 0,2912
       MOV 0,2913
       MOV 0,2914
       MOV 0,2917
       MOV 0,2918
       MOV 0,2919
       MOV 0,2922
       MOV 0,2928
       MOV 0,2930
       MOV 0,2933
       MOV 0,2992
       MOV 0,2995
       MOV 0,2996
       MOV 0,3001
       MOV 0,3006
       MOV 0,3011
       MOV 0,3014
       MOV 0,3021
       MOV 0,3022
       MOV 0,3023
       MOV 0,3024
       MOV 0,3027
       MOV 0,3028
       MOV 0,3030
       MOV 0,3032
       MOV 0,3038
       MOV 0,3040
       MOV 0,3103
       MOV 0,3106
       MOV 0,3107
       MOV 0,3107
       MOV 0,3107
       MOV 0,3107
       MOV 0,3107
       MOV 0,3108
       MOV 0,3108
       MOV 0,3108
       MOV 0,3108
       MOV 0,3108
       MOV 0,3109
       MOV 0,3109
       MOV 0,3109
       MOV 0,3109
       MOV 0,3109
       MOV 0,3111
       MOV 0,3111
       MOV 0,3111
       MOV 0,3120
       MOV 0,3121
       MOV 0,3124
       MOV 0,3124
       MOV 0,3124
       MOV 0,3126
       MOV 0,3129
       MOV 0,3130
       MOV 0,3130
       MOV 0,3130
       MOV 0,3130
       MOV 0,3130
       MOV 0,3131
       MOV 0,3131
       MOV 0,3131
       MOV 0,3131
       MOV 0,3135
       JMP 0
$ENTRY GO{=<Prout 'Hello, world!'>;}

Revolution

[編輯 | 編輯原始碼]

(這對 Transcript 或 xTalk 也是一樣的)

列印在訊息框中

[編輯 | 編輯原始碼]
put "Hello, World!" 

顯示在對話方塊中

[編輯 | 編輯原始碼]
answer "Hello, world!" 

列印在主視窗介面上

[編輯 | 編輯原始碼]
create field "myField"
set the text of field "myField" to "Hello, world!"

作為 CGI 檔案

[編輯 | 編輯原始碼]
#!revolution 

on startup 
  put "Content-Type: text/plain" & cr & cr 
  put "Hello World!" 
end startup 

REXX、ARexx、NetRexx 和 Object REXX

[編輯 | 編輯原始碼]
 /* a starting comment is needed in mainframe versions */
 say "Hello, world!"
 see "hello world!"

自由格式語法

[編輯 | 編輯原始碼]
/FREE

    DSPLY 'Hello, world!';

    *InLR = *On;

/END-FREE 

傳統語法

[編輯 | 編輯原始碼]

使用此語法,必須使用常量,因為訊息必須放在引號之間,位於位置 12 到 25 之間。

     d TestMessage     c                   Const( 'Hello, world!' )

     c     TestMessage   DSPLY

     c                   EVAL      *InLR = *On

RPG 程式碼

[編輯 | 編輯原始碼]

訊息視窗

[編輯 | 編輯原始碼]

使用內部訊息視窗,一個簡單的 Hello, world! 程式可以這樣呈現

mwin("Hello, world!")
wait()

螢幕文字

[編輯 | 編輯原始碼]

渲染文字的另一種方法是使用內建的 text() 函式。

text(1,1,"Hello, world!")
wait()

另請參閱 GUI 部分.

(在惠普 HP-28、HP-48 和 HP-49 系列圖形計算器上。)

<<
  CLLCD
  "Hello, world!" 1 DISP
  0 WAIT
  DROP
>>

RT 彙編程式

[編輯 | 編輯原始碼]
_name   Hello~World!
pause   Hello~World!
exit
_end

另請參閱 GUI 部分.

puts 'Hello, world!'

'Hello, world!'.each { |s| print s }

class String
    def say
        puts self
    end
end
'Hello, world!'.say
fn main() {
    println!("Hello, world!");
}

S(和 R)

[編輯 | 編輯原始碼]
print("Hello, world")

message("Hello, world")
message("Hello, world!");
%put Hello, world!;
class HELLO_WORLD is
  main is 
   #OUT+"Hello, world!\n"; 
  end; 
end;
object HelloWorld extends App {
  println("Hello, world!")
}

App 自 Scala 2.1 起引入,Application 自 Scala 2.9.0 起被棄用。對於 2.1 以下的版本,請使用 Application 代替 App

 program HelloWorld;
 begin
  WriteLn('Hello world!');
 end.
(display "Hello, World!") (newline)

(注意:至少需要一行輸入)

sed -ne '1s/.*/Hello, world!/p'
$ include "seed7_05.s7i";

const proc: main is func
  begin
    writeln("Hello, world");
  end func;
'Hello, world!' print.

sense script

[編輯 | 編輯原始碼]
out('Hello, world!');

ShadowScript

[編輯 | 編輯原始碼]
'set up initial variables
struct.follow
 {
  cpu.fan.speed(500.rpm)
  cpu.max.process(100)
 }
<
 logic.handle(0)
 int main()
 int var()
 array.max(100000000)
>
'open and write the text in a free handle window
open mainwin(io<std>) as free(1)
 {
  write.free(1).("Hello",&sym," world",&sym)(&sym<",">&sym<"!">
  apply.free(1) to text
 }
'reset the fan, cpu, and vars
<
 logic(std)
 fan(std.auto)
 cpu.max(auto)
 unint main()
 unint var()
 un.array.max(std)
>
'end
end
.end/
BEGIN
    OutText("Hello, world!");
    OutImage;
END

Smalltalk

[編輯 | 編輯原始碼]
Transcript show: 'Hello, world!'

替代方案

StdoutStream nextPutLine: 'Hello, world'
print "Hello, world!\n";
     OUTPUT = "Hello, world!"
 END
class Hello {
  static public main: args {
    Console << "Hello, world!\n";
  }
}
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;

Spin 是 Parallax Inc. 用於為其 Propeller 多核微控制器程式設計的 高階語言。

該程式假設使用 Propeller IDE 提供的軟體 UART 物件透過序列線傳遞訊息。

CON
    _clkmode = xtal1 + pll16x
    _xinfreq = 5_000_000
OBJ
    console : "FullDuplexSerial"
PUB start
    console.start(31, 30, 0, 115_200)
    console.str(string("Hello, world!", 13))
     OUTPUT = "Hello, world!"
 END

SPSS 語法

[編輯 | 編輯原始碼]
ECHO "Hello, world!".
1.0
print Hello, World!
end

Standard ML

[編輯 | 編輯原始碼]
print "Hello, world!\n";
 CREATE TABLE message (text char(15));
 INSERT INTO message (text) VALUES ('Hello, world!');
 SELECT text FROM message;
 DROP TABLE message;

或 (對於 EnterpriseDB 的儲存過程語言 (SPL))

 BEGIN
     DBMS_OUTPUT.PUT_LINE('Hello, world!');
 END;

或 (例如 Oracle 方言)

SELECT 'Hello, world!' FROM dual;

或 (對於 Oracle 的 PL/SQL 專有過程語言)

 BEGIN
   DBMS_OUTPUT.ENABLE(1000000);
   DBMS_OUTPUT.PUT_LINE('Hello, world!');
 END;

或 (例如 MySQL 或 PostgreSQL 方言)

SELECT 'Hello, world!';

或 (對於 PostgreSQL 的 PL/pgSQL 過程語言)

 CREATE FUNCTION hello_world() RETURNS text AS $$
   BEGIN
      RETURN 'Hello, world!';
   END
 $$ LANGUAGE plpgsql;

或 (例如 T-SQL 方言)

PRINT 'Hello, world!'

或 (對於 KB-SQL 方言)

 select Null from DATA_DICTIONARY.SQL_QUERY

 FOOTER ''or HEADER or DETAIL or FINAL event''
 write "Hello, world!"
RACINE: HELLO_WORLD.

NOTIONS:
HELLO_WORLD : ecrire("Hello, world!").

在指令碼 (.do 檔案) 或命令列中定義程式

 capture program drop hello /*Define Hello, world! program*/
 program define hello   
      di "Hello, world!"
 end
 
 hello  /*run Hello, world! program*/

或者,在命令列中互動式操作

di "Hello, world!"

SuperCollider

[編輯 | 編輯原始碼]
 "Hello, world!".postln;

或者,對於互動式提示,

"Hello, world!"

Supernova

[編輯 | 編輯原始碼]
I want window and the window title is hello world.
 println("Hello, world!") // Swift 1.x

 print("Hello, world!")   // Swift 2.x
#OUTPUT Hello, world!

Tcl (工具命令語言)

[編輯 | 編輯原始碼]

另請參閱 GUI 部分.

puts "Hello, world!"

模板工具包

[編輯 | 編輯原始碼]
[% GET "Hola mundo!"; %]

或英文版本

[% GET "Hello world!"; %]
 print ("Hello, world!")

TOM (重寫語言)

[編輯 | 編輯原始碼]
 public class HelloWorld {
  %include { string.tom }
  public final static void main(String[] args) {
    String who = "world";
    %match(String who) {
      "World" -> { System.out.println("Hello, " + who + "!"); }
      _       -> { System.out.println("Don't panic"); }
    }
  }
Declare @Output varchar(16)
Set @Output='Hello, world!'
Select 'Output' = @Output

或者,更簡單的變體

Select 'Hello, world!'
Print 'Hello, world!'
module hello_world {
  control {
    log("Hello, world!");
  }
}
put "Hello world!"

類 Unix shell

[編輯 | 編輯原始碼]
 echo 'Hello, world!'

或者使用內聯“here document”

 cat <<'DELIM'
 Hello, world!
 DELIM

 printf '%s' $'Hello, world!\n'

或者對於 curses 介面

 dialog --msgbox 'Hello, world!' 0 0
using GLib;

public int main(string[] args)
{
       stdout.printf("Hello, world!\n");
       return 0;
}
module main();
       initial begin
              #0 $display("Hello, world!!");
              #1 $finish;
       end
endmodule

或者(稍微複雜一些)

module hello(clk);
       input clk;
       always @(posedge clk) $display("Hello, world!!");
endmodule
module main();
       reg     clk;
       hello H1(clk);
       initial begin
              #0 clk=0;
              #5 clk=1;
              #1 $finish;
       end
endmodule
module hello(clk);
       input clk;
       always @(posedge clk) $display("Hello, world!!");
endmodule
module main();
       reg     clk;
       hello H1(clk);
       initial begin
              #0 clk=0;
              #23 $display("--23--");
              #100 $finish;
       end
       always #5 clk=~clk;
endmodule
use std.textio.all;

entity Hello is
end Hello;

architecture Hello_Arch of Hello is
begin
       p : process
       variable l:line;
       begin
               write(l, String'("Hello, world!"));
               writeline(output, l);
               wait;
       end process;
end Hello_Arch;

Visual Basic Script

[編輯 | 編輯原始碼]
WScript.Echo "Hello, world!"

或者作為一個 VBscript 檔案

MsgBox "Hello, world!"

Visual Prolog

[編輯 | 編輯原始碼]
#include @"pfc\console\console.ph"

goal
  console::init(),
  stdio::write("Hello, world!").

VRML (虛擬現實建模語言)

[編輯 | 編輯原始碼]
#X3D V3.3 utf8
Shape {
  geometry Text {
    string [ "hello, world" ]
  }
}

WebAssembly

[編輯 | 編輯原始碼]
 (module
   (type $type0 (func (result i32)))
   (table 0 anyfunc)
   (memory 1)
   (export "memory" memory)
   (export "hello" $func0)
   (func $func0 (result i32)
     i32.const 16
   )
   (data (i32.const 16)
     "Hello World\00"
   )
 )
sub:main
load:mscorlib.dll
push:Hello, World!
invoke:mscorlib.dll:System.Console:Write:1
endsub

X3D (可擴充套件 3D)

[編輯 | 編輯原始碼]
<X3D profile='Immersive' version='3.3'>
  <Scene>
    <Shape>
      <Text string='"hello, world"'/>
    </Shape>
  </Scene>
</X3D>

XC 是一種來自 XMOS Ltd 的類 C 語言,提供支援其多執行緒、多核處理器上的通訊順序程序的功能。此示例展示了其中的一些功能。

#include <platform.h>
#define BIT_RATE 115200
#define BIT_TIME XS1_TIMER_HZ / BIT_RATE

// A one bit output port with buffering
out port:1 buffered uart_tx = PORT_UART_TX;

// Thread implements serial transmitter using the ports timer.
void console (chanend c, out port:1 buffered TXD)
{
	unsigned time;
	char byte;

	while (1)
	{
		c :> byte;					// Read byte from the consol output channel.
		TXD <: 0 @ time;				// Set start bit and save IO time stamp.
		for (int j = 0; j < 8; j += 1)		// Data bits.
		{
			time += BIT_TIME;		// Time of next bit.
			TXD @ time <: >> byte;	// Shift out next bit on time.
		}
		time += BIT_TIME;			// Two stop bits
		TXD @ time <: 1;
		time += BIT_TIME;
		TXD @ time <: 1;
	}
}

// Thread issues greeting message to the console
void greeter(chanend c)
{
	char msg[] = "Hello World!\n";
	int i;
	while (1)					// Repeatedly send message to console output channel.
	{
		for (i = 0; i < sizeof(msg) - 1; i++)
		{
			c <: msg[i];                    // Output a byte to the channel.
		}
	}
}

int main()
{
	chan c;						// Communication channel between threads.
	par						// Parallel execution of block statements.
	{
		on stdcore[0]: console(c, uart_tx);	// Run console output thread on core 0.
		on stdcore[1]: greeter(c);		// Run greeter thread or core 1.
	}
	return 0;
}
   use XL.UI.CONSOLE
   WriteLn "Hello, world!"

   import IO = XL.UI.CONSOLE
   IO.WriteLn "Hello, world!"

XMLmosaic

[編輯 | 編輯原始碼]
<Class>
  <Type>XMLmosaic Class</Type>
  <Method>
    <Name id="1">Main</Name>
    <Code id="1">void Main()
{
Console.WriteLine('Hello World!');
}
    </Code>
  </Method>
  <Counter>
    <Count>1</Count>
  </Counter>
</Class>
write, "Hello, world!";

注意:分號是可選的。

使用波蘭語命令的程式語言。 網頁

pisz Hello World!
koniec

圖形使用者介面 (GUI)

[編輯 | 編輯原始碼]

ActionScript (Adobe Flash)

[編輯 | 編輯原始碼]
this.createTextField("hello_txt",0,10,10,100,20);
this.hello_txt.text="Hello, world!";

AppleScript

[編輯 | 編輯原始碼]
display dialog "Hello, world!" buttons {"OK"} default button 1
import System.Drawing
import System.Windows.Forms
f = Form()
f.Controls.Add(Label(Text: "Hello, world!", Location: Point(40,30)))
f.Controls.Add(Button(Text: "Ok", Location: Point(50, 55), Click: {Application.Exit()}))
Application.Run(f)

下面 C# 程式的功能等效項。

簡單地,使用訊息框

 public class HelloWorld
 {
     static void Main()
     {
         System.Windows.Forms.MessageBox.Show("Hello, world!");
     }
 }

或者

using System;
using System.Drawing;
using System.Windows.Forms;
 
 public class HelloWorldForm : Form 
 {
     public static void Main() 
     {
         Application.Run(new HelloWorldForm());
     }
 
     public HelloWorldForm() 
     {
        Label label = new Label();
        label.Text = "Hello, world!";
        label.Location = new Point(40,30);
        this.Controls.Add(label);
        Button button = new Button();
        button.Text = "OK";
        button.Location = new Point(50,55);
        this.Controls.Add(button);
        button.Click += new EventHandler(button_Click);
     }
 
     private void button_Click(Object sender, EventArgs e) 
     {
        Application.Exit();
     }
 }

實現此目的最簡單的方法是使用內建的訊息函式,該函式類似於 windows messageBox()。

   PROGRAM
   MAP
   END
   CODE
   MESSAGE('Hello, world!!','Clarion')
   RETURN

一個更真實的示例使用 Clarion 結構來宣告一個視窗,並使用 Clarion Accept 迴圈來處理該視窗的事件。

  PROGRAM
    MAP
HelloProcedure  PROCEDURE()
    END

    CODE
    HelloProcedure()
    RETURN

HelloProcedure  PROCEDURE()
Window WINDOW('Clarion for Windows'),AT(,,222,116),FONT('Tahoma',8,,FONT:regular),ICON('Hey.ICO'), |
         SYSTEM,GRAY
       STRING('Hello, world!!'),AT(91,22),USE(?String1)
       BUTTON('Close'),AT(92,78,37,14),USE(?CloseBtn),LEFT
     END
    CODE
    OPEN(Window)
    ACCEPT
      CASE ACCEPTED()
      OF ?CloseBtn
        POST(EVENT:CloseWindow)
      END
    END
    CLOSE(Window)
    RETURN

Cocoa 或 GNUStep (在 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
{curl 3.0, 4.0 applet}
{curl-file-attributes character-encoding = "utf-8"}

Hello, world!

Delphi, Kylix

[編輯 | 編輯原始碼]
program Hello_World;
uses    
  QDialogs;

begin
  ShowMessage('Hello, world!');
end.

program Hello_World;
uses    
  QDialogs;

begin
  MessageDlg ('Hello, world!', mtInformation, [mbOk], 0);
end.
-module(hello_world).
-export([hello/0]).

hello() ->
   S = gs:start(),
   Win = gs:create(window, S, [{width, 100}, {height, 50}]),
   gs:create(label, Win, [{label, {text, "Hello, world!"}}]),
   gs:config(Win, {map, true}),
   receive
      {gs, Win, destroy, _, _} ->
         gs:stop()
   end,
   ok.

一種呼叫方式是在 Erlang shell 中輸入hello_world:hello().另一種是透過命令列執行

erl -noshell -run hello_world hello -run init stop

僅限 MS-Windows - 基本。

include msgbox.e
if message_box("Hello, world!", "Hello", 0) then end if

僅限 MS-Windows - 使用 Win32Lib 庫

include win32lib.ew
createForm({
       ";Window; Hello",
       ";Label;  Hello, world!"
   })
include w32start.ew

在 F# 互動式提示符下使用 WindowsForms

let _ = System.Windows.Forms.MessageBox.Show("Hello, world!");;

FLTK2 (在 C++ 中)

[編輯 | 編輯原始碼]
#include <fltk/Window.h>
#include <fltk/Widget.h>
#include <fltk/run.h>
using namespace fltk;

int main(int argc, char **argv)
{
    Window *window = new Window(300, 180);
    window->begin();
        Widget *box = new Widget(20, 40, 260, 100, "Hello, world!");
        box->box(UP_BOX);
        box->labelfont(HELVETICA_BOLD_ITALIC);
        box->labelsize(36);
        box->labeltype(SHADOW_LABEL);
     window->end();
     window->show(argc, argv);

    return run();
 }

G (LabVIEW)

[編輯 | 編輯原始碼]
PUBLIC SUB Main()
  Message.Info("Hello, world!")
END

Gtk# (在 C# 中)

[編輯 | 編輯原始碼]
using Gtk;
using GtkSharp;
using System;

class Hello {

    static void Main()
    {
        Application.Init ();

        Window window = new Window("");
        window.DeleteEvent += cls_evn;
        Button close  = new Button ("Hello, world!");
        close.Clicked += new EventHandler(cls_evn);

        window.Add(close);
        window.ShowAll();

        Application.Run ();

    }

    static void cls_evn(object obj, EventArgs args)
    {
        Application.Quit();
    }

}

GTK+ 2.x (在 Euphoria 中)

[編輯 | 編輯原始碼]
include gtk2/wrapper.e

Info(NULL,"Hello","Hello, world!")

IOC/OCL (在 IBM VisualAge for C++ 中)

[編輯 | 編輯原始碼]
#include <iframe.hpp>
void main()
{
    IFrameWindow frame("Hello, world!");
    frame.showModally()
}
import javax.swing.*;

class HelloWorld {

    public static void main(final String[] args) {
        JFrame frame = new JFrame();
        frame.add(new JLabel("Hello World", SwingConstants.CENTER));
        frame.setSize(200, 100);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
	
}

JavaFX 和 FXML 檔案

[編輯 | 編輯原始碼]
package example;

public class FXMLDocumentController extends Application implements Initializable  {
    
    @Override
    public void start(Stage stage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.show();
    }

    @FXML
    private Label label;
    
    @Override
    public void initialize(URL url, ResourceBundle rb) {
         label.setText("Hello World!");
    }
    
    public static void main(String[] args) {
        launch(args);
    }
    
}
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" xmlns:fx="http://javafx.com/fxml/1" fx:controller="example.FXMLDocumentController">
    <children>
        <Label layoutX="126" layoutY="80" minHeight="16" minWidth="69" fx:id="label" />
    </children>
</AnchorPane>

GTK (java-gnome)

[編輯 | 編輯原始碼]
import org.gnome.gdk.*;

class GdkSimple extends Window {

    public GdkSimple() {
        setTitle("Example");
        connect((DeleteEvent)(source, event) -> {
            Gtk.mainQuit();
            return false;
        });
        add(new Label("Hello World"));
        setDefaultSize(250, 150);
        setPosition(WindowPosition.CENTER);
        show();
    }

    public static void main(String[] args) {
        Gtk.init(args);
        new GdkSimple(); 
        Gtk.main(); 
    } 
}

這將建立一個標題為“Hello, world!”的視窗,並帶有一個標題為“Hello, world!”的按鈕。

hello:hello..l:"Hello, world!"
hello..c:`button
`show$`hello

Microsoft Foundation Classes (在 C++ 中)

[編輯 | 編輯原始碼]
#include <afx.h>
#include <afxwin.h>

class CHelloWin : public CWnd
{
protected:
 DECLARE_MESSAGE_MAP()
 afx_msg void OnPaint(void)
 {
 CPaintDC dc(this);
 dc.TextOut(15, 3, TEXT("Hello, world!"), 13);
 }
};

BEGIN_MESSAGE_MAP(CHelloWin, CWnd)
 ON_WM_PAINT()
END_MESSAGE_MAP()

class CHelloApp : public CWinApp
{
 virtual BOOL InitInstance();
};
  
CHelloApp theApp;
LPCTSTR wndClass;
 
BOOL CHelloApp::InitInstance()
{
 CWinApp::InitInstance();
 CHelloWin* hello = new CHelloWin();
 m_pMainWnd = hello;
 wndClass = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW, 0, (HBRUSH)::GetStockObject(WHITE_BRUSH), 0);
 hello->CreateEx(0, wndClass, TEXT("Hello MFC"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 120, 50, NULL, NULL);
 hello->ShowWindow(SW_SHOW);
 hello->UpdateWindow();
 return TRUE;
}

Adobe Flex MXML

[編輯 | 編輯原始碼]
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Label text="Hello, world!"/>
</mx:Application>

這將建立一個顯示“Hello, world!”的對話方塊。

OutFile "HelloWorld.exe"
Name "Hello, world!"
Caption "Hello, world!"

Section Hello, world!
SectionEnd

Function .onInit
    MessageBox MB_OK "Hello, world!" 
    Quit
FunctionEnd

使用 lablgtk

let () = 
  let window = GWindow.window ~title:"Hello" ~border_width:10 () in
    window#connect#destroy ~callback:GMain.Main.quit;
    let button = GButton.button ~label:"Hello World" ~packing:window#add () in
      button#connect#clicked ~callback:window#destroy;
      window#show ();
      GMain.Main.main ()

(在 Psion Series 3 及更高相容的 PDA 上)

PROC guihello:
  ALERT("Hello, world!","","Exit")
ENDP

PROC hello:
   dINIT "Window Title"
   dTEXT "","Hello, world!"
   dBUTTONS "OK",13
   DIALOG
ENDP

Pure Data

[編輯 | 編輯原始碼]

作為 ASCII 藝術的補丁

[Hello, world!(
|
[print]

作為原始碼的補丁

#N canvas 0 0 300 300 10;
#X msg 100 150 Hello, world!;
#X obj 100 200 print;
#X connect 0 0 1 0;
from Tkinter import Tk, Label
 
root = Tk()
Label(root, text="Hello, world!").pack()
 
root.mainloop()

使用 PyQt

import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *

app = QApplication(sys.argv)
label = QLabel("Hello, World!")
label.show()
sys.exit(app.exec_())
from gtk import *

label = Label("Hello, world!")
label.show()

window = Window()
window.add(label)
window.show()

main()
import pygame
import sys

pygame.init()
screen = pygame.display.set_mode((512, 256), 0, 32)
f = pygame.font.SysFont(None, 32)
t = f.render("Hello, world!", True, (255, 255, 255))
tR = t.get_rect()
screen.blit(t, tR)
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
    pygame.display.update()

Kivy 多平臺框架

import kivy

from kivy.app import App
from kivy.uix.label import Label

class MyApp(App):
    def build(self):
        return Label(text='Hello world')

MyApp().run()

Qt 工具包 (在 C++ 中)

[編輯 | 編輯原始碼]
 #include <QApplication>
 #include <QMessageBox>

 int main(int argc, char * argv[])
 {
     QApplication app(argc, argv);
     QMessageBox::information(0, "Qt4", "Hello World!");
 }

 #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();
 }

 #include <QApplication>
 #include <QPushButton>
 #include <QVBoxLayout>
 
 int main(int argc, char *argv[])
 {
     QApplication app(argc, argv);
 
     QWidget *window = new QWidget;
     QVBoxLayout *layout = new QVBoxLayout(window);
     QPushButton *hello = new QPushButton("Hello, world!", window);
 
     //connect the button to quitting
     hello->connect(hello, SIGNAL(clicked()), &app, SLOT(quit()));
 
     layout->addWidget(hello);
     layout->setMargin(10);
     layout->setSpacing(10);
 
     window->show();
 
     return app.exec();
 }
 view layout [text "Hello, world!"]
 view [text "Hello, world!"]

Robotic (MegaZeux)

[編輯 | 編輯原始碼]
* "Hello, world!"
end

(在 Hewlett-Packard HP-48G 和 HP-49G 系列計算器上)

<< "Hello, world!" MSGBOX >>
Hello ()
TEXT "Hello, world!"

Ruby 使用 WxWidgets

[編輯 | 編輯原始碼]
require 'wxruby'

class HelloWorldApp < Wx::App
 def on_init
  ourFrame = Wx::Frame.new(nil, -1, "Hello, world!").show
  ourDialogBox = Wx::MessageDialog.new(ourFrame, "Hello, world!", "Information:", \
                 Wx::OK|Wx::ICON_INFORMATION).show_modal
 end
end

HelloWorldApp.new.main_loop

Ruby 使用 GTK+

[編輯 | 編輯原始碼]
require 'gtk2'

Gtk.init
window = Gtk::Window.new
window.signal_connect("delete_event") { Gtk.main_quit; false }
button = Gtk::Button.new("Hello, world!")
button.signal_connect("clicked") { Gtk.main_quit; false }
window.add(button)
window.show_all
Gtk.main

Ruby 使用 Tk

[編輯 | 編輯原始碼]
require 'tk'

window = TkRoot.new { title 'Hello, world!' }
button = TkButton.new(window) {
 text 'Hello, world!'
 command proc { exit }
 pack
}

Tk.mainloop

Smalltalk

[編輯 | 編輯原始碼]

在工作空間中評估

Dialog confirm: 'Hello, world!'

使用 Squeak Smalltalk 的 Morphic GUI 工具包

('Hello, world!' asMorph openInWindow) submorphs second color: Color black

使用 wxSqueak

Wx messageBox: 'Hello, world!'

SWT 使用 Java

[編輯 | 編輯原始碼]
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
public class SWTHello {
     public static void main (String [] args) {
         Display display = new Display ();
         final Shell shell = new Shell(display);
         RowLayout layout = new RowLayout();
         layout.justify = true;
         layout.pack = true;
         shell.setLayout(layout);
         shell.setText("Hello, world!");
         Label label = new Label(shell, SWT.CENTER);
         label.setText("Hello, world!");
         shell.pack();
         shell.open ();
         while (!shell.isDisposed ()) {
             if (!display.readAndDispatch ()) display.sleep ();
         }
         display.dispose ();
     }
}
label .l -text "Hello, world!"
pack .l

以及單行程式碼

pack [label .l -text "Hello, world!"]

Tcl 與 Tk

[編輯 | 編輯原始碼]
package require Tk
tk_messageBox -message "Hello, world!"

package require Tk
pack [button .b -text "Hello, world!" -command exit]
 Ubercode 1 class Hello
 public function main()
 code
   call Msgbox("Hello", "Hello, world!")
 end function
 end class
 message "Hello, world!"
void main () 
{ 
  String s = "Hello World."; 
  bc.OutputToConsole (s); 
}
Sub Main()
    MsgBox "Hello, world!"
End Sub

Visual Basic .NET 2003/2005

[編輯 | 編輯原始碼]
Private Sub Form_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
  MessageBox.Show("Hello, world!")
  Me.Close()    
End Sub

請注意,只有在程式碼作為表單載入事件的一部分輸入時,上述示例才有效,例如在 Visual Studio 程式設計環境中生成新專案時預設建立的表單載入事件。同樣,以下程式碼大致等同於傳統的 Visual Basic 6 程式碼,它透過停用應用程式框架並將“Sub Main”設定為應用程式的入口點來實現。

Public Module MyApplication
  Sub Main()
     MessageBox.Show("Hello, world!")
  End Sub
End Class

或者使用類;

Public Class MyApplication
  Shared Sub Main()
     MessageBox.Show("Hello, world!")
  End Sub
End Class

Visual Prolog(註釋框)

[編輯 | 編輯原始碼]
#include @"pfc\vpi\vpi.ph"

goal
  vpiCommonDialogs::note("Hello, world!").

Windows API(使用 C)

[編輯 | 編輯原始碼]

這使用 Windows API 建立一個包含文字的完整視窗。

/*
 Name: Win32 example
 Copyright: GLP
 Author: Ryon S. Hunter
 Date: 20/03/07 17:11
 Description: This is an example of what a Win32 hello world looks like.
*/

#include <windows.h>
#define APPTITLE "Win32 - Hello world"

BOOL InitInstance(HINSTANCE,int);
ATOM MyRegisterClass(HINSTANCE);
LRESULT CALLBACK WinProc(HWND,UINT,WPARAM,LPARAM);

LRESULT CALLBACK WinProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
       PAINTSTRUCT ps;
       COLORREF c = RGB( 0, 0, 0 );
       HDC hdc;
       RECT rt;
       switch(message)
       {
                      case WM_DESTROY: // Exit the window? Ok
                            PostQuitMessage(0);
                      break;
                      case WM_PAINT:
                           GetClientRect( hWnd, &rt );
                           hdc = BeginPaint( hWnd, &ps );
                           DrawText( hdc, "Hello world!", sizeof( "Hello world!" ), &rt, DT_CENTER );
                           EndPaint( hWnd, &ps );
                      break;
       }
       return DefWindowProc(hWnd,message,wParam,lParam);
}

ATOM MyRegisterClass(HINSTANCE hInstance)
{
    WNDCLASSEX wc;
    wc.cbSize = sizeof( WNDCLASSEX );
    wc.style = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc = (WNDPROC)WinProc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = 0;
    wc.hIcon = NULL;
    wc.hCursor = LoadCursor( NULL, IDC_ARROW );
    wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    wc.lpszMenuName = NULL;
    wc.lpszClassName = APPTITLE;
    wc.hIconSm = NULL;
    
    return RegisterClassEx(&wc);
}

BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
    HWND hWnd;
    hWnd = CreateWindow( // Create a win32 window
         APPTITLE,
         APPTITLE,
         WS_OVERLAPPEDWINDOW,
         CW_USEDEFAULT,
         CW_USEDEFAULT,
         500,
         400,
         NULL,
         NULL,
         hInstance,
         NULL);
    if(!hWnd) return FALSE; 
    ShowWindow( hWnd, nCmdShow );
    UpdateWindow( hWnd );
    return TRUE;
}

int WINAPI WinMain( HINSTANCE hInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpCmdLine,
                    int nCmdShow )
{
                    MSG msg;
                    MyRegisterClass(hInstance);
                    if(!InitInstance( hInstance,nCmdShow) )
                                      return 1;
                    while( GetMessage( &msg, NULL, 0, 0 ) )
                    {
                           TranslateMessage( &msg );
                           DispatchMessage( &msg );
                    }
                    return msg.wParam;
}

在預設視窗的開啟事件處理程式中

MsgBox("Hello world!")
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="yourwindow" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<label value="Hello, World!"/>
</window>
 with(Maplets):
 with(Maplets[Elements]):
 maplet := Maplet( [["Hello world!"]] ):
 Display( maplet );

文件格式

[編輯 | 編輯原始碼]

以下字元序列以十六進位制表示(在序列末尾帶有回車符和換行符)

48 65 6C 6C 6F 2C 20 77 6F 72 6C 64 21 0D 0A

以下字元序列以二進位制數字表示(如上所述的 cr/nl,以及相同的位元組順序)

00-07: 01001000 01100101 01101100 01101100 01101111 00101100 00100000 01110111
08-0E: 01101111 01110010 01101100 01100100 00100001 00001101 00001010

頁面描述語言

[編輯 | 編輯原始碼]

XHTML 1.1

[編輯 | 編輯原始碼]

(使用 UTF-8 字元集。)

 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
  <head>
   <title>Hello, world!</title>
  </head>
  <body>
   <p>Hello, world!</p>
  </body>
 </html>
<html>
  <body>
    Hello, world!
  </body>
</html>

非正式

[編輯 | 編輯原始碼]

對於非正式測試,<html> 和 <body> 標籤不是必需的。只需將其作為沒有標籤的文字編寫即可。

Hello, world!

HTML 4.01 嚴格(完整)

[編輯 | 編輯原始碼]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <title>Hello, world!</title>
  </head>
  <body>
    <p>Hello, world!</p>
  </body>
</html>

W3C 關於HTML 文件全域性結構的建議書的第一段也包含了此示例。

HTML 4.01 嚴格(最小)

[編輯 | 編輯原始碼]

這是最小的合法版本,省略了所有可選標籤

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN">
<title>Hello, world!</title>
<p>Hello, world!
<!DOCTYPE html>
<html>
  <head>
    <title>Hello, World!</title>
  </head>
  <body>
    <h1>Hello, world!</h1>  
  </body>
</html>
Hello, World!

MediaWiki/維基文字

[編輯 | 編輯原始碼]
Hello, World!
%PDF-1.0
1 0 obj
<<
/Type /Catalog
/Pages 3 0 R
/Outlines 2 0 R
>>
endobj
2 0 obj
<<
/Type /Outlines
/Count 0
>>
endobj
3 0 obj
<<
/Type /Pages
/Count 1
/Kids [4 0 R]
>>
endobj
4 0 obj
<<
/Type /Page
/Parent 3 0 R
/Resources << /Font << /F1 7 0 R >>/ProcSet 6 0 R
>>
/MediaBox [0 0 612 792]
/Contents 5 0 R
>>
endobj
5 0 obj
<< /Length 44 >>
stream
BT
/F1 24 TF
100 100 Td (Hello, world!) Tj
ET
endstream
endobj
6 0 obj
[/PDF /Text]
endobj
7 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F1
/BaseFont /Helvetica
/Encoding /MacRomanEncoding
>>
endobj
xref
0 8
0000000000 65535 f
0000000009 00000 n
0000000074 00000 n
0000000120 00000 n
0000000179 00000 n
0000000322 00000 n
0000000415 00000 n
0000000445 00000 n
trailer
<<
/Size 8
/Root 1 0 R
>>
startxref
553
%%EOF

只有當文字檔案具有 CRLF 行結束符時,這才是有效的 PDF。

PostScript

[編輯 | 編輯原始碼]
 % Displays on console.
 (Hello, world!) =
 %!
 % Displays as page output.
 /Courier findfont
 24 scalefont
 setfont
 100 100 moveto
 (Hello, world!) show
 showpage
{\rtf1\ansi\deff0
{\fonttbl {\f0 Courier New;}}
\f0\fs20 Hello, world!
}
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <svg xmlns="http://www.w3.org/2000/svg" width="200" height="100">
  <text x="50" y="50">Hello, world!</text>
 </svg>
 Hello, world!
 \bye

LaTeX 2ε

[編輯 | 編輯原始碼]
 \documentclass{article}
 \begin{document}
   Hello, world!
 \end{document}
  \starttext
    Hello, world!
  \stoptext

基於媒體的指令碼語言

[編輯 | 編輯原始碼]
 BlankClip()
 Subtitle("Hello, world!")

(建立具有預設屬性的影片)

Lingo(Macromedia Director 指令碼語言)

[編輯 | 編輯原始碼]
on exitFrame me
  put "Hello, world!"  
end

如果將字串放置在單個電影幀中,則將其輸出到訊息視窗。或者,要顯示一個顯示訊息的警報框,您可以使用

on exitFrame me
  alert "Hello, world!"
end
 #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 }
 }

深奧程式語言

[編輯 | 編輯原始碼]

此頁面展示了深奧程式語言中的 Hello, world! 程式 - 也就是說,工作程式語言,它們被設計為實驗或笑話,並且沒有用於嚴肅用途的意圖。

<:48:x<:65:=<:6C:$=$=$$~<:03:+$<:2c:~$~<:c:x-$<:77:
~$~<:8:x-$~<:03:+$~<:06:x-$x<:0e:x-$=x<:43:x-$
  use java.lang.*;
  main
  {
      System->out->println[ 'Hello, world!' ];
  }
 ■→→■↓■←■←■↓■→→■  /* makes H */
 →→■↓■↑↑↑■        /* makes I */
 "!dlrow olleH">v
                :
                ,
               ^_@
 v v"Hello, world!!"<
 >                  ^
 > >:#v_@
 ^   .<
 0"!dlrow olleH">,:#<_@

二進位制 lambda 演算

[編輯 | 編輯原始碼]

http://www.ioccc.org/2012/tromp/hint.html 中所述(任何從 ' ' 到 '/' 的 16 個 ASCII 字元都可以用作開頭)

   !Hello, world

BlooP、FlooP

[編輯 | 編輯原始碼]

來自 Eric Raymond 的直譯器包(更改為使用書中的大寫字母)。

   DEFINE PROCEDURE ''HELLO-WORLD''[N]:
   BLOCK 0: BEGIN
       PRINT['Hello, world!'];
   BLOCK 0: END.
+++++ +++++             initialize counter (cell #0) to 10
[                       use loop to set the next four cells to 70/100/30/10
    > +++++ ++              add  7 to cell #1
    > +++++ +++++           add 10 to cell #2 
    > +++                   add  3 to cell #3
    > +                     add  1 to cell #4
    <<<< -                  decrement counter (cell #0)
]                   
> ++ .                  print 'H'
> + .                   print 'e'
+++++ ++ .              print 'l'
.                       print 'l'
+++ .                   print 'o'
> ++ .                  print ' '
<< +++++ +++++ +++++ .  print 'W'
> .                     print 'o'
+++ .                   print 'r'
----- - .               print 'l'
----- --- .             print 'd'
> + .                   print '!'
> .                     print '\n'

Hello, world! Souffle by David Morgan-Mar。

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.

後來 Mike Worth 寫了 更美味且真正有效的食譜

Hello World Cake with Chocolate sauce.

This prints hello world, while being tastier than Hello World Souffle. The main
chef makes a " world!" cake, which he puts in the baking dish. When he gets the
sous chef to make the "Hello" chocolate sauce, it gets put into the baking dish
and then the whole thing is printed when he refrigerates the sauce. When
actually cooking, I'm interpreting the chocolate sauce baking dish to be
separate from the cake one and Liquify to mean either melt or blend depending on
context.

Ingredients.
33 g chocolate chips
100 g butter
54 ml double cream
2 pinches baking powder
114 g sugar
111 ml beaten eggs
119 g flour
32 g cocoa powder
0 g cake mixture

Cooking time: 25 minutes.

Pre-heat oven to 180 degrees Celsius.

Method.
Put chocolate chips into the mixing bowl.
Put butter into the mixing bowl.
Put sugar into the mixing bowl.
Put beaten eggs into the mixing bowl.
Put flour into the mixing bowl.
Put baking powder into the mixing bowl.
Put cocoa  powder into the mixing bowl.
Stir the mixing bowl for 1 minute.
Combine double cream into the mixing bowl.
Stir the mixing bowl for 4 minutes.
Liquify the contents of the mixing bowl.
Pour contents of the mixing bowl into the baking dish.
bake the cake mixture.
Wait until baked.
Serve with chocolate sauce.

chocolate sauce.

Ingredients.
111 g sugar
108 ml hot water
108 ml heated double cream
101 g dark chocolate
72 g milk chocolate

Method.
Clean the mixing bowl.
Put sugar into the mixing bowl.
Put hot water into the mixing bowl.
Put heated double cream into the mixing bowl.
dissolve the sugar.
agitate the sugar until dissolved.
Liquify the dark chocolate.
Put dark chocolate into the mixing bowl.
Liquify the milk chocolate.
Put milk chocolate into the mixing bowl.
Liquify contents of the mixing bowl.
Pour contents of the mixing bowl into the baking dish.
Refrigerate for 1 hour.
"Hello, World!
"

終止引號之前的換行符是必需的。

H

INTERCAL 程式語言

[編輯 | 編輯原始碼]
    PLEASE DO ,1 <- #13
    DO ,1 SUB #1 <- #238
    DO ,1 SUB #2 <- #112
    DO ,1 SUB #3 <- #112
    DO ,1 SUB #4 <- #0
    DO ,1 SUB #5 <- #64
    DO ,1 SUB #6 <- #238
    DO ,1 SUB #7 <- #26
    
    DO ,1 SUB #8 <- #248
    DO ,1 SUB #9 <- #168
    DO ,1 SUB #10 <- #24
    DO ,1 SUB #11 <- #16
    DO ,1 SUB #12 <- #158
    DO ,1 SUB #13 <- #52
    PLEASE READ OUT ,1
    PLEASE GIVE UP
HAI;
    CAN HAS STDIO?;
    VISIBLE "Hello, World!";
KTHXBYE;

LOLGraphics

[編輯 | 編輯原始碼]
HAI 3.4 0 100
IM IN UR CODE EXECUTIN UR KOMANDZ

PLZ PRINT TEXT HELLO WORLD!
 
IM OUTTA UR CODE

Malbolge 程式語言

[編輯 | 編輯原始碼]
(=<`:9876Z4321UT.-Q+*)M'&%$H"!~}|Bzy?=|{z]KwZY44Eq0/{mlk**hKs_dG5[m_BA{?-Y;;Vb'rR5431M}/.zHGwEDCBA@98\6543W10/.R,+O< hello

P 程式語言

[編輯 | 編輯原始碼]
"Hello, world!\n"

這並不是真正的深奧語言,但這段程式碼使用了 混淆

qq chop lc and print chr ord uc q chop uc and print chr ord q ne sin and 
print chr ord qw q le q and print chr ord q else and print chr ord q pop 
and print chr oct oct ord uc qw q bind q and print chr ord q q eq and print 
chr ord qw q warn q and print chr ord q pop and print chr ord q qr q and 
print chr ord q else and print chr ord qw q do q and print chr hex length 
q q semctl setpgrp chop q


Piet 程式語言只使用顏色。

Piet 中的 Hello world(請參閱 YouTube 上的“The Art of Code”第 41:40 分鐘起)
Shout "Hello, world!"

莎士比亞

[編輯 | 編輯原始碼]
The Infamous Hello World Program.
 
Romeo, a young man with a remarkable patience.
Juliet, a likewise young woman of remarkable grace.
Ophelia, a remarkable woman much in dispute with Hamlet.
Hamlet, the flatterer of Andersen Insulting A/S.
  
                  Act I: Hamlet's insults and flattery.
  
                  Scene I: The insulting of Romeo.
 
[Enter Hamlet and Romeo]

Hamlet:
 You lying stupid fatherless big smelly half-witted coward!
 You are as stupid as the difference between a handsome rich brave
 hero and thyself! Speak your mind!

 You are as brave as the sum of your fat little stuffed misused dusty
 old rotten codpiece and a beautiful fair warm peaceful sunny summer's
 day. You are as healthy as the difference between the sum of the
 sweetest reddest rose and my father and yourself! Speak your mind!

 You are as cowardly as the sum of yourself and the difference
 between a big mighty proud kingdom and a horse. Speak your mind.

 Speak your mind!

[Exit Romeo]

                    Scene II: The praising of Juliet.

[Enter Juliet]

Hamlet:
 Thou art as sweet as the sum of the sum of Romeo and his horse and his
 black cat! Speak thy mind!

[Exit Juliet]

                    Scene III: The praising of Ophelia.

[Enter Ophelia]

Hamlet:
 Thou art as lovely as the product of a large rural town and my amazing
 bottomless embroidered purse. Speak thy mind!

 Thou art as loving as the product of the bluest clearest sweetest sky
 and the sum of a squirrel and a white horse. Thou art as beautiful as
 the difference between Juliet and thyself. Speak thy mind!

[Exeunt Ophelia and Hamlet]


                    Act II: Behind Hamlet's back.

                    Scene I: Romeo and Juliet's conversation.

[Enter Romeo and Juliet]

Romeo:
 Speak your mind. You are as worried as the sum of yourself and the
 difference between my small smooth hamster and my nose. Speak your
 mind!

Juliet:
 Speak YOUR mind! You are as bad as Hamlet! You are as small as the
 difference between the square of the difference between my little pony
 and your big hairy hound and the cube of your sorry little
 codpiece. Speak your mind!

[Exit Romeo]

                    Scene II: Juliet and Ophelia's conversation.

[Enter Ophelia]

Juliet:
 Thou art as good as the quotient between Romeo and the sum of a small
 furry animal and a leech. Speak your mind!

Ophelia:
 Thou art as disgusting as the quotient between Romeo and twice the
 difference between a mistletoe and an oozing infected blister! Speak
 your mind!

[Exeunt]
   /e+++++++++++++++++++++++++++++.\  
   ./\/\/\  /+++\!>.+++o.l.+++++++l/                  #/?\  
$H!\++++++\ +   \comma.------------ .<w++++++++.\ /?\<!\-/
   /++++++/ +/\                      /.--------o/ \-/!.++++++++++/?\n
 /=\++++++\ +\\!=++++++\             \r+++.l------.d--------.>+.!\-/
 \!\/\/\/\/ \++++++++++/

模組化 SNUSP

      /@@@@++++#               #+++@@\                #-----@@@\n
$@\H.@/e.+++++++l.l.+++o.>>++++.< .<@/w.@\o.+++r.++@\l.@\d.>+.@/.#
  \@@@@=>++++>+++++<<@+++++#       #---@@/!=========/!==/

Spoon(程式語言)

[編輯 | 編輯原始碼]
1111110010001011111111111101100000110100010100101111111111001000101111111111011000001101 0100101011111110010100010101110010100101111001000101111111111101100000110100010100111110 0100010000000000000011000001101000101001101101101101111100100010111110110000011010001010 0100100010101110010100000000000000000000010100000000000000000000000000010100100101001010

超級 NAND 時間!!

[編輯 | 編輯原始碼]
12 (32 35 37 38 42)
13 (35 37 38 39 43)
14 ((31 36 39 42 43))
15 (31 33 34 35 38 40 43)
16 (37 39)
17 ((31 43))
18 ((36 42 43))
20 ((42(43)))
21 44
31 ((31)(44))
32 (32(31))
33 (33(32))
34 (34(33))
35 (35(34))
36 (36(35))
37 (37(36))
38 (38(37))
39 (39(38))
40 (40(39))
41 (41(40))
42 (42(41))
43 (43(42))
44 1

計程車程式語言

[編輯 | 編輯原始碼]
"Hello, World!" is waiting at the Writer's Depot.
Go to Writer's Depot: west 1st left, 2nd right, 1st left, 2nd left.
Pickup a passenger going to the Post Office.
Go to the Post Office: north 1st right, 2nd right, 1st left.
Go to the Taxi Garage: north 1st right, 1st left, 1st right.

T 程式語言

[編輯 | 編輯原始碼]
%begin @jump $main
%main.0 @echo %msg
%main.1 @end
%main.count 2
%msg Hello, world!

This=That

[編輯 | 編輯原始碼]
x=Hello,world!
x=print

Unlambda 程式語言

[編輯 | 編輯原始碼]
  `r```````````.H.e.l.l.o. .w.o.r.l.di

Var'aq 程式語言

[編輯 | 編輯原始碼]

注意:實際上用克林貢語列印“你想要什麼,宇宙?”。

    ~ nuqneH { ~ 'u' ~ nuqneH disp disp } name
   nuqneH

空白符

[編輯 | 編輯原始碼]

請注意,空白符已突出顯示(空格製表符

   
   	  	   
		    	
   		  	 	
		    	 
   		 		  
		    		
   		 		  
		    
	  
   		 				
		    	 	
   	 		  
		    		 
   	     
		    			
   			 			
		  
  	   
   		 				
		    	  	
   			  	 
		    	 	 
   		 		  
		    	 		
   		  
	  
		    		  
   	    	
		    		 	
   		 	
		    			 
   	 	 
		    				
    
	
	     
empty-line
    	
empty-line
 			 
empty-line
	  	 
	
     	
	   
empty-line
  	
empty-line
   	 
empty-line
empty-line/EOF

XS 程式語言

[編輯 | 編輯原始碼]
<print>Hello, world!</print>

Ya 程式語言

[編輯 | 編輯原始碼]
@HelloWorld.Ya;
using <stdio.h>;
$int($char[][] args) main
	printf("Hello, %s!\n", args.Length > 1 ? args[1] : "World");
	return 0;

一種在盲文繪圖儀上以二進位制方式繪製的程式碼語言。

BGN GRPLOT BIN
DRAWPLOT

0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0011100111001111111001110000000011100000000001111100000000001000001000011111000001111100000100000000011111110000
0001000010000100001000100000000001000000000010000010000000001000001000100000100010000010000100000000010000001000
0001000010000100000000100000000001000000000010000010000000001000001000100000100010000010000100000000010000001000
0001111110000111100000100000000001000000000010000010000000001001001000100000100011111110000100000000010000001000
0001000010000100000000100000000001000000000010000010000000001011101000100000100010000001000100000000010000001000
0001000010000100001000100000000001000000000010000010000000001100011000100000100010000000100100000000010000001000
0011100111001111111001111111100011111111000001111100000000001000001000011111000010000000100111111100011111110000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

ENDDRAW
END

這種面向物件的語言看起來像 C 語言。

use System.Windows.Forms;

class HelloWorld extends System.Windows.Forms
{
    protected:
        String hw;
    construct HelloWorld()
    {
        this.hw = 'Hello, world!';
    }
    public void function show()
    {
        MessageBox.show(this.hw, '');
    }
}

複製並貼上到 ChatGPT,在新聊天中

Output: Hello, world!

一個更長的版本,仍然列印“Hello, world!”

CreateBuf: $Hello$
$Hello$: {
[H]
[e]
[l]
[l]
[o]
[,]
[32] @ The ASCII value for space
[w]
[o]
[r]
[l]
[d]
[!]
}
OpenBuf: $Hello$
JoinAllChars: $Hello$ => $Hello2$
Output: $Hello2$
CloseBuf: $Hello$

注意:第一種方法已測試,正在執行。我不知道第二種方法是否可行!

華夏公益教科書