Tuesday, September 28, 2010

All Programming Languages-Hello World! 1

List of hello world programs



The following is a list of Hello, world! programs.

Hello, world! programs make the text "Hello, world!" appear on a computer screen. It is usually the first program encountered when learning a programming language. Otherwise, it's a basic sanity check for an installation of a new programming language. If "Hello World" won't run, one must not try and develop complex programs before fixing the issues with the installation.

]

[edit]4DOS batch

It should be noted that the 4DOS/4NT batch language is a superset of the MS-DOS batch language.

 @echo Hello, world! 

[edit]Ingres 4GL

message "Hello, world!" with style = popup; 

[edit]ABAP - SAP AG

REPORT ZELLO. WRITE 'Hello, world!'. 

[edit]ABC

WRITE "Hello, world!" 

[edit]ActionScript 1.0 and 2.0

This will output to the output window only, which an end user would not see.

trace("Hello, world!"); 


This version will be visible to the end user. Use of _root to clarify scope only.

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



[edit]ActionScript 3

package {     import flash.display.Sprite;     public class HelloWorld extends Sprite     {         public function HelloWorld()         {             trace("Hello, world!");         }     } } 

[edit]Ada

with TEXT_IO;   procedure HELLO is begin     TEXT_IO.PUT_LINE ("Hello, world!"); end HELLO; 

For explanation see Ada Programming:Basic.

[edit]ALGOL 68

The ALGOL 68 standard requires that reserved-words, types and operators are in a different typeface. Hence programs are typically published in either bold or an underline typeface, eg:

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

In the popular upper-case stropping convention for bold words:

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

or using a wikitext like quote stropping, this is especially suitable on computers with only 6 bits per character (hence only have UPPERCASE):

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

or minimally using the "brief symbol" form of begin and end.

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

[edit]AmigaE

PROC main()    WriteF('Hello, world!'); ENDPROC 

[edit]AMX NetLinx

This program sends the message out via the Diagnostics Interface after start-up.

program_name = 'Hello' define_start send_string 0,'Hello World!' 

[edit]APL

An explicit return function for the Hello, world! program may be coded as follows (note: TeX fonts are not correct)

    \nabla  \mathrm {R} \leftarrow \mathrm {HW} \Delta\mathrm{PGM}   \left [ 1 \right ] \mathrm {R}\leftarrow \mathrm {'HELLO} \; \mathrm {WORLD!'}      \nabla  
  • The Del on the first line begins function definition for the program named HWΔPGM. It is a niladic function (no parameters, as opposed to monadic or dyadic) and it will return an explicit result which allows other functions or APL primitives to use the returned value as input.
  • The line labelled 1 assigns the text vector 'Hello, world!' to the variable R
  • The last line is another Del which ends the function definition.

When the function is executed by typing its name, the APL interpreter assigns the text vector to the variable R, but since we have not used this value in another function, primitive, or assignment statement the interpreter returns it to the terminal, thus displaying the words on the next line below the function invocation.

The session would look like this

      HWΔPGM Hello, world! 

While not a program, if you simply supplied the text vector to the interpreter but did not assign it to a variable it would return it to the terminal as output. Note that user input is automatically indented 6 spaces by the interpreter while results are displayed at the beginning of a new line.

      'Hello, world!' Hello, world! 

[edit]AppleScript

See also GUI section.

return "Hello, world!" 


[edit]ASP

<% Response.Write("Hello, world!") %> 
or simply:
<%= "Hello, world!" %> 

[edit]ASP.NET

// in the code behind using C# protected void Page_Load(object sender, EventArgs e) {   Response.Write("Hello, world!"); } 
// ASPX Page Template   <asp:Literal ID="Literal1" runat="server" Text="Hello World!">asp:Literal> 

or

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

or

Hello World! 

[edit]Assembly language

[edit]Accumulator-only architecture: DEC PDP-8, PAL-III assembler

See the example section of the PDP-8 article.

[edit]First successful uP/OS combinations: Intel 8080/Zilog Z80, CP/M, RMAC assembler

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]Popular home computer: ZX Spectrum, Zilog Z80, HiSoft GENS assembler

 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          CP 0         ; 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 MSG      DEFM "Hello, world!" 120          DEFB 13      ; carriage return 130          DEFB 0       ; null terminator 

[edit]Accumulator + index register machine: MOS Technology 6502, CBM KERNEL, MOS assembler syntax

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 

[edit]Accumulator/Index microcoded machine: Data General Nova, RDOS

See the example section of the Nova article.

[edit]Expanded accumulator machine: Intel x86, DOS, TASM

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$ string         INT 21H         MOV AX, 4C00H         INT 21H END Start 

[edit]ASSEMBLER x86 (DOS, MASM)

.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 

[edit]ASSEMBLER x86 (DOS, FASM)

; 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 !!!$' 

[edit]Expanded accumulator machine: Intel x86, Microsoft Windows, FASM

Example of making 32-bit PE program as raw code and data:

   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 

Using FASM import macro, unicode (MessageBoxW is one of few unicode functions 'supported' by Windows 9x/ME) and section sharing, no relocation (not needed for executables), no heap - Not a beginners example but only 1024 instead of 3072 bytes:

  include 'd:\dev\software\common\fasmw\win32a.inc'  format PE GUI 4.0 heap 0 entry start  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 

[edit]Expanded accumulator machine: Intel x86, Linux, FASM

 format ELF executable  entry _start    _start:       mov eax, 4       mov ebx, 1       mov ecx, msg       mov edx, msg_len       int 0x80         msg db 'Hello, world!', 0xA       msg_len = $-msg 

[edit]Expanded accumulator machine:Intel x86, Linux, GAS

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

[edit]Expanded accumulator machine: Intel x86, Linux, NASM

    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 

[edit]Expanded accumulator machine: Intel x86, Linux, GLibC, NASM

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         ; / 

[edit]General-purpose fictional computer: MIX, MIXAL

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 

[edit]General-purpose fictional computer: MMIX, MMIXAL

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 

[edit]General-purpose-register CISC: DEC PDP-11

[edit]RT-11, MACRO-11
        .MCALL  .REGDEF,.TTYOUT,.EXIT         .REGDEF  HELLO:  MOV    #MSG,R1         MOVB   (R1)+,R0 LOOP:  .TTYOUT         MOVB   (R1)+,R0         BNE    LOOP        .EXIT  MSG:   .ASCIZ  /Hello, world!/        .END    HELLO 
[edit]Variant for Elektronika BK using BIOS function, MICRO-11
        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 

[edit]CISC Amiga (Workbench 2.0): Motorola 68000

        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         jsr      _LVOCloseLibrary(a6)         rts  dosname     dc.b 'dos.library',0 hellostr    dc.b 'Hello, world!',0 

[edit]CISC Atari: Motorola 68000

;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 

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

        .title    hello          .psect    data, wrt, noexe  chan:   .blkw     1 iosb:   .blkq     1 term:   .ascid    "SYS$OUTPUT" msg:    .ascii    "Hello, world!" len =   . - msg          .psect    code, nowrt, exe          .entry    hello, ^m<>          ; Establish a channel for terminal I/O         $assign_s devnam=term, -                   chan=chan         blbc      r0, end          ; Queue the I/O request         $qiow_s   chan=chan, -                   func=#io$_writevblk, -                   iosb=iosb, -                   p1=msg, -                   p2=#len          ; Check the status and the IOSB status         blbc      r0, end         movzwl    iosb, r0          ; Return to operating system end:    ret         .end       hello 

[edit]Mainframe: IBM z/Architecture series using BAL

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            

[edit]RISC processor: ARM, RISC OS, BBC BASIC's in-line assembler

.program                   ADR R0,message          SWI "OS_Write0"          SWI "OS_Exit" .message                   DCS "Hello, world!"          DCB 0           ALIGN 

or the even smaller version (from qUE);

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

[edit]RISC processor: MIPS architecture

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

[edit]RISC processor: PowerPC, Mac OS X, GAS

.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 

[edit]Sigma 6/7/8/9 METASYMBOL

       SYSTEM   BPM START  M:PRINT (MESS,HW)        M:EXIT HW     TEXTC    'HELLO WORLD'        END      START 

[edit]AutoHotkey

MsgBox, Hello, world! 

[edit]AutoIt

MsgBox(0,'','Hello, world!') 

[edit]Avenue - Scripting language for ArcView GIS

MsgBox("Hello, world!","aTitle") 

[edit]AWK

BEGIN { print "Hello, world!" } 

[edit]B

This is the first known Hello, world! program ever written:[1]

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

[edit]Baan Tools

Also known as Triton Tools on older versions. On Baan ERP you can create a program on 3GL or 4GL mode.

Baan Tools on 3GL Format:

function main() {     message("Hello, world!") } 

Baan Tools on 4GL Format:

choice.cont.process: on.choice:     message("Hello, world!") 

On this last case you should press the Continue button to show the message.

[edit]Ball

Most basic form--

write Hello, *s world *n 

[edit]Bash or sh

See also UNIX-style shell.

echo 'Hello, world!' 

or

printf 'Hello, world!\n' 

or using the C preprocessor

#!/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 

[edit]BASIC

[edit]General

The following example works for any ANSI/ISO-compliant BASIC implementation, as well as most implementations built into or distributed with microcomputers in the 1970s and 1980s (usually some variant of Microsoft BASIC):

10 PRINT "Hello, world!" 20 END 

Note that the "END" statement is optional in many implementations of BASIC.

Some implementations could also execute instructions in an immediate mode when line numbers are omitted. The following examples work without requiring a RUN instruction.

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

Later implementations of BASIC allowed greater support for structured programming and did not require line numbers for source code. The following example works when RUN for the vast majority of modern BASICs.

PRINT "Hello, world!" END 

Again, the "END" statement is optional in many BASICs.

[edit]BlitzBasic

Print "Hello, world!" WaitKey 

[edit]DarkBASIC

PRINT "Hello, world!" `or TEXT 0,0,"Hello, world!" WAIT KEY 

Note: In the "classic" Dark Basic the WAIT KEY command is optional as the console goes up when the program has finished.

[edit]Liberty BASIC

To write to the main window:

print "Hello, world"  

Or drawn in a graphics window:

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

[edit]Microsoft Small Basic

TextWindow.WriteLine("Hello, world!") 

[edit]PBASIC

DEBUG "Hello, world!", CR 

or, the typical microcontroller Hello, world! program equivalent with the only output device present being a light-emitting diode (LED) (in this case attached to the seventh output pin):

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 

[edit]StarOffice/OpenOffice Basic

sub main     print "Hello, world!" end sub 

[edit]PureBasic

OpenConsole() PrintN("Hello, world!") Input() 

or

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

or

 Debug "Hello, World" 

[edit]TI-BASIC

On TI calculators of the TI-80 through TI-86 range:

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

Note: "!" character is not on the keypad. It can be accessed from "Catalog" or the "Probability" menu (as factorial notation).

On TI-89/TI-89 Titanium/TI-92(+)/Voyage 200 calculators:

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

[edit]Visual Basic

Private Sub Form_Load()   MsgBox "Hello, world" End Sub 

Alternatively, copy this into a New Form:

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 

[edit]Visual Basic .NET

Module HelloWorldApp   Sub Main()      System.Console.WriteLine("Hello, world!")   End Sub End Module 

[edit]PICK/BASIC, DATA/BASIC, MV/BASIC

In addition to the ANSI syntax at the head of this article, most Pick operating system flavors of Dartmouth BASIC support extended syntax allowing cursor placement and other terminfo type functions for VDT's

X, Y positioning (colon ":" is the concatenation instruction):

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

Will display the string "Hello, world!" roughly centered in a 80X24 CRT.

Other functions:

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

Will clear the screen before displaying the string "Hello, world!" roughly centered in a 80X24 CRT.

Syntax variants:

 CRT "Hello, world!" 

Supporting the "@" functions above, the CRT statement ignores previous PRINTER statements and always sends output to the screen.

Some Pick operating system environments such as OpenQM support the DISPLAY variant of PRINT. This variant in addition to the "@" functions maintains pagination based upon the settings of the TERM variable:

 DISPLAY "Hello, world!" 

[edit]bc

"Hello, world!" 

or, with the newline

print "Hello, world!\n" 

[edit]BCPL

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

[edit]BITGGAL AgileDog

T   1 "Hellow, World"  0 

[edit]BITGGAL Jihwaja

J( 1 TM 5 ZV 3 "Hellow, world" ) 

[edit]BLISS

%TITLE 'HELLO_WORLD' MODULE HELLO_WORLD (IDENT='V1.0', MAIN=HELLO_WORLD,         ADDRESSING_MODE (EXTERNAL=GENERAL)) = BEGIN      LIBRARY 'SYS$LIBRARY:STARLET';      EXTERNAL ROUTINE        LIB$PUT_OUTPUT;  GLOBAL ROUTINE HELLO_WORLD = BEGIN     LIB$PUT_OUTPUT(%ASCID %STRING('Hello, world!')) END;  END ELUDOM 

[edit]boo

See also GUI Section.

print "Hello, world!" 

[edit]Burning Sand 2

WRITE ELEMENT:Earth 210 230 40 CENTER TEXT "Hello World!" 

[edit]Calprola

This program will work on the Avasmath 80 online programmable calculator.

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

[edit]Casio FX-9750

This program will work on the fx-9750 graphing calculator and compatibles.

"Hello, world!" 

or

Locate 1,1,"Hello, world!" 

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

[edit]C

 #include     int main()  {     printf("Hello, world!\n");     return 0;  } 

[edit]CCL

 call echo("Hello, world!") 

[edit]Ch

The above C code can run in Ch as examples. The simple one in Ch is:

 printf("Hello, world!\n"); 

[edit]Chuck

 <<<"Hello World">>>; 

[edit]C#

See also GUI Section.

class HelloWorldApp {     static void Main()     {         System.Console.WriteLine("Hello, world!");     } } 

[edit]Chrome

namespace HelloWorld;   interface   type   HelloClass = class   public     class method Main;    end;   implementation   class method HelloClass.Main; begin   System.Console.WriteLine('Hello, world!'); end;   end. 

[edit]C++

#include    using namespace std;   int main(int argc, char *argv[]) {     cout << "Hello, World!\n"; } 

[edit]C++/CLI

int main() {    System::Console::WriteLine("Hello, world!"); } 

[edit]C++, Managed (.NET)

#using    using namespace System;   int wmain() {     Console::WriteLine("Hello, world!"); } 

[edit]ColdFusion (CFML)

Hello, world! 

or simply

Hello, world! 

[edit]COMAL

PRINT "Hello, world!" 

[edit]CIL

.assembly Hello {} .method public static void Main() cil managed {      .entrypoint      .maxstack 1      ldstr "Hello, world!"      call void [mscorlib]System.Console::WriteLine(string)      ret } 

[edit]CintieFramework (VisualBasic.NET)

> 	> 		>System.dll> 	> 	 Language="VisualBasic">  Public Class Plugin 	Public Function MainF(ByVal Ob As Object) As String 		'Script Code 		Return "Hello, World!" 	End Function End Class ]]> 	> > 

[edit]Clean

module hello  Start = "Hello, world!" 

[edit]CLIST

PROC 0 WRITE Hello, world! 

[edit]Clipper

? "Hello, world!" 

or

@1,1 say "Hello, world!" 

or

Qout("Hello, world") 

[edit]CLU

start_up = proc ()     po: stream := stream$primary_output ()     stream$putl (po, "Hello, world!")     end start_up 

[edit]COBOL

IDENTIFICATION DIVISION. PROGRAM ID.  HELLO-WORLD. PROCEDURE DIVISION.     DISPLAY "Hello, world!"     STOP RUN. 

The above is a very abbreviated and condensed version, which omits the author name and source and destination computer types.

[edit]Cube

Function | Main   WriteLine | "Hello, world" End | Main 

The '|' refers to the separation of the two text fields in the Cube standard IDE.

[edit]D

 import std.stdio ;    void main () {      writefln("Hello, world!");  } 

Tango version:

 import tango.io.Stdout;    void main() {      Stdout ("Hello, world!").newline;  } 

[edit]D++

function main() {     screenput "Hello, world!"; } 

[edit]DC an arbitrary precision calculator

[Hello, world!]p 

[edit]OR

1468369091346906859060166438166794P 

[edit]DCL batch

$ write sys$output "Hello, world!" 

[edit]DIV

PROGRAM hello; BEGIN     write(0, 0, 0, 0, "Hello, world!");     LOOP         FRAME;     END END 

[edit]DOLL

this::operator() {  import system.cstdio;  puts("Hello, world!"); } 

[edit]Dream Maker

mob     Login()         ..()         world << "Hello, world!" 

[edit]Dylan

module: hello  format-out("Hello, world!\n"); 

[edit]EAScripting

There are a number of ways to write "Hello, world!" in EAScripting. The following are some ways

[edit]EAS 0.0.1.*

set disp to "Hello, world!" set dispto to item unit 5 //5 = default screen release disp into dispto. 

This would be a pure system called by

import system ea.helloworld wait 

[edit]Ed and Ex (Ed extended)

a Hello, world!! . p 

[edit]Eiffel

class HELLO_WORLD  create make feature     make is     do         io.put_string("Hello, world!%N")     end -- make end -- class HELLO_WORLD 

[edit]Erlang

See also GUI section
-module(hello). -export([hello_world/0]).  hello_world() -> io:fwrite("Hello, world!\n"). 

[edit]Euphoria

puts(1, "Hello, world!") 

[edit]F#

print_endline "Hello, world!" 

or

printfn "Hello, world!" 

[edit]Factor

"Hello, world!" print 

or gui version

"Hello, world!" 

[edit]Ferite

uses "console";  Console.println("Hello, world!"); 

[edit]filePro

 @once:    mesgbox "Hello, world!" ; exit 

[edit]Fjölnir

"halló" <>    stef(;)    stofn        skrifastreng(;"Halló, veröld!"),    stofnlok } * "GRUNNUR" ; 

[edit]FOCAL

type "Hello, world!",! 

or

t "Hello, world!",! 

[edit]Focus

-TYPE Hellomello, world! 

[edit]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; 

[edit]Forth

: HELLO  ( -- )  ." Hello, world!" CR ;   HELLO 

or instead of compiling a new routine, one can type directly in the Forth interpreter console

 CR ." Hello, world!" CR 

[edit]Fortran

   program hello      print*, 'Hello, world!'    end 

[edit]FreeBasic

 PRINT "Hello World"  SLEEP  END 

[edit]Fril

 ?((pp "Hello, world!"))      

or

pp "Hello, world!" 

[edit]Frink

println["Hello, world!"] 

[edit]Gambas

See also GUI section.

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

[edit]GEMBase 4GL

procedure_form hello   begin_block world       print "Hello, world!"   end_block end_form 

[edit]GO (from google)

package main  import "fmt"  func main() {   fmt.Printf("Hello, world!") } 

[edit]Groovy

println "Hello, world!" 

[edit]GML (Game Maker Language)

In the draw event of some object:

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

Or to show a splash screen message:

show_message("Hello, world!") 

[edit]GraalScript 1

 if (created) {    echo Hello, world!;  } 

[edit]GraalScript 2

 function onCreated() {    echo("Hello, world!");  } 

[edit]Harbour

? "Hello, world!" 

or

@1,1 say "Hello, world!" 

or

Qout("Hello, world") 

[edit]Haskell

main = putStrLn "Hello, world!" 

[edit]haXe

class HelloWorldApp {     static function main()     {         trace("Hello, world!");     } } 

[edit]Heron

program HelloWorld; functions {   _main() {     print_string("Hello, world!");   } } end 

[edit]HP 33s

(Handheld Hewlett-Packard RPN-based scientific calculator.)

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 

[edit]HP-41 & HP-42S

(Handheld Hewlett-Packard RPN-based alphanumeric engineering calculators.)

01 LBLTHELLO  02 THello, world!  03 PROMPT 

HP-41 output

[edit]HyperTalk (Apple HyperCard's scripting programming language)

put "Hello, world!" 

or

Answer "Hello, world!" 

[edit]IDL

print,"Hello, world!" 

[edit]Inform 5/6

[ Main;   "Hello, world!"; ]; 

[edit]Inform 7

Hello World is a room.  The printed name is "Hello, world!" 

[edit]Io

"Hello, world!" println 

or

writeln("Hello, world!") 

[edit]Iptscrae

ON ENTER {     "Hello, " "world!" & SAY } 

[edit]J

 '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 

[edit]Jal

 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 = "!" 

[edit]Java

See also GUI section.

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

[edit]Java byte-code

(disassembler output of javap -c HelloWorld)

public class HelloWorld extends java.lang.Object{ public HelloWorld();  Code:   0:   aload_0   1:   invokespecial   #1; //Method java/lang/Object."":()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 } 

[edit]JavaFX

JavaFX is scripting language formerly called F3 for Form Follows Function

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

This program can also be written in this way:

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; 

A simple console output version would be:

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

Or even simpler (with a built-in function):

println("Hello World"); 

[edit]JavaScript

JavaScript does not have native (built in) input or output routines. Instead it relies on the facilities provided by its host environment.

Using a standard Web browser's document object

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

or with an alert, using a standard Web browser's window object (window.alert)

alert('Hello, world!'); 

or, from the Mozilla command line implementation

print('Hello, world!'); 

or, from the Windows Script Host

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

[edit]JSP

<%@ page contentType="text/html;charset=WINDOWS-1252"%>              <% out.println(" Hello, world!"); %>      

or just

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

or literally

 Hello, world! 

[edit]Joy

"Hello, world!\n" putchars . 

[edit]K

`0:"Hello, world!\n" 

[edit]Kogut

WriteLine "Hello, world!" 

[edit]KPL (Kids Programming Language)

Program HelloWorld    Method Main()       ShowConsole()       ConsoleWriteLine("Hello, world!")    End Method End Program 

[edit]Lasso

Output: 'Hello, world!'; 

or

Output('Hello, world!'); 

or simply

'Hello, world!'; 

[edit]Lexico Mobile (in spanish)

tarea muestre "Hola mundo !" 

or

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

[edit]Limbo

implement Command;  include "sys.m"     sys: Sys;  include "draw.m";  include "sh.m";  init(nil: ref Draw->Context, nil: list of string) {     sys = load Sys Sys->PATH;     sys->print("Hello, world!!\n"); } 

[edit]Linden Scripting Language

Linden Scripting Language is the scripting language used within Second Life

default {     state_entry()     {         llSetText("Hello, World!" , <0,0,0> , 1.0);         //or...         llSay(0,"Hello, World!");     } } 

[edit]Linotte

Livre : HelloWorld  Paragraphe : Affichage  Actions :    "Hello, World !" ! 

[edit]Lisaac

Section Header   + name := HELLO_WORLD_PROGRAM;   Section Public   - main <-   (     "Hello world!\n".print;   ); 

[edit]Lisp

Lisp has many dialects that have appeared over its almost fifty-year history.

[edit]Common Lisp

(format t "Hello, world!~%") 

or

(write-line "Hello, world!") 

or in the REPL:

"Hello, world!" 

(As a string (enclosed in quotes) it evaluates to itself, so is printed.)

[edit]Scheme

(display "Hello, world!\n") 

[edit]Clojure

(println "Hello, world!") 

[edit]Emacs Lisp

(print "Hello, world!") 

or:

(message "Hello, world!") 

[edit]AutoLisp

(print "Hello, world!") 

[edit]XLISP

(print "Hello, world!") 

[edit]Arc

(prn "Hello, world!") 

[edit]

print [Hello, world!] 

or

pr [Hello, world!] 

In mswlogo only

messagebox [Hi] [Hello, world!] 

[edit]LPC

 void create()  {      write("Hello, world!\n");  } 

[edit]Lua

io.write("Hello, world!\n") 

or

return "Hello, World!" 

or

print("Hello, world") 


[edit]LuaPSP

screen:print(1,1,"Hello, world!") screen:flip() 

[edit]Neko

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

[edit]M (MUMPS)

W "Hello, world!" 

[edit]Caché Server Pages (CSP)

Class Test.Hello Extends %CSP.Page [ ProcedureBlock ] {    ClassMethod OnPage() As %Status    {        &html<                        >        Write "Hello, world!",!        &html<        >        Quit $$$OK    } } 

[edit]M# Fictional Computer Language

[edit]Script

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   // } 

[edit]Command WI

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

[edit]Command WoI

# @ Write([byte]{0048, 0065, 006C, 006C, 006F, 002C, 0058, 006F, 0072, 006C, 0064}) 

[edit]M4

Hello, world! 

[edit]Macsyma, Maxima

print("Hello, world!")$ 

[edit]Maple

print("Hello, world!"); 

[edit]Mathematica

Print["Hello, world!"] 

or simply:

"Hello, world!" 

[edit]MATLAB

disp('Hello, world!') 

or

fprintf('Hello, world!') 

or with a GUI

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

or

msgbox('Hello World!') 

[edit]Maude

fmod HELLOWORLD is protecting STRING .   op helloworld : -> String .   eq helloworld = "Hello, world!" . endfm red helloworld . 

[edit]Max

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; 

[edit]Maya Embedded Language

print( "Hello, world!\n" ); 

[edit]Mesham

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]; } 

[edit]mIRC Script (aliases)

helloworld echo Hello, world! 

[edit]mIRC Script (remote)

alias helloworld echo Hello, world! 

[edit]mIRC Script (popups)

Hello World:echo Hello, world! 

[edit]mIRC Script (command line)

/echo Hello, world! 

or

//echo Hello, world! 

[edit]Model 204

BEGIN PRINT 'Hello, world!' END 

[edit]Modula-2

MODULE Hello;  FROM InOut IMPORT WriteLn, WriteString;  BEGIN    WriteString ("Hello, world!");    WriteLn END Hello. 

[edit]MOO

This requires that you be the player or a wizard:

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

This is specific to the implementation of the core used for the moo, but works on most well known moos, such as LambdaCore or JH-Core:

player:tell("Hello, world!"); 

[edit]Mouse

"Hello, World!" $ 

[edit]MS-DOS batch

(with the standard command.com interpreter. The @ symbol is optional and prevents the system from repeating the command before executing it. The @ symbol must be omitted on versions of MS-DOS prior to 3.0.). It's very common for batchfiles to start with two lines of "@echo off" and "cls".

 @echo Hello, world! 

For MS-DOS 3.0 or lower

echo off cls echo Hello, world! 

[edit]MUF

: main   me @ "Hello, world!" notify ; 

[edit]Natural

WRITE 'Hello, world!' END 

or

WRITE 'Hello, world!'. 

[edit]Nemerle

The easiest way to get Nemerle print "Hello, world!" would be that:

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

however, in bigger applications the following code would be probably more useful:

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

[edit]Oberon

Oberon is both the name of a programming language and an operating system.

Program written for the Oberon operating system:

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. 

Freestanding Oberon program using the standard Oakwood library:

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

[edit]Contd....

No comments:

Post a Comment