What is a programming language?

From Computer Science Wiki
Jump to: navigation, search
Programming basics[1]

A programming language is a formal computer language or constructed language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs to control the behavior of a machine or to express algorithms.[2]

Fundamental operations of a computer

The most basic instructions a computer can be given are:

  • ADD
  • COMPARE
  • RETRIEVE
  • STORE

Compound operations

Compound operations are composed of very large numbers of fundamental operations. For example, if we wanted to multiply, we would simply add groups of numbers until we had found our solution.

If we ask a simple question: what is the biggest item on this listGive a sequence of brief answers with no explanation., we might use complex code like this:

$list_of_numbers = [12,1,54,8,19,4,13,21,12,89,-1,6]

echo max($list_of_numbers);

But the computer (using fundamental operations) will process the above instructions like this:

LOAD register 00001
ADD 12
STORE result
COMPARE result to register 0002

(...and so on until the largest number has been found and stored)

Levels of programming languages

I used this glossary from an auth0 article on web assembly[3]

  • Source code: What a developer writes.
  • Compiler: An application that turns source code into assembly, bytecode or machine code (what other apps or hardware run).
  • Assembly: A low-level source-like language specific to a machine or an application.
  • Bytecode: A low-level binary representation of code that can be run by other applications.
  • Machine code: A binary representation of code that can be run directly by hardware.


The basics of programming languages

In order to really understand this material, we must understand the ALU - the "brain" of the computer.

An example

Below is an example of a program language designed to communicate instructions to a machine. The piano is "fed" instructions which enable it to play a simple song. The song is an example of a program. Can you imagine how difficult it might be to "write" these instructions?!?

ExplainGive a detailed account including reasons or causes. the need for higher level languages.

If you have watched the example above, you might immediately realize it would be crazy to write a complex piano piece by punching holes in a piece of paper. This is why we use high-level languages.

We need high level languages because programs are highly complex. Even a simple conditional statement would take many hours to write in assembly. Debugging our code would be almost impossible and understanding the code would be almost impossible.

Essential features of a programming language

Fixed vocabulary

Instructions for operations do not change. For example, the command print will always print. We do not use instructions like "display" or "show" or "put on screen", we always use the same vocabulary. Each programming language has it's own vocabulary, but this vocabulary must be consistent throughout the language.

Unambiguous meaning

Instructions must be clear. Instructions should not be foggy or fuzzy (ambiguous). For example, if I want to return the absolute value of a numberA unit of abstract mathematical system subject to the laws of arithmetic., I would use the instructions below:

# the built-in function for absolute value is abs(). 

abs(-212)

Consistent grammar & syntax

Throughout the programming language, the way we declare and use language features must be the same. Again, instructions must be very clear. For example, a conditional statement must always be formatted the same way. In python the use of whitespace is always the same.

if x > 0:
    print('X is greater than zero')
else:
    print(' X is equal or greater than zero')

Standards

  • StateGive a specific name, value or other brief answer without explanation or calculation.Give a specific name, value or other brief answer without explanation or calculation. the fundamental operations of a computer.
  • DistinguishMake clear the differences between two or more concepts or items. between fundamental and compound operations of a computer.
  • ExplainGive a detailed account including reasons or causes. the essential features of a computer language.
  • ExplainGive a detailed account including reasons or causes. the need for higher level languages.
  • OutlineGive a brief account. the need for a translation process from a higher level language to machine executable code.

References