跳转到内容

计算机编程/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$

注意:第一种方法已测试,正在运行。我不知道第二种方法是否可行!

华夏公益教科书