I would like to discuss on how the ideas - Reuse, Scope, Code optimization and maintenance - drive one aspect of programming language design and ultimately its compiler or interpreter implementation.
To begin with, all or many existing programming languages up to some extent follow one or more of the fundamental paradigms such as - Functional, Declarative, Imperative/Procedural and Object Oriented.
A language is considered single paradigm type if it implements one of the paradigms and multi-paradigm language is the one which incorporates constructs from multiple paradigms.
Hence, we can derive the fact that all existing programming languages have many characteristics in common. Below are some of the most important to list:
1) Variable and Constants
2) Control Structures
3) Inheritance
4) Encapsulation
5) Abstraction
6) Functions or Subroutines or Procedures
7) Arithmetic and logic operations
8) Type
etc.,
Lets analyze the above mentioned constructs/features and see where we get lead to...
1) Variables, Constants and their assignment: These are required by any programming language since they fairly constitute the fundamentals of computation.
2) Control Structures:
-> Decision making features - if else, switch case - describe the direction of flow of program. This can again be categorized to be in the lines of computation.
-> Iterative structures - for, while, for each and do while - though describe the typical behavior of performing computation (Executing set of instructions) but highlight the point of Repetition. This is actually refers to a kind of modularity which is nothing but code reuse.
3) Inheritance: This is one of the best examples of code-reuse. Be it Class based inheritance from Java & C# or Prototype based inheritance in Javascript, both eventually indicate the fair usage of Code-Reuse concept. A subclass inheriting the superclass's properties plainly mean reusing existing methods and data. The whole purpose is to code-reduction and promote reuse.
4) Encapsulation: There are two thoughts to encapsulation
a) Bundling data and code to get a new data type: This though indicates that in creating a new datatype but under the hood it conceptualizes Reuse of existing code in the form of creating object which refers to data and methods(nothing but lines of code acting on the data bundled to it).
b) Access restriction on code: Imposing access restrictions such as public/private/protected mean nothing but deciding which blocks of code to be available to other developers to reuse to prevent misuse.
5)Abstraction: Concept of hiding the implementation details is called Abstraction. In case of Functional / Procedural languages, the functional/procedure is modeled as element of abstraction. Whereas in OOP, a class represents the unit of abstraction. So basically fundamental building block of a programming paradigm represents the level of abstraction. Lot has been said. Lot has been told about abstraction but finally what it means in terms of programming...Well this is also ultimately represents Code Reuse.
A function is defined as a block of code that can be called any number of times during computation of a problem. This facilitates developer to reuse same lines of code(if he wants to use) by calling the function/procedure/subroutine instead of re-writing the whole again.
Similar reasoning applies to Class in Java or C#. Where the lines of code along with data on which the methods apply are bundled into an element called Class and that can be reused if need be.
Based on the above scenarios, we can conclude that characteristic of abstraction is nothing but how efficiently it allows for code-reuse.
6)Functions or Subroutines or Procedures: They are introduced from the mathematical principles of set theory and functions.
Functions at last also are means of achieving re-usability of code.
7) Arithmetic and logic operations: Operations are nothing but the computations to be performed based on the instructions later resulting the desired output. Hence more or less they belong to category of Computation rather than language characteristic.
8) Data Type: Categorizing the data such as Text, Integers, float Binary etc - to manage memory efficiently and perform faster calculations is more of computational characteristic than something to do with code writing technique.
barring the computation features such as Variables, Constants, Control Structures, Arithmetic & logic operations, Data Types etc...rest of the characteristics - - one way or the other way have the following principles under the hood.
1)Reuse
2)Scope
3)Code maintenance
4)Maintenance
No comments:
Post a Comment