Day 1

This is the day 1 page for computer programming course 101, an introductions to computer programming. On day 1 we introduce the Linux operating system several programming languages, and the Lazarus integrated development environment.

Below are the topics and course materials we are learning today.

Introduction to the Linux operating system

This is a quick introduction to the Linux operating system.

Linux is a free open source operating system inspired by the Unix operating system created by AT&T in the 1970s. Free open source means anyone can freely share and modify the source code with the idea that everyone can share their improvements gradually making software projects better and better.

When we say Linux is inspired by Unix, we mean it has been designed to be very much like Unix. It is not a direct copy of Unix, but it is an independently developed operating system that has most of same functionality as Unix.

When Unix users worked on their computers in the 1970s, they often used terminals to connect to the Unix computer. These terminals often did not have monitors, instead they would output information on paper using an automated typewriter. This terminal setup was called teletype.

Today when you using Linux, you may often want to open a terminal to execute Linux programs. These Linux terminals, and any programs you run, are assigned a TTY session number. TTY is short for teletype.

In modern Linux implementations there are several teletype sessions readily available. You can typically switch between these teletype using your keyboard with the key combination of
Ctrl + Alt + F1-F7
, where the number of the function key corresponds to the TTY session id. Normally the graphical user interface runs on TTY7.

Example: switching TTY sessions


When you are using the terminal in Linux it's helpful to know a few common program files. In Linux directory and file names are case sensitive. Here are some common program you should know when using Linux.
linuxuser:~/$ ls
Lists the contents of the current directory. Can also be using with the switch
-l
to list contents in long format. The
-a
can be added to show all files and folders, including hidden ones. An item to note is that all items which begin with a
-l
dot are normally hidden.
linuxuser:~/$ cd
Change to a directory. In Linux the paths to directories are separated by a forward slash. The tilde
~
symbol can be used to reference the users home directory. The single dot
.
and double dot
..
are used to specify the current and parent folder respectively.
linuxuser:~/$ mkdir
Make a new directory. Can be used with the
-p
switch to create a series of parent and child directories at once.
linuxuser:~/$ rmdir
Remove an existing directory. Can be used with the
-p
switch to delete a series of parent and child directories at once.
linuxuser:~/$ touch
Create a new empty file. If the file already exists then touch does nothing.
linuxuser:~/$ rm
Remove a file. Can also remove directories with used in conjunction with the
-rf
remove force switch.
linuxuser:~/$ cat
List the contents of a file. The abbreviation
cat
is short of concatenation.
linuxuser:~/$ man
List the manual for using a command. You can scroll through the manual using the arrow keys. Press
q
to exit the manual.
linuxuser:~/$ tty
List the current terminal id. The files with
tty
and numbers are real terminals. The files with
pts
and numbers are pseudo terminals when used while running programs such as
xterm
,
ssh
, or
tmux
.

Introduction to the Hello World programs

Most programming introductions start by presenting the text "Hello World!" to the end user. This is how the classic Hello World program would be written in Pascal.
program Hello;

begin
  WriteLn('Hello World!');
end.
Assuming you have Free Pascal installed and configured correctly, and your hello program is in a file named hello.pas,you would build and run the program from a terminal window using these command.
fpc hello.pas
./hello
If everything went worked correctly you should see this message in your terminal window.
Hello World!
To write the same program in C you would create a hello.c with the following text.
#include 

void main() {
  printf("Hello World!");
}
And you would compile and run the program using these commands.
gcc -o hello hello.c
./hello

Introduction to the types of programs

There are many types of programs you can write and run. The examples in the previous section were all what are called command line programs. The terminal interface may also be referred to as the CLI, or command line interface.

Another popular program category are graphical desktop applications. The web browser you are using to view this page is a graphical desktop application. Programs that use computer graphics rather than text can be referred to as using a GUI, or graphical user interface.

Aside from command line and graphical applications, some programs can be run as services. Services typically run in the background and provide endpoint to which other programs may connect. An example of a service application is a web server, a print server, and a secure shell host daemon.

Although you can usually use any programming language to write program for any of the above uses, some languages are better than others when it comes to the specific program types. C, C#, and Pascal are well suited for creating CLI programs. C, C++, and Pascal work well in creating desktop GUI programs. And scripting languages like Javascript and Typescript work well when adding programming logic when adding logic to web pages.

Show and tell break: program showcase featuring completed programs

In this section the instructor demonstrates some completed programs which were written by an individual person.

Introduction to languages and development environments

An integrated development environment, or IDE, is a programming tool that makes many tasks a computer programmer needs to do much easier. It provides a rich set of helpful functionality to both write and test your programs. All of this rich functionally is integrated into a one development environment.

In this section the instructor takes students brief tour of several integrated development environments. We start with Lazarus, then move to MonoDevelop, and finally end up looking at visual studio code.

Introduction to Lazarus development

Lazarus is one of the official development environments for the Free Pascal language. It provides a syntax and context aware code editor. It integrates a compiler and debugger. Lazarus also includes a rich two way visual component library for designing graphical desktop applications.

In this section the instructor takes students brief tour most of the commonly used areas of the Lazarus IDE. We also take a tour of the options section in Lazarus.

Introduction to console CLI and graphical GUI applications

As mentioned in a previous section Free Pascal is an excellent language for creating both CLI and desktop GUI programs. Most of the examples we will be starting with as you learn the Free Pascal languages will be CLI programs.

In this section the instructor quickly writes a few one off CLI and desktop GUI programs.

The first example across languages

In this section the instructor uses Free Pascal with Lazarus and a few other languages and environments to recreate the Hello World program.

Explain and demonstrate how programming langauges share concepts

In this section the instructor demonstrates how most programming languages share many common concepts and designs. We demonstrate a few concepts such as functions, types, variables, packages, and so on.

History break: Anders Hejlsberg

In this section we talk about the programmer hero Anders Hejlsberg. By himself Anders created the massively popular DOS program Turbo Pascal. At that time Turbo Pascal was an incredible tool. If fit on one floppy disk, integrated a text editor and compiler, and could build your software in less than a second.

In the late 1980s Anders was hired to develop Turbo Pascal as a product for the Borland company. With Turbo Pascal Borland was an enormously successful company and bought dBase from Ashton-Tate in 1991 for $430 million dollars.

In the early 1990s Anders started on a new project to take Turbo Pascal into the area developing of graphical desktop programs for Microsoft Windows 3. This new project became Delphi 1.0. In addition to making graphical desktop program development easy, Delphi also created a whole new way of developing client server database applications.

Anders next task was to take Delphi 1.0 from 16 bit Windows 3 to the forthcoming 32 bit Windows 95 operating system with Delphi 2.0.

Both Free Pascal and Lazarus borrow heavily from Turbo Pascal and Delphi. Free Pascal even has 100% compatibility with Delphi 7.

Bill Gates, the founder of Microsoft famously quipped, the only thing wrong with Delphi is that it isn't made by Microsoft.

Homework

There are no homework assignments for day 1.

See also