High or Low Level Programming Language? Justify your decision. 1 0 1 1 0 1 1 0 0 1 0 0 1 0 1 0 1 0 1 1 0 0 0 1 1 1 0 0 1 0 0 0 1 0 Machine Java Python Scratch Assembly
High/Low Languages & Language Translators 4.5.1 4.5.2
Learning Objectives 4.5.1 Understand what is meant by high-level and low-level programming languages and assess their suitability for a particular task 4.5.2 Understand what is meant by a compiler and an interpreter Online worksheet for this lesson
High/Low Languages 4.5.1
Check Java Python Scratch Assembly Machine High Level Languages Low Level Languages 1 0 1 1 0 1 1 0 0 1 0 0 1 0 1 0 1 0 1 1 0 0 0 1 1 1 0 0 1 0 0 0 1 0 Machine
10 min Your Turn: Take Notes Watch this video about high and low level programming languages https://www.youtube.com/watch?v=rzZpwGB91DU Take notes in a table like this: High Level Low Level Task 1: On class worksheet
Characteristics Check Scratch Python Java Assembly Machine Works on many different microprocessors (machine independent) Commands look similar to English language Easier for humans to read/understand than assembly or machine code Scratch Easy and quick for humans to write and maintain code High Level Languages Python Java Needs to be translated to machine code Low Level Languages Each statement is exactly one instruction in machine code Use mnemonics (abbreviations) Only works on one type of microprocessor (machine dependent) Each instruction has an opcode and operands Assembly Needs to be translated to machine code Machine 0s and 1s only No translator needed Directly executable by machine Only works on one type of microprocessor (machine dependent) Difficult for humans to read
Your Turn: Justify Usage 5 min Your Turn: Justify Usage Why would you want to use each either a high or low level language? Task 2 on class worksheet We’ll check your answers with the next slide Task 2: On class worksheet
Why Use Each? Check Python Java Assembly Machine May have built-in libraries of useful functions already written and tested. Commands look similar to English language, so it’s easy and quick for humans to write and maintain code Code can be written once and ported to many platforms (Windows, LINUX) High Level Languages Python Java Easy and quick for humans to write and maintain code Low Level Languages It’s a very good way to control hardware, like printers or graphics cards. Sometimes, it’s the only language available. For example, a new chip is invented. Sometimes, the function needed is not available in a high-level language. Can be used to speed up parts of high-level language programs. Each statement is exactly one instruction in machine code, so it’s very efficient. Assembly Machine Almost no one writes machine code now.
Questions? That finishes ‘high level and low level’ programming languages Any questions before moving on?
Language Translators 4.5.2
How does each get translated to machine code? Scratch The translator is called an ‘interpreter’. Python High Level Languages Java The translator is called a ‘compiler’. Low Level Languages The translator is called an ‘assembler’. It translates from an assembly language to machine code. Assembly Machine No translation necessary. It’s already machine code.
Compiler vs Interpreter 10 min Compiler vs Interpreter Watch this video about high and low level programming languages https://www.youtube.com/watch?v=zTuSgPQBgz8 Take notes on the worksheet We’ll check your answers with the next slide Interpreter Compiler Task 3: On class worksheet
Compiler vs Interpreter Check Compiler vs Interpreter Interpreter Compiler One line of code is translated and executed at a time; one by one The interpreter is required for the whole time the program is running Runs slowly Can correct mistakes as you go along Must have interpreter to run code Very good for prototyping (mocking up) Python, Scratch Translates the whole list of instructions in one go Has some extra processing time in the beginning The compiler is not needed to execute the translated instructions Execution of translated code is very fast Cannot correct mistakes after translation Don’t need compiler to run resulting code Java, C, C++
Compilers, Interpreters, Assemblers Assembly Java Python INTERPRETER Scratch COMPILER ASSEMBLER Low Level INTERPRETER High Level 100011111100001111000010111000111000101010010010010100001111000010100100 Machine Code
Plenary – Make a Choice 2 Assembly Language Interpreter High Level Language Compiler Low Level Language Machine Language Needs no translation Uses mnemonics. Very efficient. Is not very easy for humans to read or write. Easy for humans to read and quick for humans to write. Has to be present for a program to run. Is not needed to run the translated program. 5 4 6 3 1
Homework Complete this lesson’s homework worksheet Due in 2 lessons