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