Squirrel (programming language)

Squirrel (programming language)

Squirrel is a high level imperative/OO programming language, designed to be a light-weight scripting language that fits in the size, memory bandwidth, and real-time requirements of applications like video games. MirthKit, a simple toolkit for making and distributing open source, cross-platform 2D games, uses Squirrel for its platform for its good combination of familiar syntax, strong embedding support, and a compact but very useful standard library. [ [http://devs.mirthkit.com MirthKit Developer Wiki] ]

Language features

*Dynamic typing
*Delegation
*Classes & inheritance
*Higher order functions
*Generators
*Cooperative threads (coroutines)
*Tail recursion
*Exception handling
*Automatic memory management (primarily reference counting with backup garbage collector)
*Weak references
*Both compiler and virtual machine fit together in about 6k lines of C++ code.
*Optional 16-bit characters strings

yntax

Squirrel uses a C-like syntax

Factorial in Squirrel:

function factorial(x) { if (x = 0) { return 1; } else { return x * factorial(x-1); } } Random numbers using generators: function gen_random(max) { local last=42 local IM = 139968; local IA = 3877; local IC = 29573; for(;;) { //loops forever yield (max * (last = (last * IA + IC) % IM) / IM); } } local randtor = gen_random(100); for(local i = 0; i < 10; i += 1) print(">"+resume randtor+" ");

Classes and inheritance:

class BaseVector { constructor(...) { if(vargc >= 3) { x = vargv [0] ; y = vargv [1] ; z = vargv [2] ; } } x = 0; y = 0; z = 0; } class Vector3 extends BaseVector { function _add(other) { if(other instanceof this.getclass()) return ::Vector3(x+other.x,y+other.y,z+other.z); else throw "wrong parameter"; } function Print() { ::print(x+","+y+","+z+" "); } } local v0 = Vector3(1,2,3) local v1 = Vector3(11,12,13) local v2 = v0 + v1; v2.Print();

History

The language was made public in 2003 under the zlib/libpng license. It is developed and maintained by Alberto Demichelis.

ee also

*Lua
*Python
*Ruby

References

External links

* [http://www.squirrel-lang.org/ Squirrel Home Page]
* [http://wiki.squirrel-lang.org/ SquirrelWiki]
* [http://www.mirthkit.com/ MirthKit Home Page]


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • Shakespeare (programming language) — The Shakespeare Programming Language (SPL) is an esoteric programming language designed by Jon Åslund and Karl Hasselström. [ [http://shakespearelang.sourceforge.net/report/shakespeare/shakespeare.html The Shakespeare Programming Language] ] Like …   Wikipedia

  • Lua (programming language) — Infobox programming language name = Lua paradigm = Multi paradigm: scripting, imperative, functional year = 1993 designer = Roberto Ierusalimschy Waldemar Celes Luiz Henrique de Figueiredo developer = latest release version = 5.1.4 latest release …   Wikipedia

  • Object-oriented programming language — An object oriented programming language (also called an OO language ) is one that allows or encourages, to some degree, object oriented programming techniques such as encapsulation, inheritance, modularity, and polymorphism. Simula (1967) is… …   Wikipedia

  • Squirrel (disambiguation) — Squirrel may refer to:*Squirrel, a common name for members of the Sciuridae family of rodents and some related species *Squirrel (DHT), a web caching system *Squirrel (programming language) *Squirrel (peanut butter), a Canadian brand of peanut… …   Wikipedia

  • Squirrel (langage de programmation) — Pour les articles homonymes, voir Squirrel. Squirrel est un langage de programmation haut niveau impératif et orienté objet, conçu pour être un langage de script léger qui soit compatible en taille, occupation mémoire, et exigence temps réel d… …   Wikipédia en Français

  • List of programming languages — Programming language lists Alphabetical Categorical Chronological Generational The aim of this list of programming languages is to include all notable programming languages in existence, both those in current use and historical ones, in… …   Wikipedia

  • Scripting language — Scripting redirects here. For other uses, see Script. A scripting language, script language, or extension language is a programming language that allows control of one or more applications. Scripts are distinct from the core code of the… …   Wikipedia

  • Children's programming on NBC — Children s programming has played a part in NBC s programming since its initial roots in television. Contents 1 History 1.1 1947–1956 1.2 1956–1992 1.2.1 See also …   Wikipedia

  • SMALL — SMALL, Small Machine Algol Like Language, is a programming language developed by Dr. Nevil Brownlee of Auckland University.HistoryThe aim of the language was to enable people to write ALGOL like code that ran on a small machine. It also included… …   Wikipedia

  • Source (game engine) — Source engine …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”