Vivekanand Madesi
10/26/2013
Programming Languages Research Paper
PERL, SIMULA and SMALLTALK
Perl Introduction
Perl is a high level, general purpose, interpreted, dynamic language. It was developed in 1987 by Larry Wall, while working in Unisys. The latest stable version of Perl is ver. 5.18. There is also Perl ver. 6 which is a different programming language altogether and is being developed separately from Perl ver. 5. The Perl language broadly derives its features from C, sh (Shell Scripting), AWK and sed.
Perl – Hello World Program
In Perl, one would write the “Hello World” program as
print “Hello World!\n”;
However as the language evolved so did the Perl practices which now require more complex programs to add the “use strict” and “use warnings” pragmas, changing the “Hello World” program now to:
use strict;
use warnings;
print “Hello World!\n”;
Pragma is a directive /language construct that specifies how a compiler processes its input.
Perl Design and Features
In Perl all the names have letters, numbers and underscore characters. Variables are prefixes with a special sign – All scalar variables start with $, arrays with @ and hashes with %. Also the language is case sensitive.
The bindings in Perl are dynamically typed, however one can simulate a static typing by using the “strict” pragma.
The “my” function provides static scoping; else by default Perl language is dynamic in its scoping.
The objects in Perl are references to data types, which knows its class. They are stored as reference in a scalar variable. A class in Perl is a package that contains the methods required to create and manipulate objects. Similarly, methods are sub routines defined within a package.
Perl Supports three built in data types – scalars which is a single string, number or reference, arrays of scalars which are ordered list of scalars indexed from 0 and hashes which are unordered collection of scalar values indexed by their associated string key.
Expressions in their simplest form are “matching expressions” in Perl. They use a special operator “=~”.
Operator overloading is permitted in Perl through using module “overload.pm”.
“while”, “for”, “foreach” and “if” statements are most commonly used control structures. “until” and “control” are variations of while useful to test conditions.
In Perl, Subprograms are global in scope, and can be invoked anywhere by name or by reference. They cannot be private; however the subroutine variables can be private.
Perl has built in exception handling mechanism through the “eval{}” block .”$@” variable is used to check for exceptions. The “Error.pm” module handles Object Oriented exception handling with returns in Perl. Special Event handling procedures are also offered in Perl through a subclass
Perl is a hybrid implementation where the program is compiled for errors and then interpreted using the Perl interpreter.
Perl employs reference garbage collector. However it cannot handle circular references leading to memory leaks.
Perl Object Oriented Features
Inheritance is easily defined using special variable “@ISA”, which governs the inheritance.
In Perl, encapsulation constructs are known as packages. It uses the constructors and destructors subroutines to handle incorporation in packages.
Abstractions are achieved through pseudo-hashes, which are like hashes, but scoped in its nature.
Objects have automatically called methods.
Polymorphism (Method Override in Perl) is implicitly present in Perl; because of weak typing one can override and redefine methods in subclasses.
Perl Language Evaluation
Readability -Perl has a reputation of being ugly and hard to maintain. However variables because of special symbols are easy to read. In Perl there is more than one way to code as such syntax is not trivial.
Orthogonality - Not orthogonal but has many shortcut features defined to achieve various constructs.
Writability - Good writability because of many new features/functionalities which are continuously being added. It has simple data types and data type abstraction, also the special symbols increases writability.
Reliability - Increased stability with continuous evolution since 1987. However one can face security problems due to improperly validated user input. Continuous evolution has increased complexity in turn decreasing reliability.
Cost – Perl is open source software, thus no cost of ownership. Similarly compilation costs, execution costs are free. While cost of maintenance is a question of time vs. money as the more complex the code the more the time which may be needed.
Perl – Application in Real World
Perl has widespread popularity as a CGI scripting language and has powerful text processing facilities without the data length limitations. As such it is often used in graphics programming, system administration, network programming and biometrics. It’s called the “glue language” or the “duct tape that holds internet together”. Because of its text processing capabilities it is also favored for database applications.
Simula Introduction
Initially designed for doing Simulations it was later recognized as a general purpose programming language. It was developed in 1960s by Ole-Johan Dahl and Kristen Nygard. It is considered the first object oriented programming language. Its two known stable versions are – Simula 1 and Simula 67. It influenced later generations of programming languages greatly notably C++, Smalltalk. Simula introduced objects, classes, subclasses, virtual methods, coroutines and discrete event simulation. It was developed as an Extension of Algol 60, when the developers could not solve their problem using ALGOL 60.
Simula – Hello World Program
An example of a Hello world program in Simula:
Begin
OutText ("Hello World!");
Outimage;
End;
Simula Design and Features
In Simula a class is a procedure which returns a pointer to its activation record. It uses “Begin ….. End” like braces in Java. Comments begin with “!” and end with “;”.
Simula has special type of class called prefix class (superclass), which defines a superclass and provides inheritance.
Objects in Simula are activation records produced by call to a class.
A special keyword “Ref” like Ref(Class) is a form of the type of an object variable (Simula term for pointers).
In Simula the following are the built in data types - Integer, Short Integer, Real, Long Real, Character, Boolean. And uses “:=“ for standard value assignments and “:-” for reference assignments.
Here the parameters are transmitted by value by default and only for the Ref type, parameters are transmitted by reference.
In Simula methods/functions are implemented using keyword procedure in all cases. Procedures can be declared anywhere in a program and do not allow return statements. Simula allows procedures to have procedure parameters (“Formal procedures”).
Virtual mechanism is achieved by declaring procedures virtual or not. These can also be termed abstract as no implementation is given in class.
It is a multi stack language. Each object executes in quasi parallel, gets its own call stack by calling procedures. “Detach” statement transfers the execution control back to main program. “Resume” continues the execution from the point of detachment.
Subclasses can only be declared at the same block level as the superclass.
Only in later versions, type check during compilation was added where initially it used to be performed at runtime.
List processing capabilities are provided through a class “Simset”. Similarly, class “Simulation” allows for discrete event simulation.
The language has strong modularization as it allows separate compilation of classes and procedures. Also the strong typing extends to separately compiled modules.
Objects are garbage collected automatically, as such user destructors are considered undesirable.
Simula has a highly standard definition; as such the programs are highly portable.
This language is a compiler implementation, uses the Simula compiler.
Simula Object Oriented Features
Unique object oriented features of Simula are as follows:
Inner - Indicates that the method of a subclass be called in combination with execution of superclass code.
Inspect/Qua - Provide ability to test the type of an object at run time and to execute appropriate code accordingly.
Initially no distinction for encapsulation, however later versions incorporated “protected” and “hidden” packages.
Simula Language Evaluation
Readability – As size increases, it becomes too complicated. Missing data types (records, sets) as such orthogonality is very poor.
Writability – It has very limited file access facilities (typed files).
Reliability – It does not support multiple inheritances and has no interfaces. Often results in long executable files for short programs. It also has no advanced parallelism and real time support. A security mechanism is also missing as well as poor GUI support.
Cost – It is an expensive language. It never became a widespread language as such very few developers available and a small applications base. It also does not have a modern IDE which adds to its cost. However it is very portable because of its standardized definition.
Simula – Application in Real World
It was designed for doing Simulation during the 1960s. Also used in wide range of applications such as simulating VLSI designs, process modeling, protocols, typesetting, computer graphics and education.
Smalltalk Introduction
Smalltalk is an object-oriented, dynamically typed, reflective programming language. It was developed at Xerox PARC by Alan Kay, Dan Ingalls, Adele Goldberg, Ted Kaehler, and Scott Wallace in the 1970s. Smalltalk-76 and Smalltalk-80 are the major stable versions. It is a pure object oriented language where everything is an object. It is considered one of the major language that popularized objects. The motivating application or the inspiration for this language was to act as an operating system and language of choice for the Dynabook – a concept similar to that of laptop by Alan Kay. It was intended for non programmers.
Smalltalk – Hello World Program
In Smalltalk, the Hello World program is written as follows:
Transcript show: “Hello, World!”
Message “show:” is sent to the object “Transcript”. Invocation of the “show:” method displays the string. To see results, need transcript window.
Smalltalk – Design & Features
In Smalltalk, an object is a combination of private data and functions. Each object is an instance of some class having local memory and inherent processing capability and also having the ability to communicate with other objects. The objects can be passed as parameters and returned as objects.
A message is a request to object to perform operation (function call). In Smalltalk methods (function) are an implementation of an operation
Classes in Smalltalk are in defined as a template defining the implementation of a set of objects. This is performed using a special editor. A class variable is shared by all objects in that class. A Subclass is defined by inheriting from its superclass.
Selector in Smalltalk is the name of a message (function name). As such a message is a selector together with actual parameter values which contains the names and parameters of methods
In Smalltalk, method is the code in a class for responding to a message and are functions to manipulate objects. An instance variable is data stored in an individual object (instance of a class) and is repeated for each object
The expression types in Smalltalk are as follows –Literals, Variable names, Message Expressions, Blocks of Code.
All variables are pointers to objects and inherently type less. The variables are also case sensitive (public –start with upper class, private lower class)
A typical Message Expression in Smalltalk involves receiver, arguments, message selector and message answer.
The following are its message syntax types
Unary (no parameters)
Binary Ex: 2+3
Keyword Ex: myArray at: 42 put: 5
Self referencing is allowed by using “self”, this would reference the object itself.
The language uses “:=“ for assignment. And in here control structures are formed by passing block objects as parameters. Expressions evaluated when block receives the message value.
Ex: [Index:=index+1.
Sum:=sum+index.] value
Blocks can be assigned to variables.
Smalltalk is a “Just in Time” compilation. Smalltalk programs are usually compiled to byte code, which is then interpreted by a virtual machine into machine-native code.
All Smalltalk systems follow the same virtual machine specification making it very portable.
As this compilation done at method level, compilation is faster and instantaneous in Smalltalk resulting in it being a good language to perform prototypes.
Smalltalk has automatic garbage collection. Objects are allocated in a heap and the heap is collected for garbage automatically. “Nil” is an object used to check the “NULL” condition.
Error Handling is implicitly handled in this language. On error in objects type, a message “doesnotunderstand” pops up, and a debugger can be invoked to deal with it.
Reflection is supported in Smalltalk. Each object can be examined and if required modified at run time
Since the language was originally developed as a complete operating system, it includes code for activities typically performed at OS level.
Smalltalk - Object Oriented Features
Abstraction - Provided through protected instance variables. All methods are public, instance variables accessed only by methods of the class and subclasses
Sub typing - Does not have compile time type system. Arises implicitly, based on set of messages understood by an object
Inheritance - Subclasses inherit all instance variables and methods of superclasses. Methods of a superclass may be redefined in a subclass or deleted. It is a strict tree structure wherein a subclass can have only one and only one parent class. Subclasses can add new variables or methods, also can hide inherited functionality.
Polymorphism - Supports by allowing methods defined in class to be over ridden with methods of the same name.
Encapsulation - Encapsulates all objects, which interact with other objects through messages to the objects interface.
Smalltalk Language Evaluation
Readability – It was developed for non programming users, simple and constructible. It has very few special words
Orthogonality - As all constructs are object specific, every possible combination is possible between the constructs leading to high orthogonality.
Writability - Readable and Orthogonal and as such has good support for abstraction.
Reliability – There is no inherent type checking but type checking carried out implicitly at run time for object types. Exception handling is performed at run time along with debugging capabilities. In Smalltalk aliasing is possible which decreases its reliability.
Cost - When released it was relatively expensive and uncommon and thus was not widely adopted resulting in shortage of trained people and matured models.
Smalltalk – Application in Real World
Smalltalk is used in prototyping –a program can be prototyped quickly in Smalltalk and later deployed in other languages. This is possible due to incremental compilation. It was originally designed to work as an operating system; however there was never widespread adoption for this purpose because of heavy competition from competing Unix and Windows operating systems.
Directory: publicpublic -> Acm word Template for sig sitepublic -> The german unification, 1815-1870public -> Preparation of Papers for ieee transactions on medical imagingpublic -> Harmonised compatibility and sharing conditions for video pmse in the 7 9 ghz frequency band, taking into account radar usepublic -> Adjih, C., Georgiadis, L., Jacquet, P., & Szpankowski, W. (2006). Multicast tree structure and the power lawpublic -> Duarte, G. Pujolle: fits: a flexible Virtual Network Testbed Architecturepublic -> Swiss Federal Institute of Technology (eth) Zurich Computer Engineering and Networks Laboratorypublic -> Tr-41. 4-03-05-024 Telecommunicationspublic -> Chris Young sets 2016 “I’m Comin’ Over” Tour headlining dates
Share with your friends: |