View
241
Download
4
Embed Size (px)
Citation preview
What to Do
Set up for Java Programming
Write our first Java Program with IDE
Write our first Java Program without IDE
Review
Computer
Computer: a device for data processing.
von Neumann architecture is used by all digital computers. • It runs stored programs. • It has the following basic components:
Memory, IO, CPU, Secondary Storage.
Computer Programs are stored instructions for data processing. They are composed of
Programming is to define Data Structures to store data and Algorithms to process data.
Types of Programming Languages
Machine Languages: binary opcodes, hardware dependent. Hard to program and not portable. Programs are called binary code and are understandable by the targeted hardware.
Assembly Languages: English-like instructions, platform/OS dependent. Easier to program but not portable. Programs are called assembly code and need to be translated into binary code.
High-level Languages: English-like instructions, platform/OS independent. Easy to program and portable. Programs are called source code and need to be translated into binary code.
Special Programs
• Operating System: a program that manages a computer (its memory, CUP, SS, IO (networking)).
• Compiler: a program that translates source code written in a high-level programming language into binary code.
• Loader: a program load an executable into memory for execution.
• Linker: a program that links all related binary codes (libraries) together to make an executable.
• Editor: a program that can be used to write source code.
IDE (Integrated Development Environment)
• Contains an editor, a compiler, a linker/loader, a debugger, sometimes, a profiler, a source code version controller, and other tools.
• A complete environment for developing software.
• Always provides library programs for performing common tasks.
Setting Up Your Computer for Java Program Development
• The lab computers are set for Java program development.
• Follow the instructions in “Before You Begin” in the textbook to set up your own computer.
• You can also follow the instructions at
Creation of a C++ program
Source File (.cpp)
Intermediate File (.I)
Object File (.obj)
Binary File (.exe)
Preprocess
Compile
Link
Edit
Load
Creation of a Java program
Source File (.java)
Binary Byte File (.class)
Native Binary Code
Preprocess/Compile
JRE/JVM: load/valid/translate/execute
Edit
Creation of a Java Program
• Creation Source code : use a text editor (Notepad) to write the source code. Java source code (.java) is portable to all platforms as long as there is a java compiler. notepad ics.java
• Compile the source code: Java source code are converted into Java bytecode (.class) by the Java compiler (javac.exe). Java byte code are portable to all platforms as long as there is a Java runtime environment. javac ics.java
• Run the bytecode: Java bytecode (.class) are executed by the Java virtual machine. java ics
Traditional Compilation
Source Code for Language 1
Language 1 Compiler on OS1
Binary Code for OS1
OS1
Source Code for Language 1
Language 1 Compiler on OS2
Binary Code for OS2
OS2
OS-Independent Code: Intermediate Languages
The trend to support machine-independent binary code is to compile the source code into the binary format of an intermediate language.
And to provide an interpreter for the intermediate language on each OS to translate the binary code of the intermediate language into the native binary code of the OS.
OS-Independent Compilation: Intermediate Language
Source Code for Language 1
Language 1 Compiler on OS1
Intermediate Binary Code for Language1
OS1
Intermediate Code Interpreter OS1
OS2
Language 1 Compiler on OS2
Binary Code for OS2Binary Code for OS1
Intermediate Code Interpreter OS2
Java Intermediate Language: Java Bytecode
Java Source Code (.java)
Java Compiler (javac) on OS1
Java Bytecode (.class)
OS1
Java Interpreter on OS1 (java)
OS2
Java Compiler (javac) on OS2
Binary Code for OS2Binary Code for OS1
Java Interpreter on OS2 (java)
Program statements are interpreted one at a time during the run-time.
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 Compiler (javac) on OS1
Java Bytecode (.class)
OS1
Java JIT Compiler on OS1
OS2
Java Compiler (javac) on OS2
Binary Code for OS2Binary Code for OS1
Java JIT Compiler on OS2
All programming statements are compiled at compile time.
.NET OS-Platform-Independence
MSIL: Microsoft Intermediate Language (Used by .NET)
Source Code for Language 1
Language 1 Compiler on OS1
MSIL Code
OS1
MSIL JIT Compiler on OS1
OS2
Language 1 Compiler on OS2
Binary Code for OS2Binary Code for OS1
MSIL JIT Compiler on OS2
JIT Compilation in .NET
All MSIL code are JIT-compiled to native binary code before execution. No run-time interpretation, faster execution.
.NET Common Language Runtime
To make .NET language independent, CLR (Common Language Runtime) is defined as the runtime environment.
CLR defines CTS (Common Type System) which should be followed by all languages to be used in the .NET framework.
The code that follows CTS standard and runs through CLR is called managed code.
.NET Language-Independence
CLR: Common Language Runtime
Source Code for Language 1
Language 1 Compiler on OS1
MSIL Code Confirming CTS (Managed Code)
OS1
CLR on OS1
OS2
Language 2 Compiler on OS2
Binary Code for OS2Binary Code for OS1
CLR on OS2
Source Code for Language 2
.NET Architecture for Language and Platform Independence(fan-in and fan-out on MSIL)
Source Code for Language 1
Language 1 Compiler on OS1
OS1
CLR for OS1
OS2
Language 2 Compiler on OS2
Binary Code for OS2Binary Code for OS1
CLR for OS2
Source Code for Language 2
MSIL Code Confirming CTS (Managed Code)
CLI : Common Language Infrastructure
A specification defines an environment for multiple high-level languages to be used on different computer platforms.
Created by Microsoft based on .NET, standardized by MS, Intel, HP and others, ratified by ECMA and ISO.
.NET is an implementation of CLI for desktop systems.
.NET Compact Framework is an implementation of CLI for portable devices.
Open Source implementations: Mono development platform (Novell), Portable .NET (dotGNU)
CLI (Common Language Infrastructure) SpecificationOpen Architecture for Language and Platform Independent Programming
Source Code for Language 1
Language 1 Compiler on OS1
OS1
CLR for OS1
OS2
Language 2 Compiler on OS2
Binary Code for OS2Binary Code for OS1
CLR for OS2
Source Code for Language 2
CIL (Common Intermediate Language) Code
Confirming CTS (Common Type System)
A Common Language for the Internet
ASCII text (ISO/IEC 8859-1) is platform-independent.
=> HTTP (Hyper Text Transport Protocol)
=> Recognizable by all types of computers. (World Wide Web)
=> Everything is presented as text including data and programs.
Tim Berners-Lee
=> HTML (Hyper Text Markup Language)
A Common Language for the Internet
XML (eXtensible Markup Language), can be used to define data and programs over the Internet.
=> SOAP (Simple Object Access Protocol), XML-based
=> WSDL (Web Service Description Language), XML-based
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