CSC/ECE 517 Fall 2011/ch1 1g vn: Difference between revisions
No edit summary |
No edit summary |
||
Line 31: | Line 31: | ||
==Object Oriented Languages and Features== | ==Object Oriented Languages and Features== | ||
===Dynamic dispatch== | ===Dynamic dispatch=== | ||
===Encapsulation=== | ===Encapsulation=== | ||
===Object inheritance=== | ===Object inheritance=== |
Revision as of 23:30, 3 September 2011
Overview
Object Oriented Programming is a programming paradigm that uses abstraction to create models based on the real world. It uses several techniques from previously established paradigms, including modularity, polymorphism, and encapsulation. Today, many popular programming languages (such as Java, JavaScript, C#, C++, Python, PHP, Ruby and Objective-C) support object-oriented programming (OOP).
Object-oriented programming may be seen as the design of software using a collection of cooperating objects, as opposed to a traditional view in which a program may be seen as a collection of functions, or simply as a list of instructions to the computer. In OOP, each object is capable of receiving messages, processing data, and sending messages to other objects. Each object can be viewed as an independent little machine with a distinct role or responsibility.
Object-oriented programming is intended to promote greater flexibility and maintainability in programming, and is widely popular in large-scale software engineering. By virtue of its strong emphasis on modularity, object oriented code is intended to be simpler to develop and easier to understand later on, lending itself to more direct analysis, coding, and understanding of complex situations and procedures than less modular programming methods.[1]
A scripting language, script language or extension language is a programming language that allows control of one or more applications. "Scripts" are distinct from the core code of the application, as they are usually written in a different language and are often created or at least modified by the end-user. Scripts are often interpreted from source code or bytecode, whereas the application is typically first compiled to native machine code.Scripting languages uses a lot of the features of object oriented languages.[2]
Scripting languages have their roots in the "Job Control" languages (e.g., IBM's OS JCL) that are used on "batch processing" computer systems. JCL commands tell the system to run specified programs, using particular I/O resources (e.g., files and tape drives). The "command languages" found on "time-sharing" systems (e.g., Unix and VMS) add interactive window-dressing, but perform precisely the same functions.
In recent years, object-oriented programming has become especially popular in dynamic programming languages. Python, Ruby and Groovy are dynamic languages built on OOP principles, while Perl and PHP have been adding object oriented features since Perl 5 and PHP 4, and ColdFusion since version 6.
The Document Object Model of HTML, XHTML, and XML documents on the Internet have bindings to the popular JavaScript/ECMAScript language. JavaScript is perhaps the best known prototype-based programming language, which employs cloning from prototypes rather than inheriting from a class. Another scripting language that takes this approach is Lua. Earlier versions of ActionScript (a partial superset of the ECMA-262 R3, otherwise known as ECMAScript) also used a prototype-based object model. Later versions of ActionScript incorporate a combination of classification and prototype-based object models based largely on the currently incomplete ECMA-262 R4 specification, which has its roots in an early JavaScript 2 Proposal. Microsoft's JScript.NET also includes a mash-up of object models based on the same proposal, and is also a superset of the ECMA-262 R3 specification.
History
Early mainframe computers (in the 1950s) were non-interactive, instead using batch processing. IBM's Job Control Language (JCL) is the archetype of language used to control batch processing.
The first interactive shells were developed in the 1960s to enable remote operation of the first time-sharing systems, and these used shell scripts, which controlled running computer programs within a computer program, the shell.
Languages such as Tcl and Lua were specifically designed as general purpose scripting languages that could be embedded in any application. Other languages such as Visual Basic for Applications (VBA) provided strong integration with the automation facilities of an underlying system. Embedding of such general purpose scripting languages instead of developing a new language for each application also had obvious benefits, relieving the application developer of the need to code a language translator from scratch and allowing the user to apply skills learned elsewhere.
Some software incorporates several different scripting languages. Modern web browsers typically provide a language for writing extensions to the browser itself, and several standard embedded languages for controlling the browser, including JavaScript (a dialect of ECMAScript) or XUL.[3]
Object Oriented features were embedded into scripting language starting with Perl 5.000 released on October 17, 1994. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular amongst programmers. Larry Wall continues to oversee development of the core language, and its upcoming version, Perl 6. Perl borrows features from other programming languages including C, shell scripting (sh), AWK, and sed. The language provides powerful text processing facilities without the arbitrary data length limits of many contemporary Unix tools, facilitating easy manipulation of text files. Perl gained widespread popularity in the late 1990s as a CGI scripting language, in part due to its parsing abilities.[4]
Another Scripting Language Ruby was conceived on February 24, 1993 by Yukihiro Matsumoto who wished to create a new language that balanced functional programming with imperative programming.[8] Matsumoto has stated, "I wanted a scripting language that was more powerful than Perl, and more object-oriented than Python. That's why I decided to design my own language".
At a Google Tech Talk in 2008 Matsumoto further stated, "I hope to see Ruby help every programmer in the world to be productive, and to enjoy programming, and to be happy. That is the primary purpose of Ruby language."[5]
Object Oriented Languages and Features
Dynamic dispatch
Encapsulation
Object inheritance
Open recursion
Classes of objects
Instances of classes
Methods
Message passing
Abstraction
Benjamin C. Pierce and some other researchers view as futile any attempt to distill OOP to a minimal set of features. He nonetheless identifies fundamental features that support the OOP programming style in most object-oriented languages:
1.Dynamic dispatch – when a method is invoked on an object, the object itself determines what code gets executed by looking up the method at run time in a table associated with the object. This feature distinguishes an object from an abstract data type (or module), which has a fixed (static) implementation of the operations for all instances. It is a programming methodology that gives modular component development while at the same time being very efficient. 2.Encapsulation (or multi-methods, in which case the state is kept separate) 3.Subtype polymorphism 4.Object inheritance (or delegation) 5.Open recursion – a special variable (syntactically it may be a keyword), usually called this or self, that allows a method body to invoke another method body of the same object. This variable is late-bound; it allows a method defined in one class to invoke another method that is defined later, in some subclass thereof.
Similarly, in his 2003 book, Concepts in programming languages, John C. Mitchell identifies four main features: dynamic dispatch, abstraction, subtype polymorphism, and inheritance.[15] Michael Lee Scott in Programming Language Pragmatics considers only encapsulation, inheritance and dynamic dispatch.[16]
Additional concepts used in object-oriented programming include:
6.Classes of objects 7.Instances of classes 3. Methods which act on the attached objects. 4.Message passing 5.Abstraction
Scripting Languages
Few of the Object Oriented Scripting languages:
- AppleScript [6]
- Curl [7]
- Groovy [8]
- ICI
- Io
- JavaScript
- Lua
- Moto
- Object Rexx
- Perl
- PHP
- Pike
- Pliant
- Python
- REBOL
- Ruby
- Simkin
- Tcl-Tk
- Transcript
- VBScript
- Water
- XPTcl
Conclusion
References
[1]https://developer.mozilla.org/En/Introduction_to_Object-Oriented_JavaScript