programming languages€¦ · computer languages are used to develop programs. ... this is a...
TRANSCRIPT
![Page 1: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/1.jpg)
PROGRAMMING LANGUAGES
Marlene Galea
![Page 2: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/2.jpg)
What is a computer language?
A computer language involves a vocabularyand set of grammatical rules for instructing a computer to perform specific tasks.
Computer languages are used to develop programs.
![Page 3: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/3.jpg)
The CPU Instruction Set
the complete set of all the instructions in machine code that can be recognized and executed by a central processing unit.
![Page 4: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/4.jpg)
The CPU Instruction Set
Examples of instruction set
ADD - Add two numbers together.
COMPARE - Compare numbers.
IN - Input information from a device, e.g. keyboard.
JUMP - Jump to designated RAM address.
JUMP IF - Conditional statement that jumps to a designated RAM address.
LOAD - Load information from RAM to the CPU.
OUT - Output information to device, e.g. monitor.
STORE - Store information to RAM.
![Page 5: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/5.jpg)
LOW LEVEL LANGUAGES
![Page 6: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/6.jpg)
What is a Low Level Language?
This is a programming language that that provides little or no abstraction from a computer's instruction set architecture
![Page 7: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/7.jpg)
Machine Code
• Computer can directly execute machine code
• Humans find it very difficult to write in machine code
• They are written to run on a specificplatform.
![Page 8: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/8.jpg)
Advantages and Disadvantages of Machine CodeAdvantages Disadvantages
Written Exercise 1
![Page 9: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/9.jpg)
Advantages and Disadvantages of Machine CodeAdvantages
• Execute fast because no translation is needed
• Require less space and system resources
Disadvantages
• Difficult for humans to create• Difficult for humans to debug• Not portable
Written Exercise 1
![Page 10: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/10.jpg)
ASSEMBLY LANGUAGES
![Page 11: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/11.jpg)
Assembly Languages
LDA B
ADD C
STA D
1101 110001
1101 111100
1000 111100
Arithmetic Logic Unit (ALU)
CPU
Control Unit (CU)
Instruction Register
Accumulator
Shift Register
Program Counter
![Page 12: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/12.jpg)
ASSEMBLY LANGUAGES
USE MNEMONICS
LDA BADDCSTA D
![Page 13: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/13.jpg)
Assembly Languages are LLL
• Programs in Assembly are still difficult and long to write, but they are more English-Like than machine code
![Page 14: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/14.jpg)
Opcode and OperandAddress Data001 LDA N1
010 ADD N2
011 ADD N3
100 STA ans101 STP110 (N1)111 (N2)1000 (N3)1001 (ans)
ADD N2Opcode
What to do
OperandWhat
data to use
Instruction
![Page 15: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/15.jpg)
ADDRESSING
![Page 16: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/16.jpg)
Types of Addressing
• Symbolic addressing • LDA N1
• Direct addressing• LDA 110
• Immediate addressing• LDA # 9
Address Data
001 LDA N1
010 ADD N2
011 ADD N3
100 STA ans
101 STP
110 (N1) 9
111 (N2) 7
1000 (N3) 13
1001 (ans)
![Page 17: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/17.jpg)
Types of AddressingAddress Data
001 LDA N1
010 ADD N2
011 ADD N3
100 STA ans
101 STP
110 (N1) 9
111 (N2) 7
1000 (N3) 13
1001 (ans)
What Type of Addressing is involved?
LDA N2
LDA 111
LDA # 7
![Page 18: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/18.jpg)
Types of AddressingAddress Data
001 LDA N1
010 ADD N2
011 ADD N3
100 STA ans
101 STP
110 (N1) 9
111 (N2) 7
1000 (N3) 13
1001 (ans)
What Type of Addressing is involved?
LDA N2 Symbolic Addressing
LDA 111 Direct Addressing
LDA # 7 Immediate Addressing
![Page 19: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/19.jpg)
True or False
Answer
1. A Low Level Language is easier to code in and debug
2. Programs in a LLL will execute faster than equivalent HLL programs
3. Assembly Language is an LLL
4. Java is an LLL
5. LLLs are portable
6. Programming in an LLL requires a good knowledge of machine architecture
7. Programs in a LLL are less resource hungry than equivalent HLL programs
![Page 20: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/20.jpg)
True or False
Answer
1. A Low Level Language is easier to code in and debug False
2. Programs in a LLL will execute faster than equivalent HLL programs True
3. Assembly Language is an LLL True
4. Java is an LLL False
5. LLLs are portable False
6. Programming in an LLL requires a good knowledge of machine architecture True
7. Programs in a LLL are less resource-hungry than equivalent HLL programs True
![Page 21: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/21.jpg)
HIGH LEVEL LANGUAGES
![Page 22: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/22.jpg)
High Level Languages
![Page 23: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/23.jpg)
Advantages and Disadvantages
Advantages
• More English-Like: easier to create and debug
• Portable
Disadvantages
• Require complex translation so may be slower to execute
• Programs in HLLs require more system resources
![Page 24: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/24.jpg)
GENERAL AND SPECIAL PURPOSE LANGUAGES
![Page 25: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/25.jpg)
General Purpose Language• A language that can be used to
develop applications in a number of field
![Page 26: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/26.jpg)
SPECIAL PURPOSE LANGUAGESA language developed specifically for creating programs with application in a
particular field.
![Page 27: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/27.jpg)
Artificial Intelligence & Expert Systems
The study and design of
intelligent agents An intelligent agent is a system
that perceives its environment and
takes actions which maximizes its
chances of success
‘Deep Blue’ the first instance of AI, a computer chess game, managed to beat a human world champion at chess.
![Page 28: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/28.jpg)
Artificial Intelligence & Expert Systems
An expert system can process large amounts of known information and provide conclusions based on them.
An expert system is a program that contains some of the subject-specific knowledge, and contains the knowledge and analytical skills of human experts.
![Page 29: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/29.jpg)
Artificial Intelligence &
Expert Systems
• Most expert systems involve a program made up of a set of rules.
• The program analyses information about a specific class of problems, and provides mathematical analysis of the problem(s).
• Then, depending upon their design, they recommend a course of user action to implement corrections.
• The system utilizes what appear to be reasoning capabilities to reach conclusions.
![Page 30: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/30.jpg)
TRANSLATORS
![Page 31: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/31.jpg)
Translating LLLs
• Translator from Assembly (LLL) to machine code
• Simple translation
![Page 32: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/32.jpg)
TRANSLATING HLLSBoth translate HLL to Machine Code (or LLL
![Page 33: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/33.jpg)
Compilers & Interpreters
c = 0;
total = 0;
Repeat
Input num;
total = total + num;
c = c + 1;
Until c = 5;
![Page 34: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/34.jpg)
Compilers
• It goes through the source code checking program structure
• once no errors are found it translates line by line, producing object code which can be saved and executed without requiring translation.
• In the case of a loop the section of code does NOT need to be translated each time the loop executes
Use:
• to translate programs for distribution: so the consumer only gets the object code
![Page 35: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/35.jpg)
Interpreters
• Interpreters translate one line at a time and then execute it before moving on to translate the next line. No object code is created.
Use:
• While creating and testing a program
![Page 36: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/36.jpg)
Tick as appropriateAssembler Interpreter Compiler
Translates LLL programs to Machine Code
Translates HLL programs
Translates the whole program before execution starts
Produces object code that can be saved and laterexecuted without further translation
Ideal for use during program development
Ideal for use when distributing software
![Page 37: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/37.jpg)
Tick as appropriateAssembler Interpreter Compiler
Translates LLL programs to Machine Code
Translates HLL programs
Translates the whole program before execution starts
Produces object code that can be saved and laterexecuted without further translation
Ideal for use during program development
Ideal for use when distributing software
![Page 38: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/38.jpg)
SO WHAT’S SO GREAT ABOUT JAVA?
![Page 39: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/39.jpg)
So what’s so great about Java?
We need our code to be translated for many different platforms
![Page 40: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/40.jpg)
So what’s so great about Java?
Bytecode
Compiled
Interpreted
JVMJava Virtual Machine
Linux machine
iPhone
Windows PC
Java Source Code
Platform IndependentPlatform
Independent
Platform Dependent
Interpreted
Interpreted
![Page 41: PROGRAMMING LANGUAGES€¦ · Computer languages are used to develop programs. ... This is a programming language that that provides little or noabstraction from a computer'sinstruction](https://reader033.vdocument.in/reader033/viewer/2022060208/5f041be37e708231d40c5cc8/html5/thumbnails/41.jpg)
Two-Step Translation
In Java translation is done in two steps: using first a compiler, then an interpreter.
The program is first compiled to produce bytecode. At this stage the user cannot view the actual code but the program is still platform independent. Therefore the bytecode is ideal for distribution.
Then the JVM on the machine the program will run on uses an interpreter to translate the program into executable code. The executable code is platform dependent because it will be different for a Linux Machine and a Windows PC etc.