lecture 1 Flashcards
What is a compiler?
A compiler (for compiled languages) translates the entire
program into equivalent machine codes before carrying out any of the statements.
source code ⇒ machine code or executable
The machine codes are platform-dependent
What does platform-independent mean?
You can run it on any platform so any computer as the language is already translated in machine language.
Example of platform-dependent languages?
C, C++, Delphi.
What is an interpreter?
An interpreter (for interpreted languages) translates the program line-by-line, alternately reading lines and carrying out commands.
Why is an interpreter generally slower?
If a line was in a loop (or otherwise needed to be executed multiple times) it would be re-interpreted each time.
examples of interpreter languages?
R, PHP, Perl, Matlab.
Examples of combination and interpretation?
Java, Python, C#, Visual Basic.Net, Lua.
Both (compilation and interpretation) How does it work?
Compilation of the source code to byte code
A ”virtual machine” interprets the byte code into
computer-specific commands.
The byte code is platform-independent.
Features of java:
Distributed Multithreaded High performance Interpreted Dynamic Architecture Neutral Portable Robust Platform Independent Secured Simple Object-Oriented
History Of Java
It was called Oak- a language intended for small, embedded systems in electronic appliances like set-top boxes.
Originally developed by James Gosling at Sun Microsystems (which is now a subsidiary of Oracle Corporation).
Java is just a name, not an acronym. This name comes from an island of Indonesia where first coffee was produced (called java coffee).
How does a java program work?
Java code –> JAVAC(compiler) –>Byte code (.class) –>JMV (Java Virtual Machine) –> Windows (Or Linux Or Mac)
Stage 1: Compilation with a JAVAC compiler.
Stage 2: Interpretation ona Java Virtual Machine (JVM).
What is a Java Virtual Machine?
The Java Virtual Machine (JVM) is like a “hypothetical computer” which Java runs on, which means that instructions are not executed directly on the computer.
What are the benefits of a JVM?
- Java is fully platform-independent ”write once, run anywhere” (WORA)
- Java is secured.
Basics of Java :
The file name should match the class name.
A pair of braces { } encloses a group of statements (called ”a block”).
A statement ends with semi-comma ( ; )
Whenever JVM executes a program, it first looks for the
main() method. Not all classes are executable.
Takes a String[] as an argument