Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Hello world - computer screen version

Status
Not open for further replies.

Inquisitive

Super Moderator
Hello everyone,

Just an idea I thought might be interesting. How many different computer languages can we represent with just a simple "Hello World"

The criteria here is output must be to the computer monitor and as simple as possible.

The purpose is to show the subtle and not so subtle differences between the various computer languages available today.

Example Python 2.7

Save text file as hw.py

Contents of hw.py

Python:
print "Hello World!"

To execute this file at a terminal window prompt, type - python hw.py

Note: Python language must be installed on computer for this to work.
 
Last edited by a moderator:
Forth

One line is needed to define the world HELLO.

When we type HELLO followed by a CR the computer will respond with "Hello World". The computer output is in italics.

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

HELLO <cr>
Hello, world!
Or you can do it interactively

" Hello, world!" <cr>
Hello, world!
Note: The Forth language must be installed on computer for this to work.

Forth was a great language because you could write and test you code on the target without anything but a serial port. This was back when emulators cost thousands and rom monitors hundreds. Still a great language but I use c.
 
Last edited:
Lisp

Lisp along with prolog were the two main languages use for artificial intelligence research.

Code:
;;; HWorld.lsp

;;; ================================================== ;;;
;;; =========== HELLO WORLD SIMULATION ============== ;;;
;;; ================================================== ;;;
;;; This function simply returns the string Hello World that is in quotes.

(DEFUN HELLO ()
  "HELLO WORLD"
)



I think by now we can see that this is not a very interesting program in most if not all languages. The main use of HELLO WORLD programs is to prove that one has the compiler or interpreter working. That you can build and run a program.
 
Last edited by a moderator:
Java 1.7


Java:
//    Program name:    hw.java
//    Text-printing program

public class hw
{
    // main method begins execution of Java application
    public static void main(String[] args)
    {
        System.out.println("Hello World!");
    }    //    end method main
}    //    end class hw
 
Last edited by a moderator:
6502 on Apple II

Code:
  1 ;PROGRAM TO PRINT "HELLO WORLD!"
  2 ;ON THE SCREEN
  3 ;WRITTEN ON: today
  4 ;
  5 HOME    EQU $FC58
  6 COUT    EQU $FDED
  7          ORG $300
  8 MAIN:
  9          JSR HOME            ;CLEAR SCREEN
  10          LDY #00
  11 REPEAT  LDA MESSAGE,Y
  12          BEQ EXIT
  13          JSR COUT
  14          INY
  15          JMP REPEAT
  16 EXIT    RTS
  17 MESSAGE  ASC "HELLO WORLD!"
  18          HEX 00
  19          END
 
Moo:
Code:
@program hello:run
player:tell("Hello world!");
.

Cow:
Code:
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MoO MoO MoO MoO MoO MoO MoO Moo Moo MoO MoO MoO Moo OOO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo Moo MOo MOo MOo MOo MOo MOo MOo MOo Moo MoO MoO MoO Moo MOo MOo MOo MOo MOo MOo Moo MOo MOo MOo MOo MOo MOo MOo MOo Moo OOO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo
 
VB6
Code:
Private Sub Form_Load()
    Form1.Show
    Print "Hello World!"
End Sub

Produces,

Form1.png


Mike.
 
Last edited by a moderator:
quickbasic:

Code:
CLS : PRINT "HELLO WORLD"; DO WHILE INKEY$="":LOOP:END
`

this clears the screen, prints HELLO WORLD, and waits for a key press before terminating, because usually with the Qbasic interpreter, you go back to the editor screen as soon as the program finishes....

most M$ versions of basic have the ability to write "one-liners". back in the day, i used to drive Radio Shack sales people crazy with a "one-liner-of-death" that would run on the TRS-80 Color Computer. the BASIC code was stored as tokens near the top of RAM, and the video RAM was somewhere just below that, so the following "one-liner" would start at the bottom oF RAM, and fill it with random characters, until it first overwrote the video display with garbage, and then the program would overwrite itself, and the CoCo would lock up:
Code:
FOR X=0 TO 65535 : POKE X(INT(RND*255)) : NEXT X
 
Last edited:
GNU C

C:
#include <stdio.h>

int main(int argc, char *argv[])
{
    puts("Hello World!");

    return 0;
}
 
Last edited:
C:
#include "stdio.h"
#define e 3
#define g (e/e)
#define h ((g+e)/2)
#define f (e-g-h)
#define j (e*e-g)
#define k (j-h)
#define l(x) tab2[x]/h
#define m(n,a) ((n&(a))==(a))

long tab1[]={ 989L,5L,26L,0L,88319L,123L,0L,9367L };
int tab2[]={ 4,6,10,14,22,26,34,38,46,58,62,74,82,86 };

main(m1,s) char *s; {
    int a,b,c,d,o[k],n=(int)s;
    if(m1==1){ char b[2*j+f-g]; main(l(h+e)+h+e,b); printf(b); }
    else switch(m1-=h){
        case f:
            a=(b=(c=(d=g)<<g)<<g)<<g;
            return(m(n,a|c)|m(n,b)|m(n,a|d)|m(n,c|d));
        case h:
            for(a=f;a<j;++a)if(tab1[a]&&!(tab1[a]%((long)l(n))))return(a);
        case g:
            if(n<h)return(g);
            if(n<j){n-=g;c='D';o[f]=h;o[g]=f;}
            else{c='\r'-'\b';n-=j-g;o[f]=o[g]=g;}
            if((b=n)>=e)for(b=g<<g;b<n;++b)o[b]=o[b-h]+o[b-g]+c;
            return(o[b-g]%n+k-h);
        default:
            if(m1-=e) main(m1-g+e+h,s+g); else *(s+g)=f;
            for(*s=a=f;a<e;) *s=(*s<<e)|main(h+a++,(char *)m1);
        }
}
 
If you want simple, you may like the "whitespace" language.. because there is nothing to look at. Something that looks simple is not simple. When the OP asked for a simple "hello world", that is a good challenge. Simple code requires a very complicated compiler (on modern computers/processors).
Whitespace_in_vim2.png
 
Pic Basic Pro

Code:
'****************************************************************
'*  Name  : Hello World.BAS                                                                   
'*  Author  : Mike2545                                                                               
'*  Notice  : Copyright (c) 2013 under penalty of death                      
'*  : All Rights Reserved                                                                            
'*  Date  : 10/6/2013
'* Version  : 1.0                                                                         
'*  Notes  :                                                                                                   
'*  :                                                                                                               
'****************************************************************
' Example program to display "hello world" on the serial debug screen
' Pic Basic is a derivitive of the Basic Stamp

  INCLUDE "modedefs.bas"
  INCLUDE "ALLDIGITAL.pbp"

  OSCCON =$60 'clock speed
  DEFINE OSC 4
  DEFINE DEBUG_REG PORTB  ' Set Debug pin bit
  DEFINE DEBUG_BIT 4
  DEFINE DEBUG_BAUD 2400
  DEFINE DEBUG_MODE 1 ' Set Debug mode: 0 = true, 1 = inverted

  Debug "Hello World"
 
Last edited by a moderator:
Code:
' Hello World for AmigaBASIC
PRINT "Hello world!"

And this is the speech synthesis version:
Code:
SAY TRANSLATE$ ("HELLO WORLD")
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top