几乎所有编程语言的hello, world程序(1)

简介

“hello, world”程序是指在电脑屏幕上打印/输出”hello, world”这行字符串的应用程序。该范例最早出自1972年由贝尔实验室成员布莱恩柯林汉撰写的内部技术档案”A Tutorial Introduction to the Language B”中,不久同作者于1974年所写的”Programming in C: A Tutorial”也使用了这个范例,而以本文档所改写的《C语言程序设计》也保留了这个范例。

但是需要注意的是,Hello World的标准程序是”hello, world”,没有双引号和惊叹号,全部小写,并且在逗号后留有空格。

虽然都来自网络……但排版了好久好久好久……………………

1C-Enterprise

Message("Hello, World!");

4Test

testcase printHelloWorld()
    print("Hello World!")

ABAP4

REPORT ZHB00001.
*Hello world in ABAP/4 *
WRITE: 'Hello world'.

ACPI Source Language

Scope(\) {
    Method(_WAK) {
        Store ("Hello World", Debug)
        Return(Package(2){
   0x00000000,0})
    }   
}

Action!

PROC Main()
 PrintE("Hello World!")
RETURN

ActionScript 3.0

var t:TextField=new TextField();
t.text="Hello World!";
addChild(t);

Actionscript-Flash5

trace ("Hello World"); 

ActionScript-Flash8

class HelloWorld
{
   
    private var helloWorldField:TextField;

    public function HelloWorld( mc:MovieClip )
    {
   
        mc.helloWorldField = mc.createTextField("helloWorldField", mc.getNextHighestDepth(), 0, 0, 100, 100);
        mc.helloWorldField.autoSize = "left";
    mc.helloWorldField.html = true;
        mc.helloWorldField.htmlText = '<font size="20" color="#0000FF">Hello World!</font>';
    }
}

// on a frame
import HelloWorld;
var hw:HelloWorld = new HelloWorld( this );

Actionscript-FlashMX

// Hello World in Actionscript (Flash MX onwards) 

_root.createTextField("mytext",1,100,100,300,100);
mytext.multiline = true;
mytext.wordWrap = true;
mytext.border = false;

myformat = new TextFormat();
myformat.color = 0xff0000;
myformat.bullet = false;
myformat.underline = true;

mytext.text = "Hello World!";
mytext.setTextFormat(myformat);

Ada

-- Hello World in Ada

with Text_IO;
procedure Hello_World is

begin
  Text_IO.Put_Line("Hello World!");
end Hello_World;

ADVPL

// Hello World in ADVPL

User Function Hello()
Local cMsg := "Hello, world!"
conout(cMsg)
MsgInfo(cMsg)
Return

Algol-60

'BEGIN'
   'COMMENT' Hello World in Algol 60;
    OUTPUT(4,'(''('Hello World!')',/')')
'END'

Algol-68

( # Hello World in Algol 68 # print(("Hello World!",newline)))

Alpha-Five-Xbasic

' Hello World in Alpha Five Xbasic

ui_msg_box("The 'Hello World' Collection", "Hello World", UI_ATTENTION_SYMBOL)

amharic


// Hello World in Clipper

? "Hello World"

Amiga-E

-> Hello World in Amiga-E 
PROC main() IS WriteF('Hello World\n')

AMOS

Back to index 
Rem Hello world in AMOS

Print "Hello world!"

AngelScript

// Hello world in AngelScript

void main() { print("Hello world\n"); }

Ante

98♥J♦A237♠J♦A7♦J♦J♦A3♦J♦564♥J♥A66♠J♥A8♦J♦A8♠J♦A3♦J♦A6♠J♦A8♠J♦A32♠J♥A26♠J♥

APC

// Hello World in the APC language for probes

probe program
{
    on_entry log ("Hello, world!\n");
}

APL

⍝ Hello World in APL

⎕←\'Hello World\'

AppleScript

-- "Hello World" in AppleScript:

display dialog "Hello World"

Arena

// Hello world in Arena

print("Hello World!");

Argh!

Hello World in Argh!. No comment character exists.

j       world
lppppppPPPPPPsrfj
 hello,      *  j
              qPh

ArnoldC

IT'S SHOWTIME
TALK TO THE HAND "Hello World"
YOU HAVE BEEN TERMINATED

ASP-CSharp

<!-- Hello World for ASP.NET using C# -->
<% @ Page Language="C#" %>
<% ="Hello World!" %>

ASP-JavaScript

<%@ language="javascript" %>
<html><body>
<%
Response.Write('Hello World!');
%>
</body></html>

ASP-VBE

<!-- Hello World in ASP-VBE (Visual Basic Script Encided) -->
<html>
<script language="VBScript.Encode">#@~^HQAAAA==@#@&HdTAK6PrCsVKP    WMV[Zr@#@&HwcAAA==^#~@</script>
</html>

ASP-VBS

Hello World for Microsoft ASP (in VBScript)

<%@ language="vbscript" %>
<html><body>
<%
Response.write "Hello World!"
%>
</body></html>


ASP.NET

<!-- Hello World in ASP.NET -->
<%= "Hello World!" %>

Assembler-6502-AppleII

**********************************
*                                *
*      HELLO WORLD FOR 6502      *
*    APPLE ][, MERLIN ASSEMBLER  *
*                                *
**********************************

STROUT  EQU $DB3A ;OUTPUTS AY-POINTED NULL TERMINATED STRING
    LDY #>HELLO
    LDA #<HELLO
    JMP STROUT

HELLO   ASC "HELLO WORLD!",00

Assembler-6502-C64

; Hello World for 6502 Assembler (C64)

ldy #0
beq in
loop:
jsr $ffd2
iny
in:
lda hello,y
bne loop
rts
hello: .tx "Hello World!"
       .by 13,10,0


Assembler-68000-Amiga

; Hello World in 68000 Assembler for dos.library (Amiga)

        move.l  #DOS
        move.l  4.w,a6
        jsr     -$0198(a6)      ;OldOpenLibrary
        move.l  d0,a6
        beq.s   .Out
        move.l  #HelloWorld,d1

A)      moveq   #13,d2
        jsr     -$03AE(a6)      ;WriteChars

B)      jsr     -$03B4          ;PutStr

        move.l  a6,a1
        move.l  4.w,a6
        jsr     -$019E(a6)      ;CloseLibrary
.Out    rts

DOS          dc.b    'dos.library',0
HelloWorld   dc.b    'Hello World!',$A,0

Assembler-68000-AtariST

; Hello World in 68000 Assembler (Atari ST)

     move.l #helloworld,-(A7)
     move   #9,-(A7)
     trap   #1
     addq.l #6,A7
     move   #0,-(A7)
     trap   #1
helloworld:
     dc.b "Hello World!",$0d,$0a,0

Assembler-68008

; Hello World in 68008 Assembler (Sinclar QL)

     move.l #0,a0
     lea.l  mess,a1
     move.w $d0,a2
     jsr    (a2)
     rts
mess dc.w   12
     dc.b   'Hello World!',10
     end

Assembler-8051

-- Hello World in Assembler for the Intel 8051 (MSC51)

 Org 0

   mov dptr,#msg
   mov R0,#30h  
loop:
   clr a
   movc a,@a+dptr
   jz end
   mov @R0,a
   inc R0
   inc dptr
   sjmp  loop

end:
    jmp $

msg:
    db 'Hello World",0

Assembler-ARM

; Hello World in ARM code assembler, with RISC OS software interrupt

SWI "OS_WriteS"
EQUS "Hello World!"
EQUB 0
ALIGN
MOV PC,R14

Assembler-Darwin-PPC

; Hello World in Assembler for the Darwin Power-PC

.data
.cstring
.align 2
msg:
.asciz "Hello world!\n"
len = . - msg
.text
.align 2
.globl _start
_start:
li r0,4
li r3,1
lis r4,ha16(msg)
ori r4,r4,lo16(msg)
li r5,len
sc
li r0,1
li r3,0
sc

Assembler-DG-Nova

                        .TITL HELLO
02                      ; "HELLO, WORLD" FOR NOVA RUNNING RDOS
03                      ; USES PCHAR SYSTEM CALL
04                      .NREL
05                      .ENT START
06
07              START:
08 00000'022424 DOCHAR: LDA 0,@PMSG     ; LOAD AC0 WITH NEXT CHARACTER,
09 00001'101015         MOV# 0,0,SNR    ; TEST AC0;
10 00002'000412          JMP DONE ; SKIPPED IF NONZERO
11 00003'006017         .SYSTM
12 00004'010000         .PCHAR          ; PRINT FIRST
13 00005'000413          JMP ER ; SKIPPED IF OK
14 00006'101300         MOVS 0,0        ; SWAP BYTES
15 00007'006017         .SYSTM
16 00010'010000         .PCHAR          ; PRINT SECOND
17 00011'000407          JMP ER ; SKIPPED IF OK
18 00012'010412         ISZ PMSG        ; POINT TO NEXT WORD
19 00013'000765         JMP DOCHAR      ; GO AROUND AGAIN
20
21 00014'006017 DONE:   .SYSTM          ; NORMAL EXIT
22 00015'004400         .RTN
23 00016'000402          JMP ER
24 00017'063077         HALT
25 00020'006017 ER:     .SYSTM          ; ERROR EXIT
26 00021'006400         .ERTN
  • 11
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值