Difference between revisions of "Programming Language Translators"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Overview)
Line 4: Line 4:
  
 
https://www.youtube.com/watch?v=qHM4rtpYuxE&list=PLCiOXwirraUDJYD-VxmztyhsDP0QM2BHW&index=3
 
https://www.youtube.com/watch?v=qHM4rtpYuxE&list=PLCiOXwirraUDJYD-VxmztyhsDP0QM2BHW&index=3
 +
 +
===TRC PowerPoint===
 +
[https://studentthomrothac-my.sharepoint.com/:p:/g/personal/wayne_jones_thomroth_ac_uk/ERiDVYQq3f1Kr8MN5DiKZY4BIdym_KE-RcGjNk_FB772_g?e=Awfq57 Language Translators]
  
 
=Assembler=
 
=Assembler=

Revision as of 10:17, 17 September 2018

Overview

https://www.youtube.com/watch?v=qHM4rtpYuxE&list=PLCiOXwirraUDJYD-VxmztyhsDP0QM2BHW&index=3

TRC PowerPoint

Language Translators

Assembler

An assembler translates assembly language into machine code. One line of assembler will create a single line of machine code, because the assembler mnemonic is converted into the binary instruction.

Compiler

A compiler translates code written in a high level programming language into object code, the machine code of a particular machine. It 'compiles' the entire source code before translating it. The compiler has several advantages over interpreters, such as: the object code is saved, meaning there is no need to re-compile; compiled code executes faster than interpreted code; the object code can easily be distributed without the compiler; and compiled code is more secure, as it is harder to reverse engineer than interpreted code.

Interpreter

An interpreter also translates code written in a programming language into object code, but unlike a compiler it does this one line of code at a time. This makes it slower to run than a compiler, but interpreters are useful for partially testing or debugging programs.

Compiler vs Interpreter

Compiler over Interpreter

  • Object code is saved, so you only need to compile once so no need to re-compile. Obviously if the code is changed it will need to be re-compiled.
  • Executes faster than interpreted code, because interpreted code is interpreted and execute one at a time. Compiled code is simply executed.
  • Object code can be distributed (without the compiler).
  • Secure because the source code is hidden, the compiler generated object code is not easily reverse engineered.
  • Compilers can be more efficient, for example an interpreter must interpret and then execute each time it passes through a loop. Compiled code can just execute each time through the loop.

Interpreter over Compiler

  • Easier to partially test or debug programs, it will run until an error is reached. This will therefore allow you to test code that you haven't completely finished.

Types of Code

Source Code

The code written by the programmer.

Object Code

The code generated by compiling your source code. This object code can then be executed without the need to recompile.

Byte Code

Compilers & Interpreters would suggest there are clear divides between the languages which are interpreted and the languages that are compiled. This is not the case, some languages use both. The source code is first compiled into byte code, and then when run the byte code is then interpreted.

Languages such as Java work in this way. Java code is compiled into byte code which can then be distributed onto any platform. This is because the byte code is an instruction set than can be executed in a virtual machine. The virtual machine can then emulate the architecture of a computer allowing the byte code to be executed on any platform.

https://www.youtube.com/watch?v=gWKoW_Z5Liw&list=PLCiOXwirraUDJYD-VxmztyhsDP0QM2BHW&index=4