
Squirrel – A high-level, light-weight scripting language - xioxox
http://squirrel-lang.org/
======
mutagen
A quick google search found a nice article on the first question I had, how
does it compare to Lua?

[https://computerscomputing.wordpress.com/2013/02/18/lua-
and-...](https://computerscomputing.wordpress.com/2013/02/18/lua-and-squirrel-
the-case-for-squirrel/)

My first thought is "Squirrel doesn't have Mike Pall" but that isn't quite
fair to the author or the intentions of the language.

------
philo23
This is one of the scripting languages used in the Source Engine. I believe
the first game that supported it was Left 4 Dead 2, it was certainly the first
time I heard of it.

[https://developer.valvesoftware.com/wiki/VScript](https://developer.valvesoftware.com/wiki/VScript)

------
ComputerGuru
7k is just a random number. At that number, it can be a lot of lines or very
few - depends on what your scripting language can do. It's certainly not a
selling point!

~~~
yodsanklai
there are many such headlines on HN. "XXX in Y lines of code". I can't see in
what respect the number of lines of code matters. Regardless of what the
scripting language actually does, I'd rather have more lines of readable and
maintainable code, than less lines of obfuscated code.

~~~
kbenson
I think it's an important signifier for how easily you could read, and
hopefully grok, the entire codebase. At 7k lines, I, who have no experience
writing a scripting language, might be enticed to take a look. At 100k lines,
I'm not sure where to start, and thus likely _won 't_.

------
crivabene
Ron Gilbert chose Squirrel as the scripting engine of Thimbleweed Park:
[http://blog.thimbleweedpark.com/scripting_test](http://blog.thimbleweedpark.com/scripting_test)

If anyone is interested, the development blog is full of examples of how it is
being used in the game:
[http://blog.thimbleweedpark.com/scrolling_rooms](http://blog.thimbleweedpark.com/scrolling_rooms)
[http://blog.thimbleweedpark.com/switching_and_inventory](http://blog.thimbleweedpark.com/switching_and_inventory)

------
evincarofautumn
I like writing languages, but I really don’t understand what possesses someone
to write a new language that’s essentially a syntactic reskin of the same set
of imperative/OO features found in most popular languages. We don’t need new
syntax—we need new semantics.

~~~
nanofortnight
It's been around since <2003, so it's hardly new. It's primary purpose was a
high performance scripting language for game engines.

That being said I agree with you wrt new semantics and I would love to see a
practical programming language that has dependent types.

------
beagle3
I looked at it before - it seemed nice, but ... in those 13 years since the
release, Lua has amassed the critical support to take over the world (LuaJIT2,
FFI, stuff like Terra, MoonScript, Lua-in-JS, ...).

Lua and Squirrel being so close, it makes little practical sense to use
Squirrel in a new project. Maybe for fun projects.

(And for something that's a little different, I recommend a look at
[https://github.com/aardappel/lobster](https://github.com/aardappel/lobster)
\- it's a breath of fresh air among scripting languages; practically, I still
recommend Lua over anything else)

------
emodendroket
The page doesn't do much to tell me why I would choose to use this over
something I've heard of before.

~~~
throwawaymylife
Squirrel is roughly similar (in the grand scheme of things) to Lua and
JavaScript, with more of a (C++-style) OO flavor. Its main selling point is
that it uses reference counting instead of a tracing garbage collector for
automatic memory management. With a reference counted language, you pay a
small but predictable cost every time something goes out of scope, whereas
tracing garbage collectors coalesce all of these small costs into one big
collection cycle run every few milliseconds. The tradeoff is that while
garbage collected languages provide better throughput (due to cache effects,
heap fragmentation, etc) for batch processing jobs, reference counted ones are
much more suitable for realtime and soft realtime applications that would much
rather take a constant factor hit to throughput if it eliminates the danger of
a multi-millisecond GC scan causing the application to miss a deadline.

As such, Squirrel enjoys some popularity as (and was indeed created to serve
as, by an engineer that had grown frustrated with the experience of embedding
Lua in FarCry) a scripting language for video games, being most notably used
in some of Valve's newer games, like Left 4 Dead 2, Portal 2, and CS:GO. The
rest of the engine code usually dwarves the performance impact of "scripts" in
most games, but GC scans can still cause games embedding other scripting
languages to miss a frame presentation deadline, resulting in either a nasty
tear or a completely missed frame. There are ways that tracing garbage
collected languages can attempt to combat this (like incremental GCs), but
some engine programmers have decided to accept the throughput cost for the
peace of mind that reference counting provides.

EDIT: I had more but HN is silently ignoring some of my edits for some reason.
Is there a post length restriction for new users, or have I tripped some kind
of bizarre content filter?

~~~
emodendroket
I see. That's interesting; I think the page could do more to explain it.

~~~
throwawaymylife
I agree. With embedded "scripting" languages, you have to differentiate
between two kinds of users that don't always (or even usually) overlap: the
people writing the scripts (who may or may not even consider themselves to be
programmers), and the engine programmers embedding the language in their game
engine or other application. IMHO, the current homepage isn't really doing a
great job of appealing to either group, and it'd be much more effective if it
directly explained the advantages of its implementation to the engine dev
crowd; that might alienate the script programmers a bit, but thinking about
AAA game development, they're almost never the ones that get to pick the
language anyway.

------
teamonkey
Normally I'm agnostic on the issue of type safety, but the best game scripting
language I used was a proprietary one that was strongly typed with no implicit
casting (it also had no GC).

In my experience, a game script most often uses handles to certain types of
game engine objects (cameras, vehicles, characters, the player...) and
although it's often necessary to define your own types/classes/objects they're
rarely complex. Usually you're just iterating over collections of stuff,
exploring trees, querying the current state of the game engine or dealing with
some kind of internal state.

Because of this, explicit type safety isn't really the burden it can be in
other use cases, even for prototyping. Because you generally want hot reloads
and for a game script to fail gracefully without stopping the engine, you
probably want to add as much sanity checking as possible before it gets to
that point.

------
PythonicAlpha
To have it short: With the syntax of C/Java and scripting features, what does
this language differentiate from JavaScript?

There are some nice features added, but I think that some of them are also
covered by newer JS versions. I really don't want to argue to much about JS,
but other persons will ask the same question, I guess.

The line "optional 16bits characters strings" also makes me worry a little,
since I know how much trouble an alternate approach (8bit strings vs. Unicode)
there is in Python (which led to major changes in Python 3). It just makes to
much headaches.

If the author is reading here, you might also consider linking to a page of
your personal website, that is accessible (I get directory listing denied).

~~~
subb
The advantage is that it's usable in a soft-real time scenario because it
manage memory is a deterministic manner with ref counts instead of a GC.

------
tracker1
It looks like an error in the example in the page, shouldn't it have a comma
after...

    
    
        a = "10"

------
eatonphil
Did a quick search for (C) FFI on the home page and didn't see anything. Can
anyone corroborate?

~~~
nanofortnight
It's primary purpose is to be embeded, so it has a similar interop interface
to other embeddable languages: [http://squirrel-
lang.org/doc/squirrel3.html#d0e4060](http://squirrel-
lang.org/doc/squirrel3.html#d0e4060)

------
yoanizer
yet another (scripting) language? nice.

------
ExpiredLink
One of many C-like scripting languages.

------
andybak
Did anyone else stop reading the minute they saw it wasn't using the One True
Brace Style? Are these people barbarians!!??

~~~
seabrookmx
Allman > OTB

/s

Not everybody likes OTB though, honestly.

