Professional Documents
Culture Documents
Yingcai Xiao
Want to know? What is a computer? (From a programmers point of view). Why we have to write programs to run a computer?
Programming a Computer
Programming a Computer
Types of Computers Analog: Analog Device, 1.2345678 Digital: Binary Device, 0 or 1 Programming a Computer Wiring: Hardware, Bug, Ada Coding: Software Modern Computers: Voneumann Machines Run stored programs (code reuse) to process stored data. Components: Memory, IO, CPU, Secondary Storage.
What is a program and what is programming? Programs: stored instructions for data processing. Programming = Data Structures + Algorithms
Programs: Stored binary opcodes Different types of computers have different opcodes Opcodes are not reusable on different types computers Programs in binary codes are not reusable on different types of computers
How data are stored on a computer? Bits (0/1) and bytes (0-255):
0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
Endian (byte ordering): little (Intel), big (Moterola, Sun), bi (DEC Alpha, MIPS), big-to-bi (Sun SPARK v9)
Is data reusable?
Is data saved on one type of computers reusable on another type of computers?
No, in general. Yes, for ASCII text or any type of a byte in size.
ASCII text (ISO/IEC 8859-1) is platform-independent.
0 1 0 0 0 0 0 1
A (65)
Punch Card Programming: punch card machines converts instructions typed into binary codes (0 no hole, 1 hole) on a stack of cards.
Programming Languages
Assembly Languages
English-like: load, add, save
Assembler: a program that translates code written in an assembly language into opcodes.
Assembly languages are machine-dependent. An assembly language is only valid for a specific CPU architecture.
Programs written in an assembly language are machine-dependent and not reusable on a different types of CPU architectures.
Linker: a program that links object codes together to make an executable (.exe).
Object-codes and executables are machine-dependent. High-level languages are machine-independent.
Binary codes (.obj, .lib, .dll, .exe) compiled from a high-level programming language are reusable on the computers of the same architecture but not reusable on computers of different architecture.
Traditional Compilation
Source File (.cpp) Preprocessing
Linking
Binary File (.exe)
Traditional Compilation
Source Code for Language 1 Source Code for Language 1
OS1
OS2
Intermediate Binary Code for Language1 Intermediate Code Interpreter OS1 Intermediate Code Interpreter OS2
Java Bytecode (.class) Java Interpreter on OS1 (java) Java Interpreter on OS2 (java)
JIT Compiler
An interpreter interprets intermediate code one line at a time. Slow execution. A JIT (Just-In-Time) compiler compiles the complete code all at once just into native binary code before execution. Faster execution.
JIT Complier: Java Bite Code Compiler Java Source Code (.java)
Java Bytecode (.class) Java JIT Compiler on OS1 Java JIT Compiler on OS2
MSIL: Microsoft Intermediate Language (Used by .NET) Source Code for Language 1
MSIL Code MSIL JIT Compiler on OS1 MSIL JIT Compiler on OS2
.NET OS-Platform-Independence
CLR: Common Language Runtime Source Code for Language 1 Source Code for Language 2
MSIL Code Confirming CTS (Managed Code) CLR on OS1 CLR on OS2
.NET Language-Independence
.NET Architecture for Language and Platform Independence (fan-in and fan-out on MSIL)
MSIL Code Confirming CTS (Managed Code) CLR for OS1 CLR for OS2
CLI (Common Language Infrastructure) Specification Open Architecture for Language and Platform Independent Programming
CIL (Common Intermediate Language) Code Confirming CTS (Common Type System) CLR for OS1 CLR for OS2
Web Services Libraries shared over the Internet at run-time. Service interfaces specify what the services can do (contracts). Service interfaces are defined in WSDL (Web Service Description Language) UDDI Registry: Universal Description, Discovery, and Integration. (yellow page) Access Standard: SOAP: Simple Object Access Protocol
Programming
Client 2
UDDI Registry 1
Web Service 1
WSDL Interface 1
SOAP
WSDL Interface 2