CSC/ECE 517 Fall 2009/wiki2 6 ee
Hybrid Object Oriented Programing Languages
Hybrid Object Oriented Programming Languages are object oriented languages that also include one or more additional programing paradigms. Commonly, hybrid object oriented languages include procedural and functional programing features, in addition to being object oriented. Having multiple paradigms embraced in one language adds flexibility to the developer, letting them leverage the most appropriate programing methods, without having to switch languages.
Programing Paradigms
Before delving into Hybrid Languages, here is a quick review of the paradigms we will be discussing.
Object Oriented Programming
In Object Oriented Programming, code is grouped together into collections called Objects. Objects keep track of data and contain methods relevant to the data of the object. An object is described by a class. In order for an object to be used, it must be instantiated from a class. Objects can utilize other objects to help represent their data in meaningful ways (ie a school object can have many student objects).[1]
Procedural Programming
With procedural programming, operations are listed one after another in the order they are to be executed. Procedural programming also incorporates the notion of functions, which are chucks of code that can be called repeatedly, usually to accomplish one specific task. Functions take in data to be processed as arguments and output the result of the computation. However, the output of a function can vary greatly, depending on the state of the program at any given moment.[2]
Functional Programming
Functional Programming has strong roots in mathematics and focuses on calculations. Functions are called only to compute data and do not change the state of the program. The output of functions in functional programming depend only on the arguments to the function, with no dependency on the state of the system. Also, all variables are final - that is, once assigned to, they cannot be changed. All these factors make functional programs very reliable and repeatable.[3]
Hybrid Object Oriented Programming Languages
The following Languages use Hybrid Object Oriented Programming Paradigms:
OCaml
OCaml was an addition to the Caml programming language, which was itself derived from ML. ML (Meta-Language) was originally developed as a highly functional programming language. It was used to assist with mathematical proofs. Caml was derived from ML to create a flexible programming language and it began to incorporate more procedural programming aspects. Finally, OCaml was implemented, which added object oriented features such as multiple inheritance and module hierarchy management.[4]
Design Considerations
- By default, data in OCaml (variables, arrays, ect) are not modifiable, because of its roots in functional programming. However, to allow for more expressive procedural programming, variables are allowed to be declared as modifiable.
- To ensure safety, OCaml is statically typed and type matching is enforced at compile time. This prevents many common run time errors, but does require attention to detail by the programmer. This strong-typing is also true of objects in OCaml. At compile time, OCaml makes sure that no object will receive a message it is not able to understand.
- OCaml allows for the definition of new data types using the concept of a data constructor.[5]