Slides badge

Computer languages

Learning Intentions

  • Understand the way computer programs are represented
  • Understand what a two-state machine is and why it is called that
  • Understand what high-level and low-level programming languages are and how they differ
  • Understand the properties of and the need for translator programs including interpreters and compilers

Success Criteria

  • I understand that learning one programming language makes it easy to learn another programming language
  • I can explain the term two-state machine
  • I can explain how computer programs work on computer systems

Learn One. Learn Many.

  • When you learn to program you learn skills that allow you to adapt to use other languages very quickly.
  • By the time I had left school I knew a total of three languages well. But by the time I started university a few months later I knew a total of eight languages really well.

Programming languages

  • There are many different programming languages out there. Learning one programming language makes it easy to learn another language, but programming languages all serve different purposes.
  • For example, FORTRAN was developed before spreadsheets existed and was an excellent language for calculations.
  • Python is often used in research projects because of its simplicity to write and decent performance.
  • Java is often used for programs that work on multiple computer operating systems.
  • PHP is often used for web programming because of its web –oriented features.

Quick task

Your first task is to look up the following programming languages and find out what the main use of the programming language is. The first one has been done for you (you’ll find the tasks in the worksheet). 

A computer program

  • In one of the first lessons on computer programming, we said that a computer program is a series of instructions.
  • Continuing this idea, a computer see programs as a series of codes that it can understand. This is called machine code.
  • Back when computers were in their infancy, people wrote computer programs using punch cards.
  • These days, computers work electronically on a series of switches which are represented by 1s and 0s called binary.

Punch cards

  • Punch cards were very simple - if there was a hole then it was a 1, if there wasn’t a hole then it was a 0.
  • This was how computer programs were stored and rerun.
  • This idea spawned from the work of Ada Lovelace who theorised the idea of a machine that could accept a program to tell it what to do

Electronic computers

  • These transistors represent a 1 or 0 based on whether they are switched on.
  • For this reason, computer systems are known as two–state machines.
  • For this reason, computer systems are known as two–state machines.
  • Computer systems use electronic components such as the RAM and CPU.
  • These components are made up of series of switches called transistors.
  • When a computer program is run, it instructs the computer to switch on certain transistors.
  • These transistors represent a 1 or 0 based on whether they are switched on.
  • For this reason, computer systems are known as two–state machines.
  • A computer can then execute (run) them as a computer program and perform actions based on their state.

Writing programs

  • When we write programs in Visual Basic, Python or JavaScript, we are writing the series of instructions needed for a computer to be able to do something.
  • A computer system cannot really see a Visual Basic or Python program as a series of computer instructions.
  • A computer needs to have it as a series of 1s and 0s to understand it. To do this, a translator is required.

High- and low-level languages

  • A computer program is categorised as either high-level or low-level.
  • A high-level language is one that is written in English or near to English using words such as ‘if’, ‘loop’ whereas a low-level language is written in either machine code (such as 1s and 0s) or assembly code (MV x y) and very unlike the English language and difficult to read.
  • Visual Basic, Python, JavaScript etc. are high-level languages.
  • x86-64 Assembly (Intel) and machine code are low-level languages

Assembly code

  • Assembly code is very short (often three letter words) that tell the computer what to. Instead of writing x = 10, you would write

MOV 10, x

  • CPUs all have different assembly languages too. So, writing a program in assembly language and then trying to run it on another computer is not always going to work!
  • Therefore, abstraction became a big thing in computer programs.

Abstraction

  • Abstraction is all about adding layers on top of other layers. 
  • These layers make it easier for us to write code, for example in Python we write x = 65 in assembly we write 
  movq $65, %rax
  pushq $100
  • It requires a lot more as you go further down the chain. 

Abstraction

  • Also, since high-level programming languages are simply code, we can often run this on several computers if the computer can do the translation to machine code on the computer running the code!
  • To do this, we have a small program called a runtime. The end user must have this runtime to run your code. The runtime translates the code whenever the program is run. Python uses a runtime system.
  • Every time a layer is developed on top of another layer, for example all high-level languages are written in either low-level languages (such as assembly) or another high-level language (such as C++) they become slower than the layer below them. In other words, programs written in low-level languages run faster than those written in high-level languages.

Demo

Translator programs

  • Translator programs turn code transforms from a high-level language into a language that the computer can understand.  
  • There are two types of translator programs:
    • Compilers
    • Interpreters

Compilers

  • A compiler turns the users code into something that the computer understands in one go.
  • Compilers check for bugs in the code, but they are more difficult to detect with a compiled program because the compiler only displays all the bugs at the end of the program compiling.
  • Compiling can be slow, however. Some compilers can take several hours or days to compile a program.
  • When a program is compiled, its original code is almost impossible to go back to (or decompile) and in terms of safety a compiled program is much better.

Interpreters

  • An interpreter translates each line of code, line by line.
  • If there is a bug in the code it will stop at the line where the bug is and inform the user.
  • Interpreted programs are slower than compiled programs but do offer more tools to help find any problems in the code.

Complete the worksheet from task 2 onwards.

 

Task 2: sort out the facts

Task 3: find the code that displays "Hello world" in each of the different programming languages

Task 4: answer the questions, giving a reason for your opinion

Task

Plenary

I can explain how computers work with 1s and 0s

I can explain how computer programs work on computer systems with reference to the two-state machine concept

I understand that learning one programming language makes it easy to learn another programming language

Presentation Overview
Close
JB
Computer languages
© 2020 - 2024 J Balfour
17:42 | 23-05-2024
Join Live Session
Start Remote
Save Progress
Slideshow Outline
Presenter Mode
Widget Screen
Canvas Controls
Random Selector
Timer
Volume Meter
Binary Converter
Python Editor
Show Knox 90
Provide Feedback
Help
!
Keywords
    DragonDocs Management
    Random selector
    Sections
      Binary conversion
      Denary to binary conversion
      Binary to denary conversion
      Feedback 👍
      Accessibility

      Apply a filter:

      ×
      All slideshow files