
Squirrel Programming Language - joubert
https://developer.valvesoftware.com/wiki/Squirrel
======
justusw
Given that Lua and Squirrel are quite similar due to meta tables resembling
each other, what does Squirrel provide compared to Lua except for the C-Style
syntax?

~~~
qwertyuiop924
It's hyper-optimized, small, and can be multithreaded or multiplexed
trivially, but that's true of lua as well. The array thing gives it a leg up
in speed as well, as does 0-indexing. Finally, its gc algorithm doesn't have
cpu bursts (it's not "stop the world"). I don't know of Lua has this feature,
but it makes the language ideal for real-time applications. Like games.

~~~
iamcreasy
What does it mean by a language can be multiplexed trivially?

~~~
qwertyuiop924
You can run multiple interpreters, embedded in the same application, in
separate threads: multiplexing, as you have multiple instances, as opposed to
multithreading, where you have a single instance.

~~~
safewayclubcard
Is that what
[https://github.com/rvirding/luerl](https://github.com/rvirding/luerl) is
doing in the erlang VM?

From the docs:

> It should give you a Lua environment that allows you to effortlessly run
> tens of thousands of Lua processes in parallel, leveraging the famed
> microprocesses implementation of the Erlang VM. The empty Luerl State
> footprint will be yet smaller than the C Lua State footprint.

~~~
qwertyuiop924
Yes. Lua does it quite well by default. Apparently, luerl aspires to do it
better.

------
jonathonf
Official site:

[http://squirrel-lang.org/](http://squirrel-lang.org/)

Similar:

[http://wren.io/index.html](http://wren.io/index.html)

~~~
vmorgulis
AngelScript too:

[http://www.angelcode.com/angelscript/](http://www.angelcode.com/angelscript/)

~~~
mlinksva
Also Lily
[https://github.com/jesserayadkins/lily](https://github.com/jesserayadkins/lily)
recently discussed
[https://news.ycombinator.com/item?id=12015158](https://news.ycombinator.com/item?id=12015158)

~~~
technomancy
Lily's design is actually pretty unique; it feels a lot less "me too!" than
the others.

------
vegabook
Please could you explain to me, if Squirrel is "similar to Lua, but uses a C
like syntax", why I wouldn't want to use C or Lua instead?

Is this about Steam? If not, is this (even) faster than Lua? Is it easier or
safer than C? Am I missing something? You better have something seriously good
to offer if in your first breath you're pitching yourself alongside the very
best of both interpreted and compiled languages.

~~~
Jtsummers
You would use this in the same arena you'd use Lua, not where you'd use C.
That is, you want something more flexible than compiled C for your particular
application.

Why you'd use it over Lua, I haven't figured out yet, but I don't use either
so I have no basis for comparison.

~~~
je42
Actually, there are arena's where C is replaced by Lua (with LuaJIT) see
OpenResty / Nginx with Lua. Where the normally C plugins to nginx are
implemented with lua.

------
hajile
If you're changing the syntax, why not take the time to fix having to use
`local` everywhere instead of making things local by default?

~~~
bakery2k
Presumably the author of Squirrel agrees with (one of) the authors of Lua:
"Local by default is wrong" [1].

"The problem is that without local declarations, you cannot say where the
variable is local to" [2]. Take Python, for example, where "local by default"
means "local to the current function". Variables are created in the current
function's scope on assignment, which causes 2 problems:

1\. It is awkward to modify variables in outer scopes, because an attempt to
assign to them creates a new variable. Python works around this with the
`global` and `nonlocal` keywords.

2\. Python does not support variables which are local to the current _block_ ,
for example, the body of a loop.

[1] [http://lua-users.org/lists/lua-l/2006-10/msg00056.html](http://lua-
users.org/lists/lua-l/2006-10/msg00056.html) [2] [http://lua-
users.org/lists/lua-l/2006-10/msg00063.html](http://lua-
users.org/lists/lua-l/2006-10/msg00063.html)

~~~
to3m
If Lua did the decent thing and insisted that you declare every variable
first, it wouldn't have this stupid problem. Squirrel should probably do it,
too. Python certainly should! (Even _Javascript_ , misguided as it is in so
many respects, has strict mode!)

This sort of static checking massively increases the amount of code you can
look after without going insane. Add static types too, and you're even better
off.

(Last time I used Lua, I modified it so that all variables had to be
introduced before their first use, either using `local', or a new `global'
keyword. More static checks, and no more accidental globals.)

~~~
looki
Lua's metatables are very powerful, and there's actually a tiny implementation
of "strict mode" for Lua [1]. I do agree that static checks like these would
help the language for serious applications. I recently got back into Lua a bit
and the first error I made was omitting "local".

[1]:
[http://metalua.luaforge.net/src/lib/strict.lua.html](http://metalua.luaforge.net/src/lib/strict.lua.html)

------
dkersten
I've played with Squirrel years ago and its a really nice language. But in the
end, I went back to Lua because of LuaJIT.

------
mcphage
The 2008 WiiWare game "Final Fantasy Crystal Chronicles: My Life as a King"
was implemented in Squirrel.

------
sreidnw
I've also run across Squirrel (or a variant of it) on Electric Imp (an
IoT/embedded platform):
[https://electricimp.com/docs/squirrel/](https://electricimp.com/docs/squirrel/)

------
brianobush
Better to see the actual documentation at: [http://squirrel-
lang.org/squirreldoc/reference/index.html](http://squirrel-
lang.org/squirreldoc/reference/index.html)

------
jupiter90000
Ron Gilbert is using Squirrel as a scripting language in the game Thimbleweed
Park [1]. For someone developing games for as long as he has, I think it lends
some credibility to it (though I would still evaluate it before I choose to
use it for my use cases).

[1]
[https://blog.thimbleweedpark.com/text_tron_3000](https://blog.thimbleweedpark.com/text_tron_3000)

~~~
insomniatic
I really appreciate his examples. I feel like it's a great example of
experience seeing the value of a first-order iteration process, but making
sure that the technical debt accrued is easily remedied by an automated
process that has already been worked out. TLDR: the value of the speed
obtained in accruing technical debt, and the wisdom to ensure that you don't
have to really pay for it.

------
hoodoof
New programming languages need really compelling, upfront "why this new
language" arguments.

I love the idea of new languages but there's plenty of good ones out there so
there has to be a super good argument in my face explaining why.

------
habosa
I interviewed a candidate a year ago who said their preferred language was
'Squirrel'. This was my first interview ever I thought maybe I was being
pranked. Was pretty straightforward to read though.

------
snarfy
It's also the scripting language for the Irrlicht rendering engine.

[http://irrlicht.sourceforge.net/](http://irrlicht.sourceforge.net/) (seems
down at the moment)

------
ricksplat
Does anybody remember Quake C?

------
grimmdude
Why is it called Squirrel?

~~~
GadgetJax
Squir-Rel who came from Superman's planet, you know.

