Introduction to Theory of Programming Languages

This is a lesson in in the course, Theory of Programming Languages, which is a part of The School of Computer Science

Objective

In this lesson, students will be introduced to programming languages and the distinctions between them.

Students will be able to answer:

  • What is a programming language?
  • How is a programming language different than a human language?
  • What is the difference between a High Level Language(HLL) and a Low Level Language(LLL)?
  • What are the pros and cons of HLLs and LLLs?

Introduction

Programming languages are special purpose languages used to instruct machines and express the semantics of algorithms. They were invented to make machines easier to use, as their processes could be automated in logical ways. New languages are still being written to this day to make different logical or mechanical problems easier to solve. Programming languages are strikingly different from human languages as they are highly formal and logical. Yet many of the concepts applied can be directly compared to human language. Programming languages can be divided in many ways, but the clearest distinction is between "Low Level Languages" (LLL) or "High Level Languages" (HLL).

Low Level Languages

A R4700 Orion chip, which runs the LLL MIPS.

LLLs are very simple, often based directly on the machines which they control - different brands of computer chips use different LLLs. Low Level Languages are also unique in that they can be directly represented by machine code, made of electrical signals or other physical processes. These languages can be represented using simple strings of text but even with that level of detail, humans have great difficulty reading the code - they are primarily the mother tongue of the machine.

This is an example of a lower level language called MIPS assembly:

add    $t3, $a0, $t0	
lw     $t3, 0($t0)	
sub    $v0, $0, $t1
srl    $v2,$t1, $s7

Because MIPS assembly (or assembler language) is a LLL, it can be directly represented in binary form. Here is that same program written in its binary counterpart:

00000000100010000101100000100000
10001101000010110000000000000000
00000000000010010001000000100010
00000000000010010000010111000010

Binary is often written in hexadecimal format to reduce size:

00885820
8D0B0000
00091022
000905C2

As you can clearly tell, it is hard to read "008858208D0B000000091022000905C2" and discern the program behind it. This is why people tend to avoid LLLs unless they are directly working with or learning about the hardware within a computer.

High Level Languages

High Level languages, while just as logical as their lower level siblings, provide other useful features. Besides being much easier for a human to read, these languages are not based on a specific machine - they are translated down by "compilers", "interpreters" and "virtual machines" into LLLs. (This process will be covered in later lessons, at this point simply understand that HLLs can run on a variety of machines while LLLs are limited to a single type.) HLLs are also less efficient than LLLs because they need to be translated to machine code, but this extra step gives a computer the chance to check code for logical errors. Generally, HLLs are easier for people to learn and are more pleasing to work with - but they are less efficient than LLLs and are more distantly connected to the machines they run on.

High Level Languages fall into several main varieties: Imperative, Object Oriented, Functional, and Logical. Later lessons will go into detail describing the pros and cons of each type.

Assignments

  1. Make a list of 15 programming languages. Write down if they are a HLL or LLL - if they are a HLL write down which type they are (Logical, Imperative, etc).
  2. Find out which kind of LLL each computer in your house uses (this includes cell phones). To do this you will need to look up what type of processor it uses, and then find what language that processor runs.
  3. Make a list of your favorite programs, find out what languages they are written in.
  4. Read The Introduction from your textbook.

Completion status: this resource is just getting off the ground. Please feel welcome to help!

This article is issued from Wikiversity - version of the Sunday, March 13, 2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.