Home > Projects > Hello World



Forth


Forth is an unusual computer language that has probably been applied to more varied projects than any other. Forth was created for small embedded control mini- and micro-computers. It has also been used in a wide variety of applications Programming in Forth is more of an “art” than programming in any other language. Like painters drawing brushstrokes, Forth programmers have complete control over where they are going and how they will get there.


According to J.V. Noble, "It has also been called '...one of the best-kept secrets in the computing world.' This is no exaggeration: large corporations have purchased professional Forth development systems from vendors such as Laboratory Microsystems, Inc., Forth, Inc. or MicroProcessor Engineering, Ltd. and sworn them to secrecy.

Some speculate (unkindly) that corporate giants prefer to hide their shame at using Forth; but I believe they are actually concealing a secret weapon from their rivals."


Displaying "Hello, World!" in Forth is simple.

Win32Forth 6.15.04 was used in the examples:

.( Hello World!) CR

Or slightly more interesting:

s" Hello, World!" MsgBox CR

This displays a message box.



Hello World Variation

This example uses a file named HelloWorld.f

The file is loaded from the Win32Forth Console Window.


Forth is an interactive programming language consisting entirely of subroutines, called words in Forth jargon.


To create the file, first define a (subroutine) word HASH to display a single #, whose ASCII character code is 35.

Next define a word SPAC to display a single white space whose ASCII character code is 32.

The rest defines ASCII lettering, which will be displayed on the screen.

: HASH	 ( -- )   
   35 EMIT ;
: SPAC	 ( -- ) 
   32 EMIT ; CR

HASH SPAC SPAC SPAC HASH SPAC HASH HASH HASH HASH HASH SPAC HASH SPAC SPAC SPAC SPAC SPAC HASH SPAC SPAC SPAC SPAC SPAC SPAC HASH HASH HASH SPAC SPAC SPAC SPAC SPAC HASH SPAC SPAC SPAC SPAC SPAC SPAC SPAC HASH SPAC SPAC HASH HASH HASH SPAC SPAC HASH HASH HASH HASH SPAC SPAC HASH SPAC SPAC SPAC SPAC SPAC HASH HASH HASH HASH SPAC SPAC SPAC HASH CR
HASH SPAC SPAC SPAC HASH SPAC HASH SPAC SPAC SPAC SPAC SPAC HASH SPAC SPAC SPAC SPAC SPAC HASH SPAC SPAC SPAC SPAC SPAC HASH SPAC SPAC SPAC HASH SPAC SPAC SPAC SPAC HASH SPAC SPAC SPAC HASH SPAC SPAC SPAC HASH SPAC HASH SPAC SPAC SPAC HASH SPAC HASH SPAC SPAC SPAC HASH SPAC HASH SPAC SPAC SPAC SPAC SPAC HASH SPAC SPAC SPAC HASH SPAC SPAC HASH CR
HASH HASH HASH HASH HASH SPAC HASH HASH HASH HASH HASH SPAC HASH SPAC SPAC SPAC SPAC SPAC HASH SPAC SPAC SPAC SPAC SPAC HASH SPAC SPAC SPAC HASH SPAC SPAC SPAC SPAC HASH SPAC SPAC SPAC HASH SPAC SPAC SPAC HASH SPAC HASH SPAC SPAC SPAC HASH SPAC HASH HASH HASH HASH SPAC SPAC HASH SPAC SPAC SPAC SPAC SPAC HASH SPAC SPAC SPAC HASH SPAC SPAC HASH CR
HASH SPAC SPAC SPAC HASH SPAC HASH SPAC SPAC SPAC SPAC SPAC HASH SPAC SPAC SPAC SPAC SPAC HASH SPAC SPAC SPAC SPAC SPAC HASH SPAC SPAC SPAC HASH SPAC SPAC SPAC SPAC SPAC HASH SPAC SPAC HASH SPAC SPAC HASH SPAC SPAC HASH SPAC SPAC SPAC HASH SPAC HASH SPAC SPAC HASH SPAC SPAC HASH SPAC SPAC SPAC SPAC SPAC HASH SPAC SPAC SPAC HASH SPAC SPAC SPAC CR
HASH SPAC SPAC SPAC HASH SPAC HASH HASH HASH HASH HASH SPAC HASH HASH HASH HASH HASH SPAC HASH HASH HASH HASH HASH SPAC SPAC HASH HASH HASH SPAC SPAC HASH SPAC SPAC SPAC SPAC HASH SPAC SPAC HASH SPAC SPAC SPAC SPAC SPAC HASH HASH HASH SPAC SPAC HASH SPAC SPAC SPAC HASH SPAC HASH HASH HASH HASH HASH SPAC HASH HASH HASH HASH SPAC SPAC SPAC HASH CR
SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC HASH SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC SPAC CR

Once the file has been loaded. This is the resulting screen:


Win32Forth: a 32 Bit Forth for Windows 95/98/ME/NT4/W2K/XP/VISTA/W7/W8/W10

Version: 6.15.04 Build: 4


Current directory is: C:\Win32Forth

Program path is: C:\Win32Forth\Win32for.exe

Forth path is: C:\Win32Forth\

Application path is: not set


System Editor is: Win32Forth IDE


FLOAD 'C:\Win32Forth\demos\HelloWorld.f'

#   # ##### #     #      ###     #       #  ###  ####  #     ####   #

#   # #     #     #     #   #    #   #   # #   # #   # #     #   #  #

##### ##### #     #     #   #    #   #   # #   # ####  #     #   #  #

#   # #     #     #     #   #     #  #  #  #   # #  #  #     #   #   

#   # ##### ##### #####  ###  #    #  #     ###  #   # ##### ####   #

                             #                                       

ok