Pike programming language
|
Pike is a general-purpose, high-level, dynamic programming language, with a syntax similar to that of C. Unlike many other dynamic languages, pike is statically typed, and requires explicit type definitions. It features a flexible type system that allows the rapid development and flexible code of dynamically typed languages, while still providing the benefits of a statically typed language. Pike features garbage collection, advanced data types, and first-class anonymous functions, and supports many programming paradigms, including object-oriented, functional, aspect-oriented and imperative programming. Pike is free software, released under the GPL, LGPL and MPL licenses.
History
Pike has its roots in LPC, which was a language developed for MUDs . LPC's license did not allow use for commercial purposes, and so a new GPL implementation was written in 1994, called ųLPC. In 1996, ųLPC was renamed to pike to provide a more commercially viable name. Although the name of the company has changed over the years, the company now known as Roxen Internet Software employed many pike developers, and provided resources for its development. In 2002, the programming environment laboratory at Linköping University took over maintenance of pike from Roxen.
Data types
The following list shows all the standard data types that pike provides. Advanced data types such as sequences, queues, heaps, stacks, etc. are available in the ADT module which is included with pike.
Basic data types:
- int
- float
- string
Container types:
- array
- mapping
- multiset
Reference types:
- program (the compiled representation of a class)
- object (an instance of a class)
- function
Pike requires explicit type definitions for all variables, and being a strongly typed language, uses this information to report type errors at compile time. The following code will produce a compiler error indicating that number must be an integer, and the code is attempting to assign floating point and string values to the integer variable.
int number; number = 5.5; // 5.5 is a floating point value number = "5"; // "5" is a string, not the integer value 5
This behaviour is traditionally considered restrictive and limiting by proponents of dynamically typed language. However unlike C, C++ and Java, pike uses a flexible type system, allowing programmers to declare variables that may be any of a number of types. The following demonstrates a variable that can be either an integer or a floating point number.
int|float number; number = 5; number = 5.5;
Additionally, there is a special "mixed" data type definition that allows a variable to be any kind of data type. In order to convert a value from one type to another, it must be explicitly cast:
int number; number = (int)"5.5"; // number is now the integer value 5
External links
- Official homepage (http://pike.ida.liu.se/)
- Community Page (http://www.gotpike.org/)ca:Pike