The dominant reason why object oriented programming languages have become successful is because of its ability to split larger problems into classes. Without this feature, the program code is stored in a single large file in which hundred of functions have access to hundred of variables. On the other hand, many larger programs were written in Forth and Ansi C without any sort of OOP feature so it seems, that some sort of hidden technique is available which works similar to object oriented programming.
What Ansi C programmers are aware of it is the module concept. A module is a file in which the scope of the functions and variables is limited to this file. it is possible to set a value in a module like “module1.msg=”hello world” and that call a function in that module with “module1.show()”. This allows to simulate object oriented programming.
Modular programming allows to reduce complexity without introducing dedicated OOP techniques. This allows to use much simpler compilers like the ansi C compiler or even minimalist languages like Forth. The question is not if a certain programming supports objects but if the concept of modules is available. Similar to OOP programming modular programmings allows to split larger problems into smaller one. Each function is limited to a single module and this allows to solve the problem in general. The pascal language which lacks also of OOP features has of course the feature to utilize modules. In pascal a module is called a unit and similar to C it is stored in a single file. From the perspective of Java and Python a single pascal unit is equal to a class which has variables and methods.
No comments:
Post a Comment