High-level Languages
-
Upload
lawrence-rich -
Category
Documents
-
view
197 -
download
15
description
Transcript of High-level Languages
High-level Languages
Assembly language benefits
Hides details of hardware
Assembly language benefits
Hides details of hardware
Easier to remember instruction names
Assembly language benefits
Hides details of hardware
Easier to remember instruction names
A tiny step closer to how humans think
Assembly language benefits
Hides details of hardware
Easier to remember instruction names
A tiny step closer to how humans think
Assembly language is a useful level of abstraction from the bare hardware
Assembly language benefits
Hides details of hardware
Easier to remember instruction names
A tiny step closer to how humans think
Assembly language is a useful level of abstraction from the bare hardware
Assembly language programs must be "assembled" into machine language executables.
Assembly Language issues
Still tied directly to the machine language instruction set
Assembly Language issues
Still tied directly to the machine language instruction set
Most machine language instructions do only a tiny amount of work
Assembly Language issues
Still tied directly to the machine language instruction set
Most machine language instructions do only a tiny amount of work
Humans solve problems at a higher level, using much larger steps
Example
For each value I read in from a fileIf the value is negative, then
add it to the list of expendituresOtherwise
add it to the list of income
(This is pseudo-code, like the way we write textual storyboards)
High-level languages
Def: a programming language that provides statements that are a closer match to the way humans solve problems than assembly language.
Why can't we just write programs in English (or any other spoken language)?
Examples
COBOL – business application languageFORTRAN – scientific application languageBASIC, Pascal – teaching languagesAda – designed and used for US military softwareSmalltalk – early object-oriented languageC, C++ - systems/general purpose languages
Can a program in a high-level language be executed on a computer?
High-level language translation
compiler – a program that translates a program written in a particular high level language into another form.
What form should a compiler output?
Compiled languages
High level languages that are translated into a machine language executable are called "compiled languages."
Executables might be called "native code."
HLL correspondence to AL
Benefit of HLL is being able to work in "bigger steps."
One HLL statement might translate to many AL/ML instructions
HLL correspondence to AL
Benefit of HLL is being able to work in "bigger steps."
One HLL statement might translate to many AL/ML instructions
sum = sum + value;
Java statement
HLL correspondence to AL
Benefit of HLL is being able to work in "bigger steps."
One HLL statement might translate to many AL/ML instructions
sum = sum + value;
Java statement Woody equivalent
CopyFrom sumAdd valueCopyTo sum
Hierarchy of abstractionHigh-level lang.program
Compiler
Assembly languageprogram
Assembler
Machine language program
Language closest to "how humans think."Input for compiler
Hierarchy of abstractionHigh-level lang.program
Compiler
Assembly languageprogram
Assembler
Machine language program
Translates programs from a specific HLLinto a particular architecture's assemblylanguage.
Hierarchy of abstractionHigh-level lang.program
Compiler
Assembly languageprogram
Assembler
Machine language program
"Human readable" form of a particulararchitecture's machine language. Input for assembler.
Hierarchy of abstractionHigh-level lang.program
Compiler
Assembly languageprogram
Assembler
Machine language program
Translates a particular architecture'sassembly language into that archi-tecture's machine language.
Hierarchy of abstractionHigh-level lang.program
Compiler
Assembly languageprogram
Assembler
Machine language program
Binary form executable versionof program.
Interpreted Languages
Interpreter – a program that can execute high-level language programs "directly," without first being translated to machine language.
Code in the interpreter emulates the circuitry that understands how to carry out each machine language instruction.
Some are "scripting" languages, used to stitch together existing executables to perform higher level tasks.
Examples
TCL/TK
Python
Windows Batch files/Windows Scripting Host
Perl
PHP – web scripting language
Compiled vs. interpreted
Compiled execution
Hardware follows instruction cycle for each machine language instruction in the executable
Interpreted execution
Interpreter translates HLL statement, then imitates hardware to execute it.
Interpreted pros and cons
Pros
Cons
"Hybrid" languages
Goal: High Level Language with platform-independent executable format, performance close to compiled languages.
How?
Examples
Java – originally intended for set-top TV/Video boxes, widely used on the web
C# - Supported by MS .Net platform, their answer to Java
How it works
Source program is compiled to an intermediate form – byte code
Byte code is the assembly language for an imaginary architecture
For each supported platform, write a "virtual machine" emulator that reads byte code and emulates its execution.
Java sourceprogram
Java compiler
JavaVirtualMachine
JavaVirtualMachine
JavaVirtualMachine
JavaVirtualMachine
WintelHardware
SunHardware
IBMHardware
MacHardware
Java byte code
Web server
HTMLJavaApplet
JavaApplet
JavaApplet HTML
HTML
JavaVirtualMachine
JavaApplet
JavaVirtualMachine
JavaApplet
JavaVirtualMachine
JavaApplet
webrequest web
request
webrequest
"Just In Time" compilation
JVMs actually compile each bytecode instruction to native code the first time it is used.
Subsequent executions of that instruction are faster.
Why would the same instruction be used again?
Computer Systems
A computer system is the combination of hardware and operating system
An operating system is the software that controls the overall operation of the computer, managing the processor, memory, files and attached devices
Computer System examples
PC – MS Windows OS running on Intel CPU
Mac – Mac OS running on IBM or Intel CPU
Linux – Linux OS running on Intel CPU
Unix – Unix OS running on various hardware platforms
IBM – OS/400 running on IBM servers