Hello World

Hello World monella kielellä

 

6502

; Uses S-C Assembler variant.
; .or is origin
; .as is ASCII String
; .hs is Hex String
        .or $300
main    ldy #$00
.1      lda str,y
        beq .2
        jsr $fded ; ROM routine, COUT, y is preserved
        iny
        bne .1
.2      rts
str     .as "HELLO WORLD"
        .hs 0D00

 

Assembly (NASM)

section	.text
    global _start   ;must be declared for linker (ld)
_start:	            ;tells linker entry point
    mov	edx,len     ;message length
    mov	ecx,msg     ;message to write
    mov	ebx,1       ;file descriptor (stdout)
    mov	eax,4       ;system call number (sys_write)
    int	0x80        ;call kernel
	
    mov	eax,1       ;system call number (sys_exit)
    int	0x80        ;call kernel

section	.data
msg db 'Hello, world!', 0xa  ; string
len equ $ - msg     ;length of string

 

C

#include <stdio.h> 
main() { 
  printf("Hello World\n");
}

 

C#

using System; 
class HelloWorld { 
  static void Main() 
  { Console.WriteLine("Hello World"); } 
}

 

C++

#include <stdio.h> 
void main() { 
  printf("Hello World\n");
}

 

Cobol

000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID.     HELLOWORLD.
000300
000400*
000500 ENVIRONMENT DIVISION.
000600 CONFIGURATION SECTION.
000700 SOURCE-COMPUTER. RM-COBOL.
000800 OBJECT-COMPUTER. RM-COBOL.
000900
001000 DATA DIVISION.
001100 FILE SECTION.
001200
100000 PROCEDURE DIVISION.
100100
100200 MAIN-LOGIC SECTION.
100300 BEGIN.
100400     DISPLAY " " LINE 1 POSITION 1 ERASE EOS.
100500     DISPLAY "Hello world!" LINE 15 POSITION 10.
100600     STOP RUN.
100700 MAIN-LOGIC-EXIT.
100800     EXIT.

 

Java & Java Applet

public class HelloWorld {

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

}

/* Applet */

import java.applet.Applet;
import java.awt.Graphics;

public class HelloWorld extends Applet {
	public void paint(Graphics g) {
		g.drawString("Hello world!", 50, 25);
	}
}

 

PHP

echo "Hello World\n";

 

Perl

print "Hello World\n";

 

sh, bash

echo Hello World

 

JavaScript & Inline HTML

<script type="text/javascript">
<!-- to hide script contents from old browsers
  document.write("Hello World!")
// end hiding contents from old browsers  -->
</script>


<!DOCTYPE HTML>
<html>
<body>
 
  <p>Header</p>
 
  <script>
    alert('Hello, World!')
  </script>
 
  <p>Footer</p>
 
</body>
</html>