Programming Languages Supported by Selenium 2

Selenium

Selenium is a portable software testing framework for web applications. Selenium provides a record/playback tool for authoring tests without learning a test scripting language (Selenium IDE).

Supporting languages

  • Java

  • C#

  • PHP

  • Python

  • Perl

  • Ruby

Java (software platform)

History

The Java platform and language began as an internal project at Sun Microsystems in December 1990, providing an alternative to the C++/C programming languages. Engineer Patrick Naughtonhad become increasingly frustrated with the state of Sun’s C++ and C application programming interfaces (APIs) and tools. While considering moving to Next, Naughton was offered a chance to work on new technology and thus the StealthProject was started.

The Stealth Project was soon renamed to the Green Project with James Gosling and Mike Sheridan joining Naughton. Together with other engineers, they began work in a small office on Sand Hill Road in Menlo Park, California. They were attempting to develop a new technology for programming next generation smart appliances, which Sun expected to be a major new opportunity.

The team originally considered using C++, but it was rejected for several reasons. Because they were developing an embedded system with limited resources, they decided that C++ needed too much memory and that its complexity led to developer errors. The language’s lack of garbage collection meant that programmers had to manually manage system memory, a challenging and error-prone task. The team was also troubled by the language’s lack of portable facilities for security, distributed programming, and threading. Finally, they wanted a platform that could be easily ported to all types of devices.

Bill Joy had envisioned a new language combining Mesa and C. In a paper called Further, he proposed to Sun that its engineers should produce an object-oriented environment based on C++. Initially, Gosling attempted to modify and extend C++ (that he referred to as “C++ ++ –“) but soon abandoned that in favor of creating a new language, which he called Oak, after the tree that stood just outside his office.

In 1994, the language was renamed Java after a trademark search revealed that Oak was used by Oak Technology. Although Java 1.0a was available for download in 1994, the first public release of Java was 1.0a2 with the Hot Java browser on May 23, 1995, announced by Gage at the Sun World conference. 

On January 9, 1996, the Java Soft group was formed by Sun Microsystems to develop the technology.

There were five primary goals in the creation of the Java language:

  1. It should be “simple, object-oriented and familiar”

  2. It should be “robust and secure”

  3. It should be “architecture-neutral and portable”

  4. It should execute with “high performance”

  5. It should be “interpreted, threaded, and dynamic”

Versions

Major release versions of Java, along with their release dates:

  • JDK 1.0 (January 21, 1996)

  • JDK 1.1 (February 19, 1997)

  • J2SE 1.2 (December 8, 1998)

  • J2SE 1.3 (May 8, 2000)

  • J2SE 1.4 (February 6, 2002)

  • J2SE 5.0 (September 30, 2004)

  • Java SE 6 (December 11, 2006)

  • Java SE 7 (July 28, 2011)

  • Java EE 7 (October 27, 2013)

Java platform

One characteristic of Java is portability, which means that computer programs written in the Java language must run similarly on any hardware/operating-system platform. This is achieved by compiling the Java language code to an intermediate representation called Java byte code, instead of directly to platform-specific machine code. Standardized libraries provide a generic way to access host-specific features such as graphics, threading, and networking.

A major benefit of using byte code is porting. However, the overhead of interpretation means that interpreted programs almost always run more slowly than programs compiled to native executables would. Just-in-Time (JIT) compilers were introduced from an early stage that compiles byte codes to machine code during runtime.

Performance

Programs written in Java have a reputation for being slower and requiring more memory than those written in C++. However, Java programs’ execution speed improved significantly with the introduction of Just-in-time compilation in 1997/1998 for Java 1.1, the addition of language features supporting better code analysis (such as inner classes, the String Builder class, optional assertions, etc.), and optimizations in the Java virtual machine itself, such as Hotspot becoming the default for Sun’s JVM in 2000.

Java uses an automatic garbage collector to manage memory in the object lifecycle. The programmer determines when objects are created, and the Java runtime is responsible for recovering the memory once objects are no longer in use. Once no references to an object remain, the unreachable memory becomes eligible to be freed automatically by the garbage collector. Something similar to a memory leak may still occur if a programmer’s code holds a reference to an object that is no longer needed, typically when objects that are no longer needed are stored in containers that are still in use. If methods for a nonexistent object are called, a “null pointer exception” is thrown.

One of the ideas behind Java’s automatic memory management model is that programmers can be spared the burden of having to perform manual memory management. In some languages, memory for the creation of objects is implicitly allocated on the stack, or explicitly allocated and deallocated from the heap. In the latter case the responsibility of managing memory resides with the programmer. If the program does not deallocate an object, a memory leak occurs. If the program attempts to access or deallocate memory that has already been deallocated, the result is undefined and difficult to predict, and the program is likely to become unstable and/or crash. This can be partially remedied by the use of smart pointers, but these add overhead and complexity. Note that garbage collection does not prevent “logical” memory leaks, i.e. those where the memory is still referenced but never used.

Garbage collection may happen at any time. Ideally, it will occur when a program is idle. It is guaranteed to be triggered if there is insufficient free memory on the heap to allocate a new object; this can cause a program to stall momentarily. Explicit memory management is not possible in Java.

Java does not support C/C++ style pointer arithmetic, where object addresses and unsigned integers (usually long integers) can be used interchangeably. This allows the garbage collector to relocate referenced objects and ensures type safety and security.

As in C++ and some other object-oriented languages, variables of Java’s primitive data types are not objects. Values of primitive types are either stored directly in fields (for objects) or on the stack (for methods) rather than on the heap, as is commonly true for objects. This was a conscious decision by Java’s designers for performance reasons. Because of this, Java was not considered to be a pure object-oriented programming language. However, as of Java 5.0, auto boxing enables programmers to proceed as if primitive types were instances of their wrapper class.

Syntax

The syntax of Java is largely derived from C++. Unlike C++, which combines the syntax for structured, generic, and object-oriented programming, Java was built almost exclusively as an object-oriented language. All code is written inside a class, and everything is an object, with the exception of the primitive data types (i.e. integers, floating-point numbers, boolean values, and characters), which are not classes for performance reasons.Unlike C++, Java does not support operator overloading or multiple inheritance for classes.

Special classes

Applet

Java applets are programs that are embedded in other applications, typically in a Web page displayed in a Web browser.

Servlet

Java Servlet technology provides Web developers with a simple, consistent mechanism for extending the functionality of a Web server and for accessing existing business systems. Servlets are server-side Java EE components that generate responses (typically HTML pages) to requests (typically HTTP requests) from clients. A servlet can almost be thought of as an applet that runs on the server side—without a face.

JavaServer Pages

JavaServer Pages (JSP) are server-side Java EE components that generate responses, typically HTML pages, to HTTP requests from clients. JSPs embed Java code in an HTML page by using the special delimiters <% and %>. A JSP is compiled to a Java servlet, a Java application in its own right, the first time it is accessed. After that, the generated servlet creates the response.

Swing application

Swing is a graphical user interface library for the Java SE platform. It is possible to specify a different look and feel through the pluggable look and feel system of Swing. Swing in Java SE 6 addresses this problem by using more native GUI widget drawing routines of the underlying platforms.

Example

class HelloWorldApp {

public static void main(String[] args)

{

System.out.println(“Hello World!”);

}

}

Output: Hello World!

JavaScript

JavaScript (JS) is an interpreted computer programming language.[5] As part of web browsers, implementations allow client-side scripts to interact with the user, control the browser, communicate asynchronously, and alter the document content that is displayed.[5] It has also become common in server-side programming, game development and the creation of desktop applications.

JavaScript is a prototype-based scripting language with dynamic typing and has first-class functions. Its syntax was influenced by C. JavaScript copies many names and naming conventions from Java, but the two languages are otherwise unrelated and have very different semantics.

History

Birth at Netscape

JavaScript was originally developed by Brendan Eich. While battling with Microsoft over the Web, Netscape considered their client-server offering a distributed OS, running a portable version of Sun Microsystems’ Java. Because Java was a competitor of C++ and aimed at professional programmers, Netscape also wanted a lightweight interpreted language that would complement Java by appealing to nonprofessional programmers, like Microsoft’s Visual Basic (see JavaScript and Java).

Server-side JavaScript

Netscape introduced an implementation of the language for server-side scripting (SSJS) with Netscape Enterprise Server, first released in December, 1994 (soon after releasing JavaScript for browsers). Since the mid-2000s, there has been a proliferation of server-side JavaScript implementations. Node.js is one recent notable example of server-side JavaScript being used in real-world applications.

Adoption by Microsoft

JavaScript very quickly gained widespread success as a client-side scripting language for web pages. Microsoft introduced JavaScript support in its own web browser, Internet Explorer, in version 3.0, released in August 1996. Microsoft’s webserver, Internet Information Server, introduced support for server-side scripting in JavaScript with release 3.0 (1996). Microsoft started to promote webpage scripting using the umbrella term Dynamic HTML.

Standardization

In November 1996, Netscape announced that it had submitted JavaScript to Ecma International for consideration as an industry standard, and subsequent work resulted in the standardized version named ECMAScript. In June 1997, Ecma International published the first edition of the ECMA-262 specification. A year later, in June 1998, some modifications were made to adapt it to the ISO/IEC-16262 standard, and the second edition was released. The third edition of ECMA-262 (published on December 1999) is the version most browsers currently use.

Development of what would have been a fourth edition of the ECMAScript standard was ultimately never completed and no fourth edition was released. The fifth edition was released in December 2009. The current edition of the ECMAScript standard is 5.1, released in June 2011.

Later developments

JavaScript has become one of the most popular programming languages on the web. Initially, however, many professional programmers denigrated the language because its target audience consisted of web authors and other such “amateurs”, among other reasons. The advent of Ajax returned JavaScript to the spotlight and brought more professional programming attention. The result was a proliferation of comprehensive frameworks and libraries, improved JavaScript programming practices, and increased usage of JavaScript outside of web browsers, as seen by the proliferation of server-side JavaScript platforms.

Features

Imperative and structured

JavaScript supports much of the structured programming syntax from C. Dynamic[edit]

Dynamic typing

As in most scripting languages, types are associated with values, not with variables. For example, a variable x could be bound to a number, then later rebound to a string.

Object based

JavaScript is almost entirely object-based. JavaScript objects are associative arrays, augmented with prototypes. Object property names are string keys. They support two equivalent syntaxes: dot notation (obj.x = 10) and bracket notation (obj[‘x’] = 10). Properties and their values can be added, changed, or deleted at run-time. JavaScript has a small number of built-in objects such as Function and Date.

Run-time evaluation

JavaScript includes an eval function that can execute statements provided as strings at run-time.

Functional

First-class functions

Functions are first-class; they are objects themselves. As such, they have properties and methods, such as .call() and .bind().

Prototypes

JavaScript uses prototypes where many other object oriented languages use classes for inheritance.

Functions as object constructors

Functions double as object constructors along with their typical role. Prefixing a function call with new will create an instance of a prototype, inheriting properties and methods from the constructor (including properties from the Object prototype).

Functions as methods

Unlike many object-oriented languages, there is no distinction between a function definition and a method definition. Rather, the distinction occurs during function calling; when a function is called as a method of an object, the function’s local this keyword is bound to that object for that invocation.

JavaScript is a Delegation Language.

Type Composition and Inheritance

Whereas explicit function based delegation does cover composition in JavaScript, implicit delegation already happens every time the prototype chain is walked in order to e.g. find a method that might be related to but is not directly owned by an object. Once the method was found it gets called within this objects context. Thus inheritance in JavaScript is covered by a delegation automatism that is bound to the prototype property of constructor functions.

Miscellaneous

Run-time environment

JavaScript typically relies on a run-time environment (e.g. a web browser) to provide objects and methods by which scripts can interact with the environment (e.g. a webpage DOM). It also relies on the run-time environment to provide the ability to include/import scripts (e.g. HTML <script> elements). This is not a language feature per se, but it is common in most JavaScript implementations.

Variadic functions

An indefinite number of parameters can be passed to a function. The function can access them through formal parameters and also through the local arguments object. Variadic functions can also be created by using the apply method.

Array and object literals

Like many scripting languages, arrays and objects (associative arrays in other languages) can each be created with a succinct shortcut syntax. In fact, these literals form the basis of the JSON data format.

Regular expressions

JavaScript also supports regular expressions in a manner similar to Perl, which provide a concise and powerful syntax for text manipulation that is more sophisticated than the built-in string functions.

Example Script:

<meta charset=”utf-8″>

<title>Minimal Example</title>

<h1 id=”header”>This is JavaScript</h1>

<script>

document.body.appendChild(document.createTextNode(‘Hello World!’));

var h1 = document.getElementById(‘header’); // holds a reference to the <h1> tag

h1 = document.getElementsByTagName(‘h1’)[0]; // accessing the same <h1> element

</script>

C Sharp

C♯(pronounced see sharp) is a multi-paradigm programming language encompassing strong typing, imperative, declarative, functional,procedural, generic, object-oriented (class-based), and component-oriented programming disciplines. It was developed by Microsoft within its .NET initiative and later approved as a standard by Ecma (ECMA-334) and ISO (ISO/IEC 23270:2006). C# is one of the programming languages designed for the Common Language Infrastructure.C♯ is intended to be a simple, modern, general-purpose, object-oriented programming language.

History

During the development of the .NET Framework, the class libraries were originally written using a managed code compiler system called Simple Managed C (SMC).In January 1999,Anders Hejlsberg formed a team to build a new language at the time called Cool, which stood for “C-like Object Oriented Language”. Microsoft had considered keeping the name “Cool” as the final name of the language, but chose not to do so for trademark reasons. By the time the .NET project was publicly announced at the July 2000 Professional Developers Conference, the language had been renamed C#, and the class libraries and ASP.NET runtime had been ported to C#.

C#’s principal designer and lead architect at Microsoft is Anders Hejlsberg, who was previously involved with the design of Turbo Pascal, Embarcadero Delphi (formerly CodeGear Delphi, Inprise Delphi and Borland Delphi), and Visual J++. In interviews and technical papers he has stated that flawsin most major programming languages (e.g. C++, Java, Delphi, and Smalltalk) drove the fundamentals of the Common Language Runtime (CLR), which, in turn, drove the design of the C# language itself.

James Gosling, who created the Java programming language in 1994, and Bill Joy, a co-founder of Sun Microsystems, the originator of Java, called C# an “imitation” of Java; Gosling further said that “[C# is] sort of Java with reliability, productivity and security deleted. Klaus Kreft and Angelika Langer (authors of a C++ streams book) stated in a blog post that “Java and C# are almost identical programming languages. Boring repetition that lacks innovation, Hardly anybody will claim that Java or C# are revolutionary programming languages that changed the way we write programs,” and “C# borrowed a lot from Java – and vice versa. Now that C# supports boxing and unboxing, we’ll have a very similar feature in Java. In July 2000, Anders Hejlsberg said that C# is “not a Java clone” and is “much closer to C++” in its design.

Since the release of C# 2.0 in November 2005, the C# and Java languages have evolved on increasingly divergent trajectories, becoming somewhat less similar. One of the first major departures came with the addition of generics to both languages, with vastly different implementations

Version

Version

CLR[28]

Language specification

Date

.NET Framework

Visual Studio

ECMA

ISO/IEC

Microsoft

C# 1.0

1.0

December 2002

April 2003

January 2002

January 2002

.NET Framework 1.0

Visual Studio .NET 2002

C# 1.2

1.1

October 2003

April 2003

.NET Framework 1.1

Visual Studio .NET 2003

C# 2.0

2.0

June 2006

September 2006

September 2005[A]

November 2005

.NET Framework 2.0

Visual Studio 2005

C# 3.0

2.0
2.0 SP1

None[B]

August 2007

November 2007

.NET Framework 2.0 (Except LINQ/Query Extensions)[29]
.NET Framework 3.0 (Except LINQ/Query Extensions)[29]
.NET Framework 3.5

Visual Studio 2008
Visual Studio 2010

C# 4.0

4.0[C]

April 2010

April 2010

.NET Framework 4

Visual Studio 2010

C# 5.0

4.5[D]

June 2013

August 2012

.NET Framework 4.5

Visual Studio 2012

Syntax

Syntax – the form – is contrasted with semantics – the meaning. In processing computer languages, semantic processing generally comes after syntactic processing, but in some cases semantic processing is necessary for complete syntactic analysis, and these are done together or concurrently. In a compiler, the syntactic analysis comprises the frontend, while semantic analysis comprises the backend .There are 3 levels,

  • Words – the lexical level, determining how characters form tokens;

  • Phrases – the grammar level, narrowly speaking, determining how tokens form phrases;

  • Context – determining what objects or variables names refer to, if types are valid, etc.

Characteristics of C#

  • The C# language is intended to be a simple, modern, general-purpose, object-oriented programming language.

  • The language, and implementations thereof, should provide support for software engineering principles such as strong type checking, array bounds checking, detection of attempts to use uninitialized variables, and automatic garbage collection. Software robustness, durability, and programmer productivity are important.

  • The language is intended for use in developing software components suitable for deployment in distributed environments.

  • Source code portability is very important, as is programmer portability, especially for those programmers already familiar with C and C++.

  • Support for internationalization is very important.

  • C# is intended to be suitable for writing applications for both hosted and embedded systems, ranging from the very large that use sophisticated operating systems, down to the very small having dedicated functions.

  • Although C# applications are intended to be economical with regard to memory and processing power requirements, the language was not intended to compete directly on performance and size with C or assembly language.

Common type system

C# has a unified type system. This unified type system is called Common Type System. A unified type system implies that all types, including primitives such as integers, are subclasses of the System. Object class. For example, every type inherits a To String() method.

CTS separate data types into two categories:

  1. Reference types

  2. Value types

Boxing and unboxing

Boxing is the operation of converting a value-type object into a value of a corresponding reference type. Boxing in C# is implicit. Unboxing is the operation of converting a value of a reference type (previously boxed) into a value of a value type.

Generics

Generics were added to version 2.0 of the C# language. Generics use type parameters, which make it possible to design classes and methods that do not specify the type used until the class or method is instantiated. The main advantage is that one can use generic type parameters to create classes and methods that can be used without incurring the cost of runtime casts or boxing operations.

Code:

using System;

class Program

{

static void Main()

{

Console.WriteLine(“Hello world!”);

}

}Output: Hello World!

Python (programming language)

Python is a widely used general-purpose, high-level programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in languages such as C. The language provides constructs intended to enable clear programs on both a small and large scale.

Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles. It features a dynamic system and automatic memory management and has a large and comprehensive standard library.

History and Versions

Python was conceived in the late 1980sand its implementation was started in December 1989 by Guido van Rossum at CWI in the Netherlands as a successor to the ABC language (itself inspired by SETL capable of exception handling and interfacing with the Amoeba operating system. Van Rossum is Python’s principal author, and his continuing central role in deciding the direction of Python is reflected in the title given to him by the Python community,Benevolent (BDFL).

Python 2.0 was released on 16 October 2000, with many major new features including a full garbage collector and support for Unicode. With this release the development process was changed and became more transparent and community-backed.

Python 3.0 (also called Python 3000 or py3k), a major, backwards-incompatible release, was released on 3 December 2008 after a long period of testing. Many of its major features have been back ported to the backwards-compatible Python 2.6 and 2.7.

Features

Python is a multi-paradigm programming language: object-oriented programming and structured programming are fully supported, and there are a number of language features which support functional programming and aspect-oriented programming (including by metaprogramming and by magic methods). Many other paradigms are supported using extensions, including design by contract and logic programming.

Python uses dynamic typing and a combination of reference counting and a cycle-detecting garbage collector for memory management. An important feature of Python is dynamic name resolution (late binding), which binds method and variable names during program execution.

The design of Python offers only limited support for functional programming in the Lisp tradition. The language has map(), reduce() and filter() functions, comprehensions for lists, dictionaries, and sets, as well as generator expressions.

The core philosophy of the language is summarized by the document “PEP 20 (The Zen of Python)”, which includes aphorisms such as:

  • Beautiful is better than ugly.

  • Explicit is better than implicit.

  • Simple is better than complex.

  • Complex is better than complicated.

  • Readability counts.

Syntax and semantics

Python is intended to be a highly readable language. Python has a smaller number of syntactic exceptions and special cases than C or Pascal.

Indentation

Python uses whitespace indentation, rather than curly braces or keywords, to delimit blocks; a feature also termed the off-side rule. An increase in indentation comes after certain statements; a decrease in indentation signifies the end of the current block.

Statements and control flow

Python’s statements include (among others):

The if statement, which conditionally executes a block of code, along with else and else-if (a contraction of else-if).

The for statement, which iterates over an iterable object, capturing each element to a local variable for use by the attached block.

The while statement, which executes a block of code as long as its condition is true.

The try statement, which allows exceptions raised in its attached code block to be caught and handled by except clauses; it also ensures that clean-up code in a finally block will always be run regardless of how the block exits.

The def statement, which defines a function or method.

Expressions

Python expressions are similar to languages such as C and Java

  • In Python, == compares by value, in contrast to Java, where it compares by reference. (Value comparisons in Java use the equals () method.) Python’s is operator may be used to compare object identities (comparison by reference). Comparisons may be chained, for example a <= b <= c.

  • Python uses the words and, or, not for its boolean operators rather than the symbolic &&, ||, ! used in Java and C.

Methods

Methods on objects are functions attached to the object’s class; the syntax instance. Method (argument) is, for normal methods and functions, syntactic sugar for Class. Method (instance, argument) Python methods have an explicit self parameter to access instance data, in contrast to the implicit self in some other object-oriented programming languages for example, Java, C++ or Ruby.

Mathematics

Python has the usual C arithmetic operators (+, -, *, /, %). It also has ** for exponentiation, e.g. 5**3 == 125 and 9**.5 == 3.0.

Python prompt:

>>> print “Hello, Python!”;

Output: Hello, Python!

Perl

Perl is a family of high-level, general-purpose, interpreted, dynamic programming languages. The languages in this family include Perl 5 and Perl 6.

Though Perl is not officially an acronym, there are various backronyms in use, such as: Practical Extraction and Reporting Language. 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. The latest major stable revision of Perl 5 is 5.18, released in May 2013. Perl 6, which began as a redesign of Perl 5 in 2000, eventually evolved into a separate language. Both languages continue to be developed independently by different development teams and liberally borrow ideas from one another.

The Perl languages borrow features from other programming languages including C, shell scripting, AWK, and sed. They provide powerful text processing facilities without the arbitrary data-length limits of many contemporary Unix commandline tools, facilitating easy manipulation of text files. Perl 5 gained widespread popularity in the late 1990s as a CGI scripting language, in part due to its parsing abilities.

History

Early versions

Wall began work on Perl in 1987, while working as a programmer at Unisys, and released version 1.0 to the comp.sources.misc newsgroup on December 18, 1987. The language expanded rapidly over the next few years.

Perl 2, released in 1988, featured a better regular expression engine. Perl 3, released in 1989, added support for binary data streams.

Perl 4 went through a series of maintenance releases, culminating in Perl 4.036 in 1993. At that point, Wall abandoned Perl 4 to begin work on Perl 5. Initial design of Perl 5 continued into 1994. The perl5-porters mailing list was established in May 1994 to coordinate work on porting Perl 5 to different platforms. It remains the primary forum for development, maintenance, and porting of Perl 5.

Perl 5.000 was released on October 17, 1994 and continues with several version.

In late 2012 and 2013 several projects for alternative implementations for Perl 5 started: Perl5 in Perl6 by the Rakudo Perl team.

Name

Perl was originally named “Pearl”.

Camel symbol

Programming Perl, published by O’Reilly Media, features a picture of a dromedary camel on the cover and is commonly called the “Camel Book”.

Onion symbol

The Perl Foundation owns an alternative symbol, an onion, which it licenses to its subsidiaries, Perl Mongers, Perl Monks, Perl.org, and others.

Features

The overall structure of Perl derives broadly from C. Perl is procedural in nature, with variables, expressions, assignment statements, brace-delimited blocks, control structures, and subroutines.

Perl also takes features from shell programming. All variables are marked with leading sigils, which unambiguously identify the data type (for example, scalar, array, hash) of the variable in context. Importantly, sigils allow variables to be interpolated directly into strings. Perl has many built-in functions that provide tools often used in shell programming (although many of these tools are implemented by programs external to the shell) such as sorting, and calling on operating system facilities.

Perl 5 added features that support complex data structures, first-class functions (that is, closures as values), and an object-oriented programming model. These include references, packages, class-based method dispatch, and lexically scoped variables, along with compiler directives (for example, the strict pragma). A major additional feature introduced with Perl 5 was the ability to package code as reusable modules. Wall later stated that “The whole intent of Perl 5’s module system was to encourage the growth of Perl culture rather than the Perl core.”

All versions of Perl do automatic data-typing and automatic memory management. The interpreter knows the type and storage requirements of every data object in the program; it allocates and frees storage for them as necessary using reference counting (so it cannot deallocate circular data structures without manual intervention). Legal type conversions — for example, conversions from number to string — are done automatically at run time; illegal type conversions are fatal errors.

Applications

Perl has many and varied applications, compounded by the availability of many standard and third-party modules.

Perl has chiefly been used to write CGI scripts. Perl is often used as a glue language, tying together systems and interfaces that were not specifically designed to interoperate, and for “data munging”, that is, converting or processing large amounts of data for tasks such as creating reports. In fact, these strengths are intimately linked.

Graphical user interfaces (GUIs) may be developed using Perl. For example, Perl/Tk and WxPerl are commonly used to enable user interaction with Perl scripts.

Implementation

Perl is implemented as a core interpreter, written in C, together with a large collection of modules, written in Perl and C. As of 2010, the stable version (5.18.1) is 16.53 MB when packaged in a tar file and gzip compressed. The interpreter is 150,000 lines of C code and compiles to a 1 MB executable on typical machine architectures. Alternatively, the interpreter can be compiled to a link library and embedded in other programs. There are nearly 500 modules in the distribution, comprising 200,000 lines of Perl and an additional 350,000 lines of C code. (Much of the C code in the modules consists of character encoding tables.)

The interpreter has an object-oriented architecture. All of the elements of the Perl language-scalars, arrays, hashes, coderefs, file handles—are represented in the interpreter by C structs.

Optimizing

Because Perl is an interpreted language, it can give problems when efficiency is critical; in such situations, the most critical routines can be written in other languages such as C, which can be connected to Perl via simple Inline modules or the more complex but flexible XS mechanism.

Perl on IRC

There are a number of IRC channels that offer support for the language and some modules.

IRC Network

Channels

irc.freenode.net

#perl #perl6 #cbstream #perlcafe #poe

irc.perl.org

#moose #poe #catalyst #dbix-class #perl-help #distzilla #epo #corehackers #sdl #win32

irc.slashnet.org

#perlmonks

irc.oftc.net

#perl

irc.efnet.net

#perlhelp

irc.rizon.net

#perl

irc.debian.org

#debian-perl

Example Code

In older versions of Perl, one would write the Hello World program as:

print“Hello World!\n;

In later versions, which support the say statement, one can also write it as:

use5.010;

say “Hello World!”;

Output: Hello World!

PHP

PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language. PHP is now installed on more than 244 million websites and 2.1 million web servers. Originally created by Rasmus Lerdorf in 1995, the reference implementationof PHP is now produced by The PHP Group. While PHP originally stood for Personal Home Page, it now stands for PHP: Hypertext Preprocessor, a recursive backronym.

PHP code is interpreted by a web server with a PHP processor module, which generates the resulting web page: PHP commands can be embedded directly into an HTML source document rather than calling an external file to process data. It has also evolved to include a command-line interfacecapability and can be used in standalone graphical applications.PHP is free software released under the PHP License.

History

PHP development began in 1994 when the developer Rasmus Lerdorf wrote a series of Common Gateway Interface (CGI) Perl scripts, which he used to maintain his personal homepage. The tools performed tasks such as displaying his résumé and recording his web traffic.

Zeev Suraski and Andi Gutmans rewrote the parser in 1997 and formed the base of PHP 3, changing the language’s name to the recursive acronym PHP: Hypertext Preprocessor. Afterwards, public testing of PHP 3 began, and the official launch came in June 1998. Suraski and Gutmans then started a new rewrite of PHP’s core, producing the Zend Engine in 1999. They also founded Zend Technologies in Ramat Gan, Israel.On May 22, 2000, PHP 4, powered by the Zend Engine 1.0, was released.On July 13, 2004, PHP 5 was released, powered by the new Zend Engine II. PHP 5 included new features such as improved support for object-oriented programming.

Version

Version

Release date

Supported until[30]

1.0

1995-06-08

2.0

1997-11-01

3.0

1998-06-06

2000-10-20

4.0

2000-05-22

2001-01-23

4.1

2001-12-10

2002-03-12

4.2

2002-04-22

2002-09-06

4.3

2002-12-27

2005-03-31

4.4

2005-07-11

2008-08-07

5.0

2004-07-13

2005-09-05

5.1

2005-11-24

2006-08-24

5.2

2006-11-02

2011-01-06

5.3

2009-06-30

2014-07

5.4

2012-03-01

3 years after release

5.5

2013-06-20

3 years after release

5.6

No date set

No date set

6

No date set

No date set

Features

PHP is a general-purpose scripting language that is especially suited to server-side web development where PHP generally runs on a web server. Any PHP code in a requested file is executed by the PHP runtime, usually to create dynamic web page content or dynamic images used on websites or elsewhere. It can also be used for command-line scripting and client-side graphical user interface (GUI) applications. PHP can be deployed on most web servers, many operating systems and platforms, and can be used with many relational database management systems (RDBMS). Most web hosting providers support PHP for use by their clients. It is available free of charge, and the PHP Group provides the complete source code for users to build, customize and extend for their own use.

Data types

PHP stores whole numbers in a platform-dependent range, either a 64-bit or 32-bit signed integer equivalent to the C-language long type. Unsigned integers are converted to signed values in certain situations; this behavior is different from other programming languages. Integer variables can be assigned using decimal (positive and negative), octal, hexadecimal, and binary notations.

Floating point numbers are also stored in a platform-specific range. They can be specified using floating point notation, or two forms of scientific notation.Using the Boolean type conversion rules, non-zero values are interpreted as true and zero as false, as in Perl and C++.

Functions

PHP has hundreds of base functions and thousands more via extensions. These functions are well documented on the PHP site; however, the built-in library has a wide variety of naming conventions and inconsistencies. One cause of the inconsistent functions naming is that early versions of PHP internally used string length as a hash function for function names, thus using inconsistent names made it easier to get a more uniform distribution of hash values. PHP currently has no functions for thread programming, although it does support multi process programming

function getAdder($x)

{

return function($y) use ($x)

{

return $x + $y;

};

}

$adder = getAdder(8);

echo $adder(2); // prints “10”

Objects

Basic object-oriented programming functionality was added in PHP 3 and improved in PHP 4. Object handling was completely rewritten for PHP 5, expanding the feature set and enhancing performance. In previous versions of PHP, objects were handled like value types. The drawback of this method was that the whole object was copied when a variable was assigned or passed as a parameter to a method. In the new approach, objects are referenced by handle, and not by value.

PHP 5 introduced private and protected member variables and methods, along with abstract classes, final classes, abstract methods, and final methods. It also introduced a standard way of declaring constructors and destructors, similar to that of other object-oriented languages such as C++, and a standard exception handling model. Furthermore, PHP 5 added interfaces and allowed for multiple interfaces to be implemented. There are special interfaces that allow objects to interact with the runtime system. Objects implementing Array Access can be used with array syntax and objects implementing Iterator or Iterator Aggregate can be used with the for each language construct.

Implementations

The PHP language was originally implemented as an interpreter, and this is still the most popular implementation. Several compilers have been developed which decouple the PHP language from the interpreter. Advantages of compilation include better execution speed, static analysis, and improved interoperability with code written in other languages.

PHP compilers of note include Phalanger, which compiles PHP into Common Intermediate Language (CIL) bytecode, and HipHop, developed at Facebook and now available as open source, which transforms the PHP Script into C++, then compiles it, reducing server load up to 50% .

PHP source code is compiled on-the-fly to an internal format that can be executed by the PHP engine. In order to speed up execution time and not have to compile the PHP source code every time the web page is accessed, PHP scripts can also be deployed in executable format using a PHP compiler.

Code

<!DOCTYPE html>

<meta charset=”utf-8″>

<title>PHP Test</title>

<?php

echo ‘Hello World’;

?>

Output: <?= ‘Hello world’;

Ruby (programming language)

Ruby is a dynamic, reflective, object-oriented, general-purpose programming language. It was designed and developed in the mid-1990s by Yukihiro “Matz” Matsumoto in Japan.

History

Ruby was conceived on February 24, 1993. 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. Choice of the name “Ruby”[edit]

The name “Ruby” originated during an online chat session between Matsumoto and Keiju Ishitsuka on February 24, 1993, before any code had been written for the language. Initially two names were proposed: “Coral” and “Ruby”. Matsumoto chose the latter in a later e-mail to Ishitsuka. Matsumoto later noted a factor in choosing the name “Ruby” – it was the birthstone of one of his colleagues.

Version

The first public release of Ruby 0.95 was announced on Japanese domestic newsgroups on December 21, 1995.

Ruby reached version 1.0 on December 25, 1996.[14]

Ruby 1.2 was initially released in December 1998.

Ruby 1.4 was initially released in August 1999.

Ruby 1.6 was initially released in September 2000.

Ruby 1.8 was initially released in August 2003, was stable for a long time, and was retired June 2013.[10] Although deprecated, there is still code based on it. Ruby 1.8 is incompatible with Ruby 1.9.

Ruby 1.9 was released in December 2007. Ruby 1.9 introduces many significant changes over the 1.8 series.[

Ruby 2.0[edit]

Ruby 2.0 added several new features.

Ruby 2.0 is intended to be fully backward compatible with Ruby 1.9.3. As of the official 2.0.0 release on February 24, 2013, there were only five known (minor) incompatibilities.

Ruby 2.1.0 was released on Christmas Day in 2013. The release includes speed-ups, bugfixes, and library updates. Starting with 2.1.0, Ruby is using semantic versioning.

Features

  • Thoroughly object-oriented with inheritance, mixins and metaclasses

  • Dynamic typing and duck typing

  • Everything is an expression (even statements) and everything is executed imperatively (even declarations)

  • Succinct and flexible syntax that minimizes syntactic noise and serves as a foundation for domain-specific languages

  • Dynamic reflection and alteration of objects to facilitate metaprogramming

  • Lexical closures, iterators and generators, with a unique block syntax

  • Literal notation for arrays, hashes, regular expressions and symbols

  • Embedding code in strings (interpolation)

  • Default arguments

  • Four levels of variable scope (global, class, instance, and local) denoted by sigils or the lack thereof

  • Garbage collection

  • Strict boolean coercion rules (everything is true except false and nil)

  • Exception handling

  • Operator overloading

  • Built-in support for rational numbers, complex numbers and arbitrary-precision arithmetic

  • Custom dispatch behavior (through method_missing and const_missing)

  • Native threads and cooperative fibers

  • Initial support for Unicode and multiple character encodings (no ICU support)

  • Interactive Ruby Shell (a REPL)

  • Centralized package management through RubyGems

  • Implemented on all major platforms

  • Large standard library, including modules for YAML, JSON, XML, CGI, OpenSSL, HTTP, FTP, RSS, curses, zlib, and Tk.

Syntax

The syntax of Ruby is broadly similar to that of Perl and Python. Class and method definitions are signaled by keywords. In contrast to Perl, variables are not obligatorily prefixed with a sigil. When used, the sigil changes the semantics of scope of the variable. One difference from C and Perl is that keywords are typically used to define logical code blocks, without braces (i.e., pair of { and }). For practical purposes there is no distinction between expressions and statements. Line breaks are significant and taken as the end of a statement; a semicolon may be equivalently used. Unlike Python, indentation is not significant.

To implement the equivalent in many other languages, the programmer would have to write each method (in_black, in_red, in_green, etc.) separately.

Some other possible uses for Ruby meta-programming include:

  • intercepting and modifying method calls

  • implementing new inheritance models

  • dynamically generating classes from parameters

  • automatic object serialization

  • interactive help and debugging

Implementations

Ruby 1.9 has multiple implementations:

  • The official Ruby interpreter often referred to as the Matz’s Ruby Interpreter or MRI. This implementation is written in C and uses its own Ruby-specific virtual machine,

  • JRuby, a Java implementation that runs on the Java virtual machine,

  • Rubinius, a C++ bytecode virtual machine that uses LLVM to compile to machine code at runtime. The bytecode compiler and most core classes are written in pure Ruby.

Other Ruby implementations:

  • MagLev (software), a Smalltalk implementation on VMware’s GemStone VM

  • MacRuby, an OS X implementation on the Objective-C runtime

  • Cardinal, an implementation for the Parrot virtual machine

  • IronRuby, an implementation on the .NET Framework.

Code

puts “Hello World!”

Output: Hello World!