Application Generation
The Nature of Applications
An application is a program or set of instructions that runs on a computer. Application software comes in many forms. It can be general purpose software also called used by almost anyone but especially office workers e.g. presentation software. Or it can be specialist software designed for a particular task e.g. webcam software. Bespoke software is custom built to fulfill the user's exact requirements. It is therefore expensive. The risk of bespoke software is that it is not "tried and tested" and is more likely to contain bugs. Most software users buy "off the shelf" software which is cheaper but is not tailored to our specific needs. Since off the shelf software has many users you can often find help and advice in online communities.
Open Source versus Closed Source
Open source software is freely available to edit and recompile. This means that the user can tailor it to their needs. If you find a bug in open source code, you can feel free to fix it yourself (Given that you have the expertise)! You could also make it work on different platforms.
Some or all of open source may be written by non-experts. It tends to have a community of developers who develop and improve the code. These are great experts to learn from. You can also see all open source code, so you can check for vulerabilities, malware, etc.. Adapting open source is quicker and cheaper than creating your own code from scratch.
Closed source software is typically distributed in binary form. It is typically written by people paid to do so. You can not easily see the code. Closed source is restrictivly licensed so you can’t freely inpect, modify, use and/or redistribute it. Licensing means you have the right to use the software only1.
What’s the difference? Translators, Interpreters, Compilers and Assemblers
Depending on the programming language you choose. There are many ways to get your code to run.
Translators is a general term for something that allows source code to be run by a processor. There are three types:
- Interpreters are used by scripting languages such as Python and JavaScript. They translate high level code line by line each time that it is run. So the user would need the source code to run the program. They are machine independent, they can run on any machine.
- Compilers translate the source code into an executable prior to distribution. Since the user receives the executable it is much harder to amend it. It is also machine dependent, it won’t run on any machine.
- Assemblers convert assembly language into machine code.
Which translator should use you? It depends on the scenario. For example do you need higher security or code that will run on many different platforms?
Stages of Compilation
Each of the stages below are carried out in order. The stage does it’s job and then passes on its results to the next stage.
- Lexical Analysis
- This is the state where elements unnecessary elements such as comments and white space are removed.
- Tokenisation. This is where the code is parsed into lexemes. These are are added to a symbols table.
- Lexemes are checked against the language rules, For example in most high level languages you can’t have a variable called *while *as *while *is a reserved word.
- Syntax Analysis
- Tokens are checked to ensure that they the correct order to comply with the rules of the language. For example
Console.Writeline(“Hello”)
, notConsole.Writeline)Hello(
.
- Tokens are checked to ensure that they the correct order to comply with the rules of the language. For example
- Code Generation
- This is where the object code is created. This is a binary form of the source code.
- Optimisation
- The last stage is to optimise the code - remove repeated or unnecessary code and rearrange as necessary.
Linkers and Loaders and the Use of Libraries
Expert code is modular and often makes use of libraries. Libraries are pre written sections of code containing useful routines. They are tried and tested and save the time of creating the code oneself. The downside of libraries is that you have to trust that they have been tested (or test them yourself). You also need to become familiar with how to use them.
Libraries can be dynamic such as DLLs. DLLs are loaded when needed and can be shared by many programs. This saves memory. Static libraries are compiled into the executable creating a larger executable but avoiding any delaying in linking at run time.
Linkers
When code is compiled many object files are created. Linkers use these to build the executable resolving any cross references between the files. Linkers also link external libraries into the executable (static libraries) or by pointing the executable at the library (dynamic libraries).
Loaders
The loader is part of the operating system. As a program is executed the loader prepares the executable and copies it into RAM.
In reality, there are many different types of license, which vary in what they allow you to do. Open source code is also licensed aswell, it's just the licenses of open source and closed source code grant more or less freedoms respectivly.