Download High-level Languages

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
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 file
If the value is negative, then
add it to the list of expenditures
Otherwise
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 language
FORTRAN – scientific application
language
BASIC, Pascal – teaching languages
Ada – designed and used for US military
software
Smalltalk – early object-oriented language
C, 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
Java statement
sum = sum + value;
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
Java statement
Woody equivalent
sum = sum + value;
CopyFrom sum
Add value
CopyTo sum
Hierarchy of abstraction
High-level lang.
program
Compiler
Assembly language
program
Assembler
Machine language
program
Language closest to "how humans think."
Input for compiler
Hierarchy of abstraction
High-level lang.
program
Compiler
Assembly language
program
Assembler
Machine language
program
Translates programs from a specific HLL
into a particular architecture's assembly
language.
Hierarchy of abstraction
High-level lang.
program
Compiler
Assembly language
program
Assembler
Machine language
program
"Human readable" form of a particular
architecture's machine language.
Input for assembler.
Hierarchy of abstraction
High-level lang.
program
Compiler
Assembly language
program
Assembler
Machine language
program
Translates a particular architecture's
assembly language into that architecture's machine language.
Hierarchy of abstraction
High-level lang.
program
Compiler
Assembly language
program
Assembler
Machine language
program
Binary form executable version
of program.
Interpreted Languages
Interpreter – a program that can execute highlevel 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 platformindependent 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 source
program
Java compiler
Java byte code
Java
Virtual
Machine
Java
Virtual
Machine
Java
Virtual
Machine
Java
Virtual
Machine
Wintel
Hardware
Sun
Hardware
IBM
Hardware
Mac
Hardware
Java
Virtual
Machine
Java
Applet
Java
Virtual
Machine
Java
Virtual
Machine
Java
Applet
web
request
Java
Applet
web
request
web
request
HTML
HTML
Java
Applet
Web server
Java
Applet
HTML
Java
Applet
"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