2.5 – Programming languages and Integrated Development Environments

🎇2.5.1 Languages

This section covers:

  • Characteristics and purpose of different levels of programming language:

    • High-level languages

    • Low-level languages

  • The purpose of translators

  • The characteristics of a compiler and an interpreter

🏠 Click here to go back to the main page.

Other sections in this topic:

🔗2.5.2 The Integrated Development Environment (IDE)

This page is NOT YET READY


Programming Languages

All computer systems need software that they can run. When the computer system is first turned on, a program that is stored in the computer's ROM is executed. This usually checks that the system is working properly, and then loads the operating system from secondary storage into the main memory. An operating system such as Windows, Android, Linux etc is extremely complies and will contain millions of lines of code.

It would be possible for a human to look up each instruction and store the code as pure machine code, but this would make code that would be extremely difficult to maintain and update. It is for this reason, that we use a programming language that is much more human readable and can be quickly read by human, understood, corrected and updated.



How do computers work?

Machine Code

At the most basic level, computers are electrical machines. They work by switching electrical signals on and off very quickly. We can use binary to represent these electrical signals. A bit pattern of 01010111 may store an instruction that will set a pixel on the screen to a certain colour. Every single instruction is represented this way, using a number to represent each instruction. This is called "Machine code". Machine code is said to be "Low level" (in fact, it is the lowest) because it is easy for machines to understand, but very hard for humans to understand.


In this image showing raw machine code, you can see the memory location addresses in the left hand column, the hexadecimal value stored in those locations in the middle column, and the symbol or character that it represents in the right column.




In this image, the "assembly language" on the right is converted, or translated, into the machine code that the computer runs.

Assembly Language

It is very difficult, although not impossible, for a human to write pure machine code. They would need to have some form of plan of how the program would work, which could be a flowchart or simple written "back of an envelope" sketch. Each step would need to be broken down into the actual machine instructions which could then be converted to the numerical values that the computer understands.

In the early days of computing, programmers found this very tedious, and prone to error. One of the first ideas that they had to make this easier was to write a special program that would use special codes to assemble into full programs. The "assembly language" was converted by the program (called an "assembler" into the machine code that the processor needed. The assembler would run and "compile" the machine code, which could then be executed by the computer.

Assembly language is easier for humans to work with, and the programmers could read the program and write the assembly language code without having to look up any codes.

It is still quite difficult to work with though, and is classed as low level.



High Level Languages

Eventually, more and more human readable programming languages were developed. These languages use words that can do many tasks at once and will require complex machine code. Here is an example:

10 FOR a = 1 TO 10

20 PRINT(a)

30 NEXT a

This is actually written in a language called BASIC, but a very similar technique is available in many languages. Line 10 will declare a variable called a and set its value to 1. Line 20 will retrieve the value of a, and export it to the monitor. Line 30 will retrieve the value of a, add one to it, and check it hasn't gone over 10. If it hasn't, the code will loop back to line 10 and repeat lines 20 and 30. If it has, the program will continue at the next line.

This is one of many different languages that are known as high level languages. They are much easier for humans to read, edit and understand but the computer needs to produce machine code, which takes time and can produce in-efficient code.

For the exam, you need to know "the characteristics and purpose of different levels of programming languages". Here is a summary:




Low level


Low level


High level


High level



Fourth generation languages are declarative, which means that they describe data structures or operations rather than program flow. An example of this is SQL.



Translators

Each generation of programming language needs a way of turning what the programmer types into actual machine code - the exception is writing actual machine code, in which case the raw numbers are just copied into memory - which historically has been known as "poking"

Other languages need to be translated into machine code.

An assembler will convert each instruction on a one to one basis.

Higher level programmers can be translated in two different ways. The first way is to take the whole program and convert it into a file that can then be run directly by the computer. This is called "compiling"

Another way, is to convert the program into machine code in smaller chunks, often just one line of code at a time. This is done by an interpreter.

A compiled program takes longer to translate, but the executable file will run much more quickly. An interpreted program will run slightly slower because it has to be translated as the program runs.



The Characteristics of an assembler, a compiler and an interpreter







Integrated Development Environments (IDE's)

We have already used several IDE's when we created programs in Python. Python IDLE (which is a play on IDE, Eric Idle was is one of the Monty Python team), Thonny and Mu are all examples of IDE's.

Virtually every IDE will have a text editor designed to write and manipulate source code. Some tools may have visual components to drag and drop front-end components, but most have a simple interface with language-specific syntax highlighting (usually using different colours to represent different things in the language, such as special words, variable names etc.)

Here are some other facilities offered by an IDE:

Bracket matching.

This is used for languages that use pairs of brackets to mark out blocks of code. It allows the code to be read and understood more quickly. If you forget to close a bracket while writing, coloured sections may help you to detect missing brackets.

Syntax checks.

This recognises incorrect use of syntax and highlights any errors.

Debugger

Debugging tools assist users in identifying and remedying errors within source code. They often simulate real-world scenarios to test functionality and performance. Programmers and software engineers can usually test the various segments of code and identify errors before the application is released.

Compiler

Compilers are components that translate programming language into a form machines can process, such as binary code. The machine code is analysed to ensure its accuracy. The compiler then parses and optimises the code to optimise performance.

Code completion

Code complete features assist programmers by intelligently identifying and inserting common code components. These features save developers time writing code and reduce the likelihood of typos and bugs.

Programming language support

IDEs are typically specific to a single programming language, though several also offer multi-language support. As such, the first step is to figure out which languages you will be coding in and narrow your prospective IDE list down accordingly. Examples include Ruby, Python, and Java IDE tools.

Integrations and plugins

With the name integrated development environment, it is no surprise that integrations need to be considered when looking at IDEs. Your IDE is your development portal, so being able to incorporate all your other development tools will improve development workflows and productivity. Poor integrations can cause numerous issues and lead to many headaches, so make sure you understand how well a potential IDE fits into your ecosystem of existing tools.


  • Auto-completion (or code completion). This is designed to save time while writing code. As you start to type the first part of a function, it suggests or completes the function and any arguments or variables.

  • Bracket matching. This is used for languages that use pairs of brackets to mark out blocks of code. It allows the code to be read and understood more quickly. If you forget to close a bracket while writing, coloured sections may help you to detect missing brackets.

  • Syntax checks. This recognises incorrect use of syntax and highlights any errors.