Hello, world!


2022-01-01

in C:

#include <stdio.h>

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

in Assembler (6502):

100D LDA #$48
100F JSR $FFD2
1012 LDA #$45
1014 JSR $FFD2
1017 LDA #$4C
1019 JSR $FFD2
101C LDA #$4C
101E JSR $FFD2
1021 LDA #$4F
1023 JSR $FFD2
1026 LDA #$2C
1028 JSR $FFD2
102B LDA #$57
102D JSR $FFD2
1030 LDA #$4F
1032 JSR $FFD2
1035 LDA #$52
1037 JSR $FFD2
103A LDA #$4C
103C JSR $FFD2
103F LDA #$44
1041 JSR $FFD2
1044 LDA #$21
1046 JSR $FFD2
1049 RTS

in C#:

using System;

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

in C++:

#include <iostream>

int main() {
    std::cout << "Hello, world!" << endl;
    return 0;
}

in Pascal:

program HelloWorld;

begin
    writeln('Hello, world!');
end.

in Perl:

print "Hello, world!\n"

in BASIC:

10 PRINT "Hello, world!"
20 END

in 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.

in FORTRAN:

program main
    implicit none
    write ( *, '(a)' ) '  Hello, world!'
    stop
    end

in Ada:

procedure Hello is
    begin
        Put_Line ("Hello, world!");
    end Hello;

in ColdFusion:

<cfset msg = "Hello, world!">
<cfoutput>#msg#</cfoutput>

or

<cfscript>
    WriteOutput("Hello, world!");
</cfscript>

in Java:

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

in JavaScript:

alert("Hello, world!");

or

document.writeln("Hello, world!");

in PHP:

<?php echo "Hello, world!"; ?>

My name is Rick Towns and I am an amateur astronomer and computer programmer from Canada. This is a collection of interesting posts I've gathered over the years.