End of document!
3.5 Translators and IDEs - Contents
In this chapter, you will learn:
Programming Language Generations
Programming languages can be classified into several programming language generations. Theses indicate how "close" to the hardware the language is; some languages are fairly far removed from the hardware and utilize closer to English syntax, thus are labelled as higher level than their closer to hardware counterparts.
The first two generations, generation 1 and 2, are known as low level languages, as they are close to the hardware. Higher level languages are considered high level as they are further removed from the hardware, requiring translators to be understood by the computer.
1st Generation - Machine Code (binary)
Machine code is directly executable by the processor, making it the lowest level programming language available. This is the generation that “computers understand” directly with no usage of a translator. The drawback of this generation is that it is difficult to program, hard to understand, and hard to debug.
2nd Generation - Assembly language
Assembly code uses mnemonics to represent binary opcodes. It’s easier to program than machine code, but is still fairly difficult as it requires a firm understanding of computer hardware. One Assembly instruction translates to one Machine Code Instruction; thus this is referred to as a 1-1 relationship. It is a simplification of the machine code; translation is on a 1 to 1 basis.
Third generation languages, such as Java, BASIC, Pascal and C++ are easier to understand, and easier to debug. This is because they use English-like keywords. However, unlike assembly language, each instruction in these languages translate into many machine code instructions.
These languages are required to be translated, either via a compiler or an interpreter.
These languages are known as declarative languages, as it describes what computations should be performed, rather than how to specifically perform it. These languages use English-like keywords, that are even further removed from machine code. Examples include SQL, and Unix Shell commands.
The main difference within fourth generation languages, is that these allow you to manipulate groups of items as a group, rather than individually. The clearest example of this is within SQL, where you manipulate datasets rather than values individually.
Programming languages that are not written in machine code must be translated into machine code before they are ran and executed. This is because computers can only understand machine code. There are different types of translators.
Source code is the original instructions listing the commands to be compiled or assembled into an executable computer program. Once this has been compiled into a program, this is referred to as object code.
The assembler translates the mnemonics of assembly language into machine code. As assembly language is very similar to machine code, thus it is a 1 to 1 conversion.
A compiler reads the entire code, and then translates the entire source code into machine code. This is outputted into a new file. The translation is done once only, thus saving resources at runtime. The code is much faster to execute, as it has already been processed.
However, if it encounters any errors, the programmer will have to use the error messages outputted to debug the software. You also cannot recreate the source code, from the compiled runtime applet. You cannot change the program, without the original source code, editing, then recompiling.
An interpreter reads each line individually and converts it into machine code at runtime. The next line is read, and converted, and so on. This has to be done every time the program is ran.
An advantage over compilers is that the error can cause a code interrupt; this means it’s much easier for a programmer to troubleshoot the code at runtime. The program can be easily edited, as the source code always exists.
However, extra processing time is taken at runtime, as it has to convert instructions as it runs. This means that it is slower. Another issue is that if the software needs to be distributed, others can take a look at the source code of the software.
IDEs, or integrated development environments, give useful tools for a developer to be able to write their code.
Within an IDE, it has many functions that allow for easier programming of software.
For instance, automatic indenting allows the programmer to keep their code clean and automatically indented, without having to manually type it in. Additionally, autofill for variable names and common functions saves the programmer time for typing common phrases.
The IDE will also show unique formatting depending on the programmers preference. Variables and functions can be shown in unique colours, to ensure that they are easily distinguishable in code. It also allows changing the size of the font on-screen, making it easier to read the code.
Tools such as find and replace, if a variable name is being changed, can also speed up time taken to produce code.
If a project is made up of multiple assets and scripts, an IDE can give a file browser and management area, to make it easy to access and change different files and assets within the project.
Run-time environments and Translators
Some IDEs are designed for languages that are interpreted; these IDEs provide a run-time environment for code to be interpreted and outputted to. Other languages are translated, so some IDEs provide a built in environment for automatically compiling the source code into a binary.
Errors can crop up during development, whether those be syntax, logic or semantic errors.
A syntax error is an error that occurs since the syntax of the language is not respected. This is usually because one of the rules of the language is not respected within the code. An example would be, in a language that requires it, missing out a semi-colon, or having a bracket in the wrong place. The language would not be able to parse these mistakes.
Logic errors are caused by the algorithm that has been implemented being incorrect. If a piece of code is meant to multiply, but is programmed to minus, this would be a logic error, as the software would still run, but would instead output the incorrect value.
Finally, semantic errors occur when there are incorrect usage of specific language statements. For instance, psuedocode would not take into account importing libraries, or errors caused by arrays being out of bounds. It also would not take into account casting errors, or variables that haven’t been initialized.
Tools within your IDE allow you to debug your software with ease. An example would be tools that give detailed breakdowns of errors at compile time. If a syntax or semantic error is found, it will flag up at compile time, and some IDEs give recommendations for how these errors can be fixed.
Breakpoints are another feature that some IDEs allow. This allows you to create a breakpoint, where it will pause execution of the code when it reaches a certain line. This then allows you to look through the variables that have been declared, and individually step through your code line by line to ensure the program is running correctly.
End of document!