7 ms·
Squirrel – A high-level, light-weight scripting language
- abomus 12y agoOk
- yoanizer 12y agoyet another (scripting) language? nice.
- emodendroket 12y agoThe page doesn't do much to tell me why I would choose to use this over something I've heard of before.
- riffraff 12y agothe language has been around for quite a few years, but "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." could tell you it's smaller than ruby/python/php, and designed to be OO compared to Lua or others. There is also a list of features, I don't think the authors of the page should have a list of "we are better than X" for every value of X.
- emodendroket 12y agoNo, but my point was more that the very bare samples on the page don't tell me much about what's interesting about Squirrel or why I would use it. Just how to declare a class.
- throwawaymylife 12y agoSquirrel 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 12y agoI see. That's interesting; I think the page could do more to explain it.
- throwawaymylife 12y agoI 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.
- nanofortnight 12y agoIt's primary advantage over Lua is definitely it's better realtime guarantees.
- codexon 12y agoReference counting is not a complete GC solution, it does not collect circular references which happen quite often. That is why python will occasionally run a mark and sweep GC even though it says it uses reference counting.
- 1morethrowaway 12y agoIt's good enough by itself if you tell programmers not to create circular references and explicitly use weak references if they really need to. That opens you up to memory leaks from accidental circular references, of course, but again, it's a worthwhile tradeoff for many projects.
- codexon 12y ago
- ComputerGuru 12y ago7k 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 12y agothere 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 12y agoI 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.
- giancarlostoro 12y agoI agree it isn't, however it has been noted here that Valve has used Squirrel in some of their games including L4D2 and Portal 2. Also it has been used in FF Crystal Chronicles: My Life As A King as well. So much like Lua, it is used in video game development as an embedded scripting language.
- mutagen 12y agoA 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-squirrel-the-case-for-squirrel/ https://computerscomputing.wordpress.com/2013/02/18/lua-and-... 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.
- ExpiredLink 12y agoOne of many C-like scripting languages.
- philo23 12y agoThis 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
- eatonphil 12y agoDid a quick search for (C) FFI on the home page and didn't see anything. Can anyone corroborate?
- nanofortnight 12y agoIt'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
- crivabene 12y agoRon 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 12y agoI 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.
- mikob 12y agoIt's a flyweight language which makes it suitable for embedded devices. It brings some modern language conveniences to the embedded world; (eg. it's the language electric imp uses for the IoT devices: http://electricimp.com/ http://electricimp.com/)
- nanofortnight 12y agoIt'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.
- deleted 12y ago[deleted]
- jnbiche 12y agoIt's a relatively (10+ years) old language, and it is innovative in that it combines a scripting language with ref counting as opposed to garbage collection. How many other scripting languages do this?
- duaneb 12y ago> How many other scripting languages do this? Python, Perl, PHP, and TCL? Not really that innovative....
- juliangregorian 12y agoNope, all those languages are garbage collected.
- andybak 12y agoDid anyone else stop reading the minute they saw it wasn't using the One True Brace Style? Are these people barbarians!!??
- seabrookmx 12y agoAllman > OTB /s Not everybody likes OTB though, honestly.
- PythonicAlpha 12y agoTo 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 12y agoThe 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.
- ptx 12y ago> The line "optional 16bits characters strings" also makes me worry a little Especially since the other option isn't 32 bits, like it was in Python versions before 3.3 (which implemented PEP 393: "Flexible String Representation"). So you can only choose between broken Unicode (no characters outside the basic multilingual plane) or no Unicode at all.
- tracker1 12y agoIt looks like an error in the example in the page, shouldn't it have a comma after... a = "10"
- teamonkey 12y agoNormally 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.
- beagle3 12y agoI 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)