Languages Features Creators CSV Resources Challenges Add Language
GitHub icon

Squirrel

Squirrel - Programming language

< >

Squirrel is a programming language created in 2003 by Alberto Demichelis.

#168on PLDB 20Years Old 1.7kUsers
0Books 0Papers 2kRepos

Try now: Riju · TIO

Squirrel is a high level imperative, object-oriented 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 and hardware such as Electric Imp. MirthKit, a simple toolkit for making and distributing open source, cross-platform 2D games, uses Squirrel for its platform. It is used extensively by Code::Blocks for scripting and was also used in Final Fantasy Crystal Chronicles: My Life as a King. Read more on Wikipedia...


Example from Riju:
print("Hello, world!\n")
Example from hello-world:
print("Hello World");
#!/usr/bin/squirrelsh // Hello world in Squirrel printl("Hello, world!");
Example from Linguist:
//example from http://www.squirrel-lang.org/#documentation local table = { a = "10" subtable = { array = [1,2,3] }, [10 + 123] = "expression index" } local array=[ 1, 2, 3, { a = 10, b = "string" } ]; foreach (i,val in array) { ::print("the type of val is"+typeof val); } ///////////////////////////////////////////// class Entity { constructor(etype,entityname) { name = entityname; type = etype; } x = 0; y = 0; z = 0; name = null; type = null; } function Entity::MoveTo(newx,newy,newz) { x = newx; y = newy; z = newz; } class Player extends Entity { constructor(entityname) { base.constructor("Player",entityname) } function DoDomething() { ::print("something"); } } local newplayer = Player("da playar"); newplayer.MoveTo(100,200,300);
Example from Wikipedia:
class BaseVector { constructor(...) { if(vargv.len() >= 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 ::Vector3) return ::Vector3(x+other.x,y+other.y,z+other.z); else throw "wrong parameter"; } function Print() { ::print(x+","+y+","+z+"\n"); } } local v0 = Vector3(1,2,3) local v1 = Vector3(11,12,13) local v2 = v0 + v1; v2.Print();

Language features

Feature Supported Token Example
Strings "
"Hello world"
Print() Debugging print
Line Comments //
// A comment
Comments
Semantic Indentation X
fantom.html · squirrel.html · reverse-polish-notation.html

View source

- Build the next great programming language · Search · Day 209 · About · Blog · Acknowledgements · Traffic · Traffic Today · GitHub · feedback@pldb.com