Table of Contents
In this article, I will take you through the steps to install gforth on Ubuntu 20.04 LTS (Focal Fossa). Gforth is a free, fast and portable implementation of the Forth Programming Language for Linux, Unix, Windows and other operating systems. Gforth uses GCC to compile a fast direct or indirect threaded Forth; Gforth is fully ANS FORTH compliant. More on Official website.
What is Forth Programming Language
Forth is a stack based procedural programming language designed by Charles H. "Chuck" Moore during 1970s. It is mostly used to design and develop real time applications based on embedded hardware and architecture. Most common applications include instrumentation and control applications of a spacecraft.
How to Install gforth on Ubuntu 20.04 LTS (Focal Fossa)
Step 1: Prerequisites
a) You should have a running
Ubuntu 20.04 LTS Server.
b) You should have
root access to run privileged command.
c) You should have
apt utility available in your Server.
Step 2: Update Your Server
To sync your System with all the latest available updates from Ubuntu and all other enabled repositories, you can use apt update command as shown below. In the case any of the packages needs to be upgraded, then you can run
apt upgrade command as well.
root@cyberithub:~# apt update Hit:2 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu focal InRelease Hit:3 http://ppa.launchpad.net/nilarimogard/webupd8/ubuntu focal InRelease Get:4 https://repo.protonvpn.com/debian stable InRelease [2,519 B] Hit:1 https://downloads.apache.org/cassandra/debian 40x InRelease Hit:5 http://in.archive.ubuntu.com/ubuntu focal InRelease Hit:6 https://dl.google.com/linux/chrome/deb stable InRelease Get:7 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB] Hit:8 http://apt.postgresql.org/pub/repos/apt focal-pgdg InRelease Hit:9 http://download.opensuse.org/repositories/home:/selmf/xUbuntu_20.04 InRelease Get:10 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB] Get:11 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB] Get:12 http://in.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages [635 kB] Get:13 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1,746 kB] Get:14 http://in.archive.ubuntu.com/ubuntu focal-updates/main Translation-en [325 kB]
Step 3: Install gforth
In the next step you can install gforth from default Ubuntu repo using
apt install gforth command as shown below. This will download and install gforth package along with all its dependencies.
root@cyberithub:~# apt install gforth Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: gforth-common gforth-lib The following NEW packages will be installed: gforth gforth-common gforth-lib 0 upgraded, 3 newly installed, 0 to remove and 17 not upgraded. Need to get 533 kB of archives. After this operation, 2,980 kB of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 http://in.archive.ubuntu.com/ubuntu focal/universe amd64 gforth-common all 0.7.3+dfsg-9build2 [315 kB] Get:2 http://in.archive.ubuntu.com/ubuntu focal/universe amd64 gforth-lib amd64 0.7.3+dfsg-9build2 [105 kB] Get:3 http://in.archive.ubuntu.com/ubuntu focal/universe amd64 gforth amd64 0.7.3+dfsg-9build2 [113 kB] Fetched 533 kB in 1s (583 kB/s) Selecting previously unselected package gforth-common. (Reading database ... 205954 files and directories currently installed.) Preparing to unpack .../gforth-common_0.7.3+dfsg-9build2_all.deb ... ..............................................
Step 4: Check Version
After successful installation, you can check the current installed version by using
gforth --version command as shown below.
root@cyberithub:~# gforth --version gforth 0.7.3
Step 5: Run a Sample Program
It is time to write a sample program and test it. You can start the gforth shell by running
gforth command as shown below. Then write below 4 line of code and test it by writing
ALOHA. If you see
Hello ok then our program is working as expected. You can type
bye to exit the shell.
root@cyberithub:~# gforth Gforth 0.7.3, Copyright (C) 1995-2008 Free Software Foundation, Inc. Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license' Type `bye' to exit ( 1 ) : HELLO ." Hello " ; ok ( 2 ) : GOODBYE ." Goodbye " ; ok ( 3 ) VARIABLE 'aloha ' HELLO 'aloha ! ok ( 4 ) : ALOHA 'aloha @ EXECUTE ; ok ALOHA Hello ok
Step 6: Uninstall gforth
Once you are done using gforth, you can choose to uninstall it from your System by using
apt remove gforth command as shown below.
root@cyberithub:~# apt remove gforth Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: gforth-common gforth-lib Use 'apt autoremove' to remove them. The following packages will be REMOVED: gforth 0 upgraded, 0 newly installed, 1 to remove and 17 not upgraded. After this operation, 732 kB disk space will be freed. Do you want to continue? [Y/n] Y (Reading database ... 206240 files and directories currently installed.) Removing gforth (0.7.3+dfsg-9build2) ... Processing triggers for man-db (2.9.1-1) ...