Week 10 - Compilers, Interpreters And Virtual Machines Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q
  1. ) What Type Of Instructions Does The CPU use to Function?
  2. ) Do Microprocessors Share The Same Machine Instructions?
  3. ) Machine Instructions Are Normally Written In What Form For Better Readability?
  4. ) Microprocessors Use Different “Flavour’s” of Which Set Of Functions?
A
  1. ) Machine Code
  2. ) No, Each Microprocessor Has It’s Own Unique Set Of Instructions.
  3. ) Assembly Language.
  4. ) Each Microprocessor Familly Has A Different Form of Assembly Language.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. ) Low Level Languages Have Access To What System Components (2 Answers)
  2. ) Low Level Instructions Focus On Efficiency And Can Be Translated…
A
  1. ) Memory And Registers

2. ) Directly To Machine Code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  1. ) High Level Languages Are Said To Have A High Level Of What…
  2. ) High Level Language Deal With… Such As: Arrays, Objects, Subroutines, Functions, Loops, String Handling And File Input/Output.
  3. ) Why Are High Level Language’s More Accessible Than Low Level Languages? (2 Answers)
  4. ) What Needs To Happen To A High Level Program Before It Can Be Used By The CPU?
A
  1. ) Abstraction.
  2. ) Complex, Abstract Concepts.
  3. )
    - 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. ) Which Types Of Programming Language Displays Polymorphism, Encapsulation and Inheritance (2 Answers)
  2. ) Which Type Of Programming Language Uses “Predefined and Well Organised Procedures, Functions Or Sib-Routines)
  3. ) Which Language Type Is Designed For Integrating And Communicating With Other Programming Languages.
A
  1. )
    - Object Orientated.
    - Functional.
  2. ) Procedural
  3. ) Scripting
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  1. ) Name The Two Primary Programs That Translate Source Code To Executable Code.
  2. ) How Does The Functionality Of These Two Methods Differ.
A
  1. )
    - Compiler
    - Interpreter
  2. )
    - 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  1. ) Compare The Execution Speeds Of A Compiler And Interpreter.
  2. ) Compare The Memory Requirements Of Code Executed By Compilers And Interpreters.
  3. ) Compare The Ease Of Debugging Of A Compiler And Interpreter.
A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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?

A

The Interpreter May Have To Translate The Same Line Of Code Multiple Times. This has A Negative Effect On Performance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  1. ) What Is The Purpose Of A Linker Program.

2. ) Detail The Process Of Producing An Executable File In An Unmanaged Environment.

A

1.) The Class Libraries Of A Language Are Linked With The Object Code.

  1. )
    - 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Modern Application Development Has Shifted To Using Managed Code.

What Are The Two Main Managed Environments Used To Run Managed Code?

A
  • Java

- .NET

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
  1. ) What Are The Issues With Running Unmanaged Code? (Three Answers)
  2. ) Why Are These Issues Difficult To Fix?
A
  1. )
    - 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!
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
  1. )What Is Managed Code Responsible For? (Three Answers)
  2. ) Name The Two Types Of Program Responsible For Managing Code.
  3. ) What Type Of Code Do The Above Programs Take As Input?
A
  1. )
    - Memory Management And Allocation.
    - Error Prevention.
    - Garbage Collection (Deallocating Unused Memory To Prevent Leaks)
  2. )
    - Run Time System (RTS)
    - Virtual Machine

3.) Intermediate Language
(Compiled By The JAVAC compiler in Java, and The Compiler Of The Language In .NET)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
  1. ) What Type Of Program Does Java Use To Manage Code? What Is It’s Name?
  2. ) Explain The Process Of Executing Java Code In A Managed Environment (Describe How The Code Changes)
A

1.) Java Uses A Virtual Machine Called The JVM (Java Virtual Machine)

  1. )
    - 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
  1. ) What Type Of Program Does .NET Use To Manage Code? What Is It’s Name?
  2. ) Explain The Process Of Executing .NET Code In A Managed Environment (Describe How The Code Changes).
A

1.) .NET Code Is Ran By A Run Time System. This Is Known As The Common Language Runtime (CLR)

  1. )
    - 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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
  1. ) Which MODERN Managed Environments Compile Their Intermediate Code?
  2. ) Which Method Of Compilation Is Mainly Used In A Managed Environment? What Format Of Code Does It Operate On?
A
  1. ) 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)
  2. ) Just In Time (JIT) - It Operates On Intermediate Code.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
  1. ) The CLR and JVM does What To The Intermediate (Native) Code It Receives As Input?
  2. ) When Is Performance Lost During The JIT Process? Why Is It Only Normally At This Point?
A
  1. ) The Code Is Segmented Into Smaller Sections.
  2. ) 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

In A JIT Compiler, When Are The Sections Of Code Compiled?

A

Just Before The Program Needs To Execute Them (Hence, “Just In Time)

17
Q

A Virtual Machine That Interprets Intermediate Language Will Run……. Than A Managed Environment That Uses Just In Time Compilation.

A

Slower.