Docsity

Understanding the Basics of Programming Languages and Processors, Slides of Geology

Partial preview of the text

Download Understanding the Basics of Programming Languages and Processors and more Slides Geology in PDF only on Docsity!

Introduction

  • Programming skills are not essential, but they are useful for: - Special data processing; - Customisation

Computers

  • The processor (or CPU) can be thought of as the ‘heart’ of the computer as it controls the flow of information around the system.
  • The processor requires instructions telling it what to do. These are provided by the operating system (OS).
  • All instructions to the processor are in machine code.

Programming Languages

  • Machine code can be represented as as series of binary digits (or bits ).
  • Bits are normally organised in groups of 8 called bytes.
  • Machine code is unintelligible to most humans, so instructions are normally provided using a language which can be translated into machine code.
  • Languages can be:
    • Low level (e.g. machine code, assembley language)
    • High level

Assembley Language

  • Each processor (or family of processors) has its own assembly language.
  • Assembley languages provide very detailed control using mneumonics.
  • It can take a lot of steps to do even simple things. For example, the following adds two single byte numbers together in 6502 assembley code.

Translation

  • Irrespective of the language used, the code must be translated into machine code.
  • Assembleylanguage programs are translated by an assembler.
  • Machine code can also be translated in the opposite directed by a disassembler.
  • High level languages are translated by either:
    • An interpreter , or
    • A compiler.

Interpreters

  • Interpreters translate the source code one line at a time.
  • The line is translated into machine code and executed.
  • If it works, the interpreter translated the next line, and so on.
  • If an interpreted program breaks down, it is fairly easy to diagnose the problem and possibly even restart the program from where it broke down.
  • The main problem with interpreted languages is that they are slow.

High Level Languages

  • Some high level languages are lower level than others
  • C is a ‘lower’ level high level language – i.e. it gives more control and also runs faster than other high level languages, but it is more difficult to learn.
  • Other high level languages (e.g. Fortran , Basic ) are easily to learn.
  • Fortran is a compiled language, Basic is usually interpreted.

Platform Dependence

  • Compiled executables are usually platform dependent (i.e. they are translated into the machine code used by a particular processor).
  • This creates problems if you want to run programs over the internet – i.e. different users use different platforms.
  • Java was developed to overcome this.
  • Java compiles the source code into an intermediate byte code for distribution.
  • This is then interpreted at execution by a Java Virtual Machine (JVM) for a particular platform.