DeeBG wrote:And just for any sadist out there who wants more, Wikipedia provides a good list of "Hello World" examples from an even wider sampling of languages here.

goose wrote:but who the hell uses those??

thebeast wrote:Nice one to read is very interesting how to program in different languages Hello WorldIn this year of study i'll learn how to program in Assembler becouse i'll must prepeare a course project whit some microprocessor which is programable whit assembler



mm_freak wrote:So DOS keeps being dead. =D
goncalopp wrote:Although HTML is a language, I don't think it is considered a programming language. You can't make programs with HTML (please correct me if I'm wrong, I'm not an "HTML programmer")
no, that means I fit around you and you fit in me.

hawking wrote:Hello World is the first programme one writes when learning a new language.
Below is a list of Hello World programmes:
I am sure this is helpful for comparing different programming languages.
~~~~~~~~~~
Ada
with Ada.Text_IO;
procedure Hello_World is
begin
Ada.Text_IO.Put_Line ("Hello World!");
end Hello_World;
[edit]
AppleScript
display dialog "Hello World!"
~~~~~~~~~~
ASP
response.write "Hello World!"
~~~~~~~~~~
Assembler (DOS)
.MODEL SMALL
.DATA
HWRLD DB "Hello world!$"
.CODE
MOV AX,@DATA
MOV DS,AX
MOV DX,OFFSET HWRLD
MOV AH,09H
INT 21H
POP DX
POP AX
MOV AH,4CH
INT 21H
END
~~~~~~~~~~
BASIC (ANSI) (Also works in FoxPro)
?"Hello World!"
~~~~~~~~~~
BCPL
GET "LIBHDR"
LET START() BE WRITES("Hello, World")
~~~~~~~~~~
C (ANSI)
#include <stdio.h>
int main() {
printf("Hello World!\n");
return 0;
}
~~~~~~~~~~
C#
using System;
namespace HelloWorld
{
public class HelloWorld {
static void Main() {
Console.WriteLine("Hello World!");
}
}
}
~~~~~~~~~~
C++
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
~~~~~~~~~~
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.
~~~~~~~~~~
DOS batch file
echo Hello World!
~~~~~~~~~~
D (DTrace)
#!/usr/sbin/dtrace -qs
BEGIN
{
trace("Hello World!");
exit(0);
}
~~~~~~~~~~
Fortran
WRITE (*,*) "Hello World!"
~~~~~~~~~~
Haskell
print "Hello World!"
~~~~~~~~~~
HTML
<html>
<head><title>Hello world</title></head>
<body>
Hello world
</body>
</html>
~~~~~~~~~~
Java
public class HelloWorld {
public static void main( String[] args ) {
System.out.println( "Hello World!" );
}
}
~~~~~~~~~~
Java Script
<script type="text/javascript">
window.alert("Hello World!");
</script>
~~~~~~~~~~
JSP
<%= "Hello World!" %>
~~~~~~~~~~
Lisp
(DEFUN HELLO-WORLD ()
(PRINT (LIST 'Hello 'World!)))
[edit]
Objective-C
#import <objc/objc.h>
int main (int arg, char **args) {
NSLog(@"Hello World!");
return 0;
}
~~~~~~~~~~
Parrot Assembler
print "Hello World!\n"
end
~~~~~~~~~~
Pascal
Begin
Writeln('Hello World!');
End.
~~~~~~~~~~
Perl
#!/usr/bin/perl
print "Hello World!\n";
[edit]
PHP
<?php
echo "Hello World!\n";
?>
~~~~~~~~~~
Python
#!/usr/bin/env python
print "Hello World!"
~~~~~~~~~~
QuickBASIC
PRINT "Hello World!"
~~~~~~~~~~
Ruby
#!/usr/bin/ruby
puts "Hello World!"
~~~~~~~~~~
Scheme
(display "Hello World")
(newline)
~~~~~~~~~~
Shell script (Bourne)
#!/bin/sh
echo 'Hello World!'
~~~~~~~~~~
Shell script (C)
#!/bin/csh
echo 'Hello World!'
~~~~~~~~~~
SPARK
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;
~~~~~~~~~~
Tcl
#!/usr/bin/tclsh
puts "Hello World!"
~~~~~~~~~~
TI BASIC
isp "Hello, World"
or
:ClrHome
isp "Hello, World"ause
:ClrHome
:Output(1,1,"")
or even
:ClrHome
:Output(1,1,"Hello, World")ause
:ClrHome
:Output(1,1,"")
~~~~~~~~~~
Tk
#!/usr/bin/wish
frame .top -borderwidth 10
pack .top -fill x
label .top.hi -text "Hello World!"
pack .top.hi -side left -padx 0p -pady 0
~~~~~~~~~~
Visual Basic
VBA.Interaction.MsgBox "Hello World!"
~~~~~~~~~~
Windows 32-bit Assembly
MASM:
.data
szHello db "Hello World",0
.code
push 0
push 0
push offset szHello
push offset szHello
push 0
call MessageBoxA
call ExitProcess
end
~~~~~~~~~~

DATAP: EQU #98 ; VDP Data port #98 works on all MSX models
; (TMS9918/TMS9929/V9938 or V9958)
; #80 works on SVI
; (for other platforms you have to figure this out by your self)
CMDP: EQU #99 ; VDP Command port #99 works on all MSX models
; (TMS9918/TMS9929/V9938 or V9958)
; #81 works on SVI
; (for other platforms you have to figure this out by your self)
;-----------------------------------------------------------------------
; Program starts here:
ORG 0 ; Z80 starts always from here when power is turned on
DI ; We don't know, how interrupts works in this system, so we disable them.
; Let's set VDP write address to #0000
XOR A
OUT (CMDP),A
LD A,#40
OUT (CMDP),A
; Now let's clear first 16Kb of VDP memory
LD B,0
LD HL,#3FFF
LD C,DATAP
CLEAR:
OUT (C),B
DEC HL
LD A,H
OR L
NOP ; Let's wait 8 clock cycles just in case VDP is not quick enough.
NOP
JR NZ,CLEAR
; Now it is time to set up VDP registers:
;----------------------------------------
; Register 0 to #0
;
; Set mode selection bit M3 (maybe also M4 & M5) to zero and
; disable external video & horizontal interrupt
LD C,CMDP
LD E,#80
OUT (C),A
OUT (C),E
;----------------------------------------
; Register 1 to #50
;
; Select 40 column mode, enable screen and disable vertical interrupt
LD A,#50
INC E
OUT (C),A
OUT (C),E
;----------------------------------------
; Register 2 to #0
;
; Set pattern name table to #0000
XOR A
INC E
OUT (C),A
OUT (C),E
;----------------------------------------
; Register 3 is ignored as 40 column mode does not need color table
;
INC E
;----------------------------------------
; Register 4 to #1
; Set pattern generator table to #800
INC A
INC E
OUT (C),A
OUT (C),E
;----------------------------------------
; Registers 5 (Sprite attribute) & 6 (Sprite pattern) are ignored
; as 40 column mode does not have sprites
INC E
INC E
;----------------------------------------
; Register 7 to #F0
; Set colors to white on black
LD A,#F0
INC E
OUT (C),A
OUT (C),E
;----------------------------------------
; Let's set VDP write address to #808 so, that we can write
; character set to memory
; (No need to write SPACE it is clear char already)
LD A,8
OUT (C),A
LD A,#48
OUT (C),A
; Let's copy character set
LD HL,CHARS
LD B, CHARS_END-CHARS
COPYCHARS:
LD A,(HL)
OUT (DATAP),A
INC HL
NOP ; Let's wait 8 clock cycles just in case VDP is not quick enough.
NOP
DJNZ COPYCHARS
; Let's set write address to start of name table
XOR A
OUT (C),A
LD A,#40
OUT (C),A
; Let's put characters to screen
LD HL,ORDER
LD B,ORDER_END-ORDER
COPYORDER:
LD A,(HL)
OUT (DATAP),A
INC HL
JR OVERNMI
NOP
NOP
; Here is address #66, that is entry for NMI
RETN ;Return from NMI
OVERNMI:
DJNZ COPYORDER
; The end
HALT
; Character set:
; --------------
ORDER:
DEFB 1,2,3,3,4,0,5,4,6,3,7
ORDER_END:
CHARS:
; H
DEFB %10001000
DEFB %10001000
DEFB %10001000
DEFB %11111000
DEFB %10001000
DEFB %10001000
DEFB %10001000
DEFB %00000000
; e
DEFB %00000000
DEFB %00000000
DEFB %01110000
DEFB %10001000
DEFB %11111000
DEFB %10000000
DEFB %01110000
DEFB %00000000
; l
DEFB %01100000
DEFB %00100000
DEFB %00100000
DEFB %00100000
DEFB %00100000
DEFB %00100000
DEFB %01110000
DEFB %00000000
; o
DEFB %00000000
DEFB %00000000
DEFB %01110000
DEFB %10001000
DEFB %10001000
DEFB %10001000
DEFB %01110000
DEFB %00000000
; W
DEFB %10001000
DEFB %10001000
DEFB %10001000
DEFB %10101000
DEFB %10101000
DEFB %11011000
DEFB %10001000
DEFB %00000000
; r
DEFB %00000000
DEFB %00000000
DEFB %10110000
DEFB %11001000
DEFB %10000000
DEFB %10000000
DEFB %10000000
DEFB %00000000
; d
DEFB %00001000
DEFB %00001000
DEFB %01101000
DEFB %10011000
DEFB %10001000
DEFB %10011000
DEFB %01101000
DEFB %00000000
chars_end:

Users browsing this forum: No registered users and 2 guests