- Sleep (programming language)
Infobox programming language
name = Sleep
logo =
paradigm = procedural, scripting
year =2002
designer = Raphael Mudge
developer =
latest_release_version = 2.1
latest_release_date = release date|2008|07|01
latest_test_version =
latest_test_date =
typing = dynamic
implementations =
dialects =
influenced_by =Perl ,Objective-C
operating_system =Cross platform (JVM)
license = LGPL
website = http://sleep.dashnine.org/Sleep (as of "Simple Language for Environment Extension Purposes") is a procedural
scripting language inspired byPerl andObjective-C . The only known implementation of the language is written in Java and is intended for embedding into existing Java applications to provide scripting services.The Sleep Java API allows the language to be extended with new constructs, operators, functions, and variable containers, making it easy to integrate it into applications.
Sleep is currently utilized in the IRC client
JIRCii and theIRC bot [http://www.ululatus.org/sleepybot/ SleepyBot] .Status and History
Sleep first version appeared in a week-end of coding in April
2002 . Since then Sleep has been developed in parallel with a Java IRC Client which heavily uses its features called [http://jirc.hick.org/jirc/ jIRCii] .The current stable 2.1 version is available since July2008 .Overview
Sleep is very easy to learn in its basic form, and anyone familiar with Perl or
PHP will feel right at home. In addition to being embeddable, Sleep can also be used stand-alone on the command line or using an interactive shell.Language features
Data structures and types
Sleep has native support for three widely different
data types : scalars,array s, and hashes. Scalars are prefixed with a dollar sign ($ ), arrays with 'at'-signs (@ ) and hashes with percentage signs (% ).* Scalars represent either a string, or a
number . Strings can be specified inrun-time as literals or as parsed literals. Numbers are eitherinteger s, orfloating point . Scalars can also contain references to objects when utilizing the HOES subsystem.
*Array s are a collection of scalars, hashes or other arrays referenced by an index number, starting at 0.
* Hashes are similar to arrays, but maps keys to values. Keys can be both strings and numbers.Dynamic typing
Sleep is a dynamically typed language. This means that variables don't have to be declared, or typed, before being used. There are certain advantages to this, and also certain disadvantages.
Input/output
Included in Sleep is support for basic input/output. This includes reading and writing from/to files and sockets.
Serialization
Parsed [http://sleep.hick.org Sleep] scripts can be serialized and saved to disk. This means faster execution of scripts since the script interpreter can skip the parser and scanner steps.
HOES
HOES is a feature that lets the scripter manipulate Java objects using a syntax similar to
Objective-C . Objects and primitives can be referenced via ordinary Sleep scalars.Easy integration
Sleep is integrated into Java applications using the concept of "programmatical bridges". These bridges act as a proxy between the Sleep scripts and the application they're run for. Bridges are written in Java, and there is extensive documentation and tutorials on how to write them.
Sleep supports the following bridge types:
* Loadable bridges
* Function bridges
* Operator bridges
* Predicates bridges
* Evaluation bridges
* Variable bridges
* Environment bridges
* Filtered environment bridges
* Predicate environment bridgesBridges can also act as "modules", as in expanding the API available to the scripts. For example, a JDBC module is underway, providing advanced database connectivity to Sleep scripters. Several other similar modules are also being planned to expand Sleep with XML/XSLT capabilities, improved sockets with support for UDP, Swing GUI, and more.
Applications
Sleep is currently being used actively in the following applications:
* [http://jircii.hick.org jIRCii]
* [http://www.ululatus.org/sleepybot/ SleepyBot]Examples
This example outputs the text "Hello world!":
# This example outputs "Hello world!" to stdout println("Hello World!");
Another more complex example:
# Usage: format(subject, repl1, repl2, ...,); # Example: format('a {0} c', 'b'); # returns 'a b c' sub format { local('$subject @args $idx $match'); @args = @_; $subject = removeAt(@args, 0); foreach $i => $arg (@args) { $match = '{' . $i . '}'; $subject = strrep($subject, $match, $arg); } return $subject; }
External links
* [http://sleep.dashnine.org/ Sleep home page]
Wikimedia Foundation. 2010.