CSC/ECE 517 Fall 2011/ch1 1g rn

From Expertiza_Wiki
Jump to navigation Jump to search

Object-Oriented Languages and Scripting

Scripting

Scripting languages are usually used for gluing together pre-existing component and automation of manual work. They provide features like dynamic typing and extensibility that make them easy to learn. Scripting languages grew out of the need to shorten the traditional edit-compile-link-run process. As such, most of the scripting languages today are interpreted. However, this is not a defining feature; there are scripting languages that are compiled.

Advantages that object orientation bring to a scripting language

Provides encapsulation paradigm in gluing components

An object-oriented approach allows multiple levels of encapsulation. The foremost use of scripts is to act as glue for pre-existing components. Since in scripting languages, code reuse is already provided by pre-existing components, encapsulation is the biggest advantage object-orientation brings to the table. Encapsulation lets us think about an object in isolation; encapsulation fits the human reasoning. Encapsulating data and functionality of various modules, possibly in different languages into a neatly packaged brand new object is perhaps the single most important objective of glue!

  • Separate code into abstract pieces

Procedural programming is the natural choice when writing scripts. Functionality in such scripts is broken down as procedures and variables. One of the major disadvantages of this approach is that it can get out of control when the complexity reaches a certain level. Using an object-oriented approach to scripting allows the programmer to separate code into classes that can be related to real-world entities. Providing classes with attributes and methods makes the code more readable, easier to extend and convenient to maintain. An abstract model makes implementation of complex system allows the program to follow a more natural flow.  

  • Reuse and customize things without changing the original script (example: define a new customized child class)

Most of the popular object-oriented scripting languages like Perl, Python provide the programmer with vast libraries. Scripts typically use one or more library modules and build upon that. Object-orientation makes it easy to reuse and customize existing functionality without changes to the source code.

  • Complex interactions within the system can be streamlined by the use of design patterns

Advantages that scripting capability bring to an object-oriented language

Are there any advantages to a scripting language that is not object oriented?

Is scripting essentially synonymous with dynamic typing?

References