2.5 - Languages and IDEs

Levels of languages

- There are two levels of languages: high level, and low level.
- High level languages are easier to read, write and understand, but are harder for computers to process and must be run through a compiler (translates the high level language into a low level language).
- Low level languages are harder to read, write and understand, but are easier for computers to process and do not need a compiler. Low level languages were the first programming langauges, and programming took a long time.

Low-Level Languages

- Low level languages either are, or resemble, machine code.
- They use 'instructions', which are commands that the CPU understand.
- Originally, programming had to be done directly in machine code. This means that the programmer had to write the code in binary.
- Later on, assembly language was created, which is a low level language that resembles machine code, but is easier to read and write.
- It has to be translated (through an assembler) into machine code before it can be run on the computer, but it is very easy to predict what will come out.
- It looks like this: Hello World in Assembly

Advantages of Assembly Disadvantages of Assembly
  • Easier to read
  • Easier to write
  • Machine code is easy to predict
  • Still requires manual memory management
  • Still requires an assembler
  • Still requires platform-specific code
  • Prone to (cryptic) errors

High-Level Languages

- High level languages are easier to read, write and understand, but are harder for computers to process and must be run through a compiler.
- Languages like C, C++, Java, Python, OCR Reference Language, JavaScript, and pretty much any 'programming language' you would use are high level.
- Despite the fact that the generate machine code may be less efficient, this is generally not an issue due to advancements in processing power and memory capacity.
- One 'standard library' instruction can be many machine code instructions.

Advantages Disadvantages
  • Easiest to read
  • Easiest to write
  • A lot easier to debug
  • Not architecture dependent
  • One line can be many machine code instructions
  • Harder to predict machine code
  • Less efficient
  • Needs to be compiled

Translators (Compilers and Interpreters)

- A translator is a program that translates source code into machine code.
- The translator required by low-level languages (such as assembly) is called an assembler.
- The translator required by compiled high-level languages (such as C) is called a compiler.
- The translator required by interpreted high-level languages (such as Python) is called an interpreter.

Compilers

- Compilers translate source code into machine code before it is run.
- Compiled code can be distributed as executable files and run directly.
- If errors are found during compilation, or if any changes are made, the entire thing will need to be recompiled, which can take a long time.

Advantages Disadvantages
  • Source does not need to be available
  • Can be distributed without runtimes
  • Fast to run
  • Pre-run optimisation carried out
  • Everything needs to be recompiled when changes are made
  • Difficult to debug
  • Executables work on only one platform and architecture
  • Compilation can be memory-intensive

Interpreters

- Interpreters are programs that translate source code into machine code during its running.
- They go line-by-line, and if any errors are found, they will stop and display an error message.
- Programs run with interpreters are usually slower than compiled code, but they are easier to debug.
- Interpreted code is more difficult to distribute, since it requires a runtime environment to run, for example the Python interpreter.

Advantages Disadvantages
  • Easiest to debug
  • Not platform-dependent
  • Does not require recompilation every time
  • Less RAM needed for processing code
  • Slower than compiled code
  • Requires a runtime environment
  • Often takes more system resources
  • No pre-run optimisation can be carried out

IDEs

- An IDE, or Integrated Development Environment, is a software application that are designed to make writing code easier and more efficient.
- There are multiple different facilites available within IDEs:

Editors

- The 'editor' component of an IDE is the part that allows you to write code.
- They will usually have syntax highlighting, which will make it easier to read code, by highlighting key words.

autocomplete(lmao)
- IDEs also automatically indent code, and automatically add ending brackets when you type an opening bracket, add ending quotes when you type an opening quote, etc.

Error diagnostics

- Error diagnostics are a feature of an IDE that will display error messages when there are errors in your code.
- They will also highlight the line where the error is, and will underline the error in the code.
- This has some overlap with runtime environments, as errors in your code # during runtime (not detected beforehand) will be highlighted.
- This is useful for finding errors in your code, and for fixing them.

Runtime environments

- Runtime environments are a feature of an IDE that will allow you to run your code.
- They will have the normal start-stop buttons you expect, but a decent IDE will also have a 'debug' option, which allow you to run your code line-by-line, and stop at any errors.

I apologise for the repetition in these but they overlap way too much

Translators

- IDEs will have built-in translators, so you can run your code without having to leave the IDE.


end of the course. woop woop