Hacker News new | past | comments | ask | show | jobs | submit login
Squirrel Programming Language (valvesoftware.com)
81 points by _zhqs on July 12, 2016 | hide | past | favorite | 50 comments



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?


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.


In short, Squirrel is small, nimble and has features that are pretty nuts. Looking for something else? You're barking up the wrong tree.


Puns like these make my day.


You should visit Reddit front page more often


perhaps I should


Is it actually faster though?

https://github.com/r-lyeh/scriptorium

Perhaps these results are due to poor coding practices in the example code.


Huh. Weird. That shouldn't be right. Squirrel can do a lot of optimizations Lua can't. Maybe it's just that problem...


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


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.


Is that what 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.


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


It really speaks more to the runtime than the language. There's nothing fundamentally anti-parallel about lua, but even just concurrent GC is difficult to execute well. Look at how big of a deal Go's recent low latency claims are.


Lua can't be multithreaded in any real sense (by "real", I mean "OS threads"). If Squirrel can that's a big advantage.


I thought it could, but I think I might have been wrong... Nope, just coroutines. Sorry for being wrong. However, as it is small and embeddable, it's trivial to spin up multiple instances of the interpreter. But Lua and TCL are just as good at that.


0-index. I tried to like Lua, but indexing from 1 is just too painful when you have to talk to C.


In times like that, I would just assume the array size is +1, and ignore the first C Zero position. It's a pain but just setup something once and its done.


No, it's not. See here: http://lua-users.org/wiki/CountingFromOne

I made a comment on that wiki MOONS ago, and it still holds.


It looks like arrays are different from tables and they start at 0.


The combination of reference counting and tracing GC looks interesting. There have been a couple of attempts to retrofit reference counting into Lua, but nothing stable or widely used AFAIK.


I am guessing that it is used in Valve games..


I wonder if parts of it were used in TF2 updates since that hasn't gotten an update in a while


I think squirrel offers much better C++ integration.





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


Lily is fascinating to me, in that it's the exact language I've been working on in my spare time. Same impetus, use-cases, everything. Guess someone else shares my delusion after all ;)


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.


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.


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.


From the wiki (http://wiki.squirrel-lang.org/default.aspx/SquirrelWiki/Lua%...) it looks like most of the reasons Squirrel was created stemmed from problems that have since been fixed in Lua.

The remaining differences seem pretty minor; IMO having the OO system baked into the language instead of implemented in user-space is a step backwards. The 0-indexing might be nice if you do a lot of FFI with C, I suppose. Hardly worth giving up the insane performance of LuaJIT for though.


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?


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 [2] http://lua-users.org/lists/lua-l/2006-10/msg00063.html


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.)


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


I would love to have something like Dialyzer to do static checks for Lua, but luacheck is a lot better than nothing: https://github.com/mpeterv/luacheck


Interesting that hajile and you both dislike global-by-default, but your proposed alternatives are essentially opposites. hajile would prefer local-by-default and fewer declarations, and you would prefer nothing-by-default and more declarations...


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.


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


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


Better to see the actual documentation at: http://squirrel-lang.org/squirreldoc/reference/index.html


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


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.


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.


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.


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

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


Does anybody remember Quake C?


Why is it called Squirrel?


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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: