Week 10 - Compilers, Interpreters And Virtual Machines Flashcards
- ) What Type Of Instructions Does The CPU use to Function?
- ) Do Microprocessors Share The Same Machine Instructions?
- ) Machine Instructions Are Normally Written In What Form For Better Readability?
- ) Microprocessors Use Different “Flavour’s” of Which Set Of Functions?
- ) Machine Code
- ) No, Each Microprocessor Has It’s Own Unique Set Of Instructions.
- ) Assembly Language.
- ) Each Microprocessor Familly Has A Different Form of Assembly Language.
- ) Low Level Languages Have Access To What System Components (2 Answers)
- ) Low Level Instructions Focus On Efficiency And Can Be Translated…
- ) Memory And Registers
2. ) Directly To Machine Code.
- ) High Level Languages Are Said To Have A High Level Of What…
- ) High Level Language Deal With… Such As: Arrays, Objects, Subroutines, Functions, Loops, String Handling And File Input/Output.
- ) Why Are High Level Language’s More Accessible Than Low Level Languages? (2 Answers)
- ) What Needs To Happen To A High Level Program Before It Can Be Used By The CPU?
- ) Abstraction.
- ) Complex, Abstract Concepts.
- )
- They Are Written To Be More Natural And Human Language Focused. They Are Designed For Ease Of Use.
- They Hide Away The Inner Workings Of The System (e.g. Memory Management) Thus Simplifying The Development Process For The Programmer.
4. ) It Needs To Be Translated Into Machine Code.
- ) Which Types Of Programming Language Displays Polymorphism, Encapsulation and Inheritance (2 Answers)
- ) Which Type Of Programming Language Uses “Predefined and Well Organised Procedures, Functions Or Sib-Routines)
- ) Which Language Type Is Designed For Integrating And Communicating With Other Programming Languages.
- )
- Object Orientated.
- Functional. - ) Procedural
- ) Scripting
- ) Name The Two Primary Programs That Translate Source Code To Executable Code.
- ) How Does The Functionality Of These Two Methods Differ.
- )
- Compiler
- Interpreter - )
- A Compiler Receives The Entirety Of The Source Code And Converts It To Object Code. A Program Must Be Recompiled If An Errors Occurs At Runtime.
- The Interpreter Runs Through Each Line Of Code Sequentially. If An Error Occurs Whilst Executing A Line Of Code, The Program Terminates.
- ) Compare The Execution Speeds Of A Compiler And Interpreter.
- ) Compare The Memory Requirements Of Code Executed By Compilers And Interpreters.
- ) Compare The Ease Of Debugging Of A Compiler And Interpreter.
1.)
Compiler - Faster As A Single Pass For Error Checking Is Made.
Interpreter - Slower, as Interpreter Checks For Errors After Each Line Is Executed.
2.)
Compiler - More Memory Intensive As Object Code Is Created.
Interpreter - Less Intensive, No Object Code Created.
3.)
Compiler - Long Winded and More Laborious, User Has To Recompile And Scour Through The Entire Program To Correct Errors.
Interpreter - Simple, Program Terminates Whenever An Error Is Detected, Inmediately Indicating The Errors.
Potentially, What Could An Interpreter End Up Doing When A Method/Recursive Function Is Called? How Will This Effect The Program In Terms Of Performance?
The Interpreter May Have To Translate The Same Line Of Code Multiple Times. This has A Negative Effect On Performance.
- ) What Is The Purpose Of A Linker Program.
2. ) Detail The Process Of Producing An Executable File In An Unmanaged Environment.
1.) The Class Libraries Of A Language Are Linked With The Object Code.
- )
- Source Code Is Written.
- Source Code Is Compiled Into Object Code.
- Object Code Is Linked With Class Libraries By The Linker To Create The Executable File.
Modern Application Development Has Shifted To Using Managed Code.
What Are The Two Main Managed Environments Used To Run Managed Code?
- Java
- .NET
- ) What Are The Issues With Running Unmanaged Code? (Three Answers)
- ) Why Are These Issues Difficult To Fix?
- )
- Unmanaged Code Easily Allows The User To Accidentally Overwrite Variable Contents And Memory Locations That They Didn’t Mean To Change.
- Unmanaged Code Allows Users To Easily Exceed The Memory Constraints Of Their Program.
- “Memory Leaks” Are Common In Unmanaged Code. This is Where The User Forgets To Deallocate Memory, Thus Making It Unavailable For The Program And Reducing Performance.
2. ) Unmanaged Code Makes It Difficult To Detect And Locate These Problems!
- )What Is Managed Code Responsible For? (Three Answers)
- ) Name The Two Types Of Program Responsible For Managing Code.
- ) What Type Of Code Do The Above Programs Take As Input?
- )
- Memory Management And Allocation.
- Error Prevention.
- Garbage Collection (Deallocating Unused Memory To Prevent Leaks) - )
- Run Time System (RTS)
- Virtual Machine
3.) Intermediate Language
(Compiled By The JAVAC compiler in Java, and The Compiler Of The Language In .NET)
- ) What Type Of Program Does Java Use To Manage Code? What Is It’s Name?
- ) Explain The Process Of Executing Java Code In A Managed Environment (Describe How The Code Changes)
1.) Java Uses A Virtual Machine Called The JVM (Java Virtual Machine)
- )
- Source Code Is Written As a .java file.
- The .java File Is Then Compiled By The JAVAC Compiler Into A .class File (Byte Code).
- The Virtual Machine Executes The .class File And Runs It In In Accordance To The Requirements Of The Operating Systems On The System.
- ) What Type Of Program Does .NET Use To Manage Code? What Is It’s Name?
- ) Explain The Process Of Executing .NET Code In A Managed Environment (Describe How The Code Changes).
1.) .NET Code Is Ran By A Run Time System. This Is Known As The Common Language Runtime (CLR)
- )
- Source Code (E.g. C++, C#, F#) Is Compiled By The Languages Compiler.
- The Compiler Converts The File Into Microsoft Intermediate Language (MSIL).
- The MSIL File Is Passed To The Common Language Runtime (CLR) Which Executes The Program (Outputs Machine Code)
- ) Which MODERN Managed Environments Compile Their Intermediate Code?
- ) Which Method Of Compilation Is Mainly Used In A Managed Environment? What Format Of Code Does It Operate On?
- ) Both The CLR and The JVM (Early JVM’s Used To Interpret The Intermediate Code, However This Was A Slow Process And Eventually Was Replaced)
- ) Just In Time (JIT) - It Operates On Intermediate Code.
- ) The CLR and JVM does What To The Intermediate (Native) Code It Receives As Input?
- ) When Is Performance Lost During The JIT Process? Why Is It Only Normally At This Point?
- ) The Code Is Segmented Into Smaller Sections.
- ) A Performance Hit Is Taken Whenever A Section/Method Is FIRST Called. Any Subsequent Method/Section Calls Are Executed At Normal Speed. This Is Because Sections Are Cached When Executes And Can Then Be Quickly Accessed By The RTS/VM.