Test Yourselves Is there an error below (yes/no) and if (yes) what type of error: a) Object x = new JPanel(“1”); b) int int = 5; c) String string = “string”; d) x+++ 1;
Program Processing: Interpretation Interpreter is a program that translates in runtime and executes each statement in the high level-language. Advantages: § No separate compilation phase (quicker program development); § Good debugging information since the source code is being executed. § Abstraction Disadvantages: § Slow execution § Can use more memory space Why?
Program Processing: Compilation § Compiler is a program that translate the entire code from source to assembly code. § Assembler. § Linker resolves external references (e.g., bring in code from libraries) object code (binary) linker Executable binary for a specific machine other objects source program assembler assembly program compiler
Program Processing: Compilation Advantages: § Faster than interpretation § Good for multi-module programs Disadvantages: § Separate compilation phase § May lose debugging info
C and C++ § Microsoft Visual Studio § Apple XCode § Clion https://www.jetbrains.com/clion/ § Online Compiler for C/C++ https://www.onlinegdb.com/online_c_compiler § Dev-C++ 5 http://www.bloodshed.net/devcpp.html
Program Processing Program Processing Interpretation LISP Prolog Compilation C C++ Two Step Translation with Intermediate Code Compilation + Interpretation Java Compilation + Compilation C++ (.Net Solution) C# (.Net Solution)
Program Processing: Intermediate Code (Java) Intermediate code make the language and compiler machine-independent. This concept was implemented in 1970’s to simplify the compiler design. It is used in Java. bytecode Java program javac Java virtual machine Interpreter on a specific machine Simulator or Hardware source program intermediate code Virtual machine compiler
Program Processing: Intermediate Code (.Net) Microsoft uses an intermediate code for its Common Language Runtime (CLR) environment (.Net Runtime Environment), which is independent of languages Prolog F# X F# compiler Prolog compiler X compiler JIT AND CLI C# Languages MS IL Just-In-Time compiler Intermediate Language Common Language Infrastructure Compilers C# compiler C++ C++ compiler C C compiler Simulator or Hardware
Program Processing: Intermediate Code Advantages: • A single compiler for all machines • A small virtual machine (interpreter) that even fits in a web browser Disadvantages: § Slow execution and memory space § Separate compilation phase and may lose debugging info
Program Processing Program Processing Interpretation LISP Prolog Compilation C C++ Two Step Translation with Intermediate Code Compilation + Interpretation Java Compilation + Compilation C++ (.Net Solution) C# (.Net Solution)
[email protected] Spring 2022 Copyright. These slides can only be used as study material for the class CSE240 at Arizona State University. They cannot be distributed or used for another purpose.