Programming Languages
Learning Outcomes:
Programming paradigms
- Be aware of the evolution of programming languages.
- Recognise the programming paradigms involved in procedural, logic, object-oriented and query languages.
- One programming language for each paradigm is selected for illustration.
- Describe the criteria for selecting a programming language for a specific problem.
Language translators and compilers
- Define code generation, linkers and loaders.
Programming paradigms
Procedural languages
- Examples: Pascal, C, Fortran
- Features/Advantages: top-down approach àeasy to trace program flow and logic.
Object-oriented languages
- Examples: Visual Basic, Java, C++, Python
- Features/Advantages:
- Entities represented by classes. An object belongs to a class. Each class has its own set of attributes and methods. E.g. CAR as an example of a class. My car (object) belongs to the class CAR. My car is white in color (attribute) and uses electricity to run e.g. move forward (method).
- Hide unnecessary information (encapsulation): you can use the class without showing the details of the class.
- Reuse of class/function (inheritance): derive a class from another class and reuses its attributes/methods.
- Utility libraries: pre-written code for specific tasks, helps to shorten software development time.
Logic languages
- Examples: Prolog
- Features/Advantages: Instead instructing the computer how to solve a problem, logic programming languages focus on what problem to solve by using the facts and rules given.
Criteria for selecting a programming language
- Examples:
- Cost
- Organisation policy
- Scalability
- Modularity
- Portability
- Availability of utility libraries
Relevant past paper:
DSE ICT Elect B(SP-2017):
PP 3f. 2012 1ci, 4c. 2013 4d. 2014 2d. 2015 2c. 2017 3d.
CE CIT 2005 3e.
Language translators and compilers
Code generation related: Translator – assembler, compiler,
interpreter
- Source code: low level or high level program code that is written by programmer.
- Translator: Translation of source code into format that is understandable by computer. i.e. object code, machine code.
- Machine code: machine code is generated by assembler from source code (low level program code). In general, execution of machine code is efficient.
- Object code: object code is generated by compiler from source code (high level program code). Further process is needed to convert the object code into executable file.
- Interpreter: Instead of generating an object code, interpreter translate the source code one statement at a time.
- Compiler vs interpreter: Compiler is more efficient as there is optimization of code during code generation.
Linker: A linker combines object code and the
required external libraries files into a single executable file
(.exe).
Loader: A loader loads the executable file to the main
memory for execution.
Relevant past paper:
DSE ICT Elect B(SP-2017):
PP 1c. 2012 1cii. 2013 2a. 2015 1ciii, 2d. 2016 1b. 2017 2e.
Learn more:
DSE ICT Elect B(SP-2017):
SP 4e.
AL CS2(2003-2012): 2007 8cde. 2009 6. 2011 5.
References:
https://www.geeksforgeeks.org/introduction-of-programming-paradigms/
https://hackr.io/blog/programming-paradigms
No comments:
Post a Comment