7 ms·
The Squirrel Programming Language
- panic 10y agoHow does this compare to Lua? It seems to be going after a very similar market.
- adamnemecek 10y agoThis seems to be making some good points but I'm only reading it now https://computerscomputing.wordpress.com/2013/02/18/lua-and-squirrel-the-case-for-squirrel/ https://computerscomputing.wordpress.com/2013/02/18/lua-and-... Huh, it actually seems like an older language, it's been around for a while and it's used in some major studio games.
- pikachu_is_cool 10y agoTo me, it looks like the only improvement of Squirrel upon Lua is automatic reference counting. Everything else seems like a step backwards. * C++ < ANSI C * two null types < one nil type * separate types for arrays and dicts < tables * C syntax < plain english * Builtin classes < make-your-own classes That's just my opinion though :)
- yoz-y 10y agoI am curious, why do you consider make-your-own-classes a superior approach?
- pikachu_is_cool 10y agoHaving OOP built into the C/C++ codebase is just a chunk of complexity that is needlessly built into the language itself; it can only be maintained by a select group of people who understand it. Instead, you could just use an OOP library, or implement the parts of OOP you want in like 20 lines of Lua. The great thing about this is you can fine-tune it to your needs. Want transparent encapsulation, or multiple inheritance? It just takes an extra 10-20 lines of code! Now you don't have to pester the Squirrel developers to put it in. :p
- yoz-y 10y agoMy counter argument would be that if objects are implemented at the language level it makes it easier for developers for the following reasons: - there is exactly one way to do it - objects can be transported between codebases without wrappers - beginners know where to look and everybody can understand everybody's codebase - the compiler can optimise them better - generally the syntax is nicer, looking at some object implementations in lua I must say that they are hideous, very similar to object implementations in javascript before ES6
- pikachu_is_cool 10y agoThere are efforts to unify OOP to be compatible across codebases: https://github.com/bartbes/Class-Commons https://github.com/bartbes/Class-Commons, but yeah I agree it is still somewhat of an issue. For the beginners thing: most beginners who use Lua don't even touch OOP. The main idea for Lua is to have concepts that are super easy for a layman to fit in their head; OOP is like this huge convoluted "idea" that has a bunch of different possible implementations and approaches. Plus... setting up the userscript/metatable structure goes a long way in abstracting it for beginners; look at how Garry's Mod does it for in-game weapons. It doesn't even use full OOP, all it has is inheritance and it doesn't even call it that; opting to call superclasses the "base" weapon. It was easy enough for me as a 12 year old non-programmer to grasp. Plus... seeing words like "class" or "constructor" would for sure deter beginners. It's not expressive enough. When I started out, I remember looking at the curly braces for a table and thinking it was some advanced programmer stuff, and I avoided it as much as possible. That feeling would probably be 10x for something like full-blown OOP. Once you force them to leave the editor to learn some concept on Wikipedia, you lost IMO. I agree with you on the optimization/syntax thing, but I think it's a necessary tradeoff. Any feature that is built into the language can get some sort of buff from that sort of stuff. I just don't think the pros outweigh the cons... Lua isn't the kind of language to leverage OOP much (other than inheritance). For me, this is pretty much the extent of OOP I've needed in Lua (along with transparent encapsulation, but I cut that code out because it would add around 10-15 more lines): OBJECT = {} function OBJECT:new() local obj = {} setmetatable(obj, {__index = self}) return obj end local subclass = OBJECT:new() This, combined with tables and closures, has suited me just fine.
- jwdunne 10y agoHow is separate types for arrays and dictionaries worse? They are two different data structures with different uses so should be separate.
- pikachu_is_cool 10y agoOne of the strengths of Lua is how usable it is for non-programmers. Having separate concepts for (essentially) a hashmap for integers and a hashmap for everything else makes it more complicated.
- emsy 10y agoThat C++ is inherently worse than C is a preposterous preconception. The only point I'd remotely agree with is the two null types, though it makes sense if you know that they express two different concepts.
- pikachu_is_cool 10y agoI was referring to portability. Being written in ANSI C is one of Lua's biggest strengths in that regard.
- sdegutis 10y agoWow. Reading that renewed my excitement for programming language design and implementation! But with 5 kids, I'm kept pretty busy and won't really have time for that kind of thing until I'm retired. And I have no real need for it, it would just be really fun. But still...
- slezyr 10y agoDo you need OOP? Then Squirrel. No? Use lua.
- pikachu_is_cool 10y agoLua supports OOP, it can be written in < 20 lines of code. It's just not built-in.
- dang 10y agoPreviously discussed at https://news.ycombinator.com/item?id=9368075 https://news.ycombinator.com/item?id=9368075.
- jclekberg 10y agohttp://www.ticalc.org/archives/news/articles/14/148/148909.html http://www.ticalc.org/archives/news/articles/14/148/148909.h...
- iumtuip2001 10y agoI appear to be a dying breed. A young ( < 30 years old ) programmer, self taught, who loves classic, "mainstream" languages like C, C++, Java... Why? Types. I cannot stand the road that new languages are on, abandoning the type system, or making it optional, or not explicit. Given that I appear to be a minority, I thank you for reading my rant... Have a good day :(
- jaked89 10y agoRest assured, not all new languages take this route. On the other side of the spectrum, type systems get stronger and more powerful. Read about dependent typing in Idris, F*. Also, nearly all academic work focuses on improved type systems.
- illivah 10y agoI feel like we're just no longer the shiny hotness. I think a lot of people WANT to be self-made self-taught semi-low-level language programmers. I listen to a lot of podcasts. My god, I just want a decent show that is NOT focused on web development. Is that so much to ask? Oh, and not ios/windows focused, 'cus then literally everything you talk about no longer applies to me. And not "a new language every week" because my god, you can't deep-delve into anything like that. Hell, not even javascript can be covered in an hour.
- haberman 10y agoI don't think looser typing is the current trend at all. I think the opposite is true: there's a movement towards more typing, particularly among the languages that have traditionally been the most dynamically typed. - Type hinting is a significant new feature in PHP 7.x: http://php.net/manual/en/migration70.new-features.php http://php.net/manual/en/migration70.new-features.php - Python 3.5 introduces type hinting: https://docs.python.org/3/library/typing.html https://docs.python.org/3/library/typing.html - Ruby is talking about possibly adding a static typing system to Ruby 3.x (this is very early stage, but there appears to be interest): https://codon.com/consider-static-typing https://codon.com/consider-static-typing. Also 24 days ago Matz talked about possibly adding type inference to Ruby3x3: https://bugs.ruby-lang.org/issues/9999 https://bugs.ruby-lang.org/issues/9999 - Flow and TypeScript add types to JavaScript. - JavaScript is adding more structure to its type system with ES6 classes. - Newer languages such as Swift and Dart are certainly more typed than the Python/Ruby/JavaScript generation. - Rust is typed to the max. I guess what I'm saying is that if you like type systems, the future is bright. :)
- pesha 10y agoI had to do one project in Squirrel when I was in university and I have to say the experience was terrible.
- qz_ 10y agoWhy?
- pikachu_is_cool 10y agoYeah I would also like to know this.
- mingodad 10y agoI did a fork of Squirrel -> SquiLu https://github.com/mingodad/squilu https://github.com/mingodad/squilu because I found the syntax more familiar and also been made with C++ that make create extensions easier than plain C. Then I started adding more and more C/C++ like syntax options with the idea to have a way to develop fast prototypes in a way that could be migrated to C/C++ when performance was not good enough, the idea is to be able to parse and accept C/C++ syntax but without actually inforce it at scripting level (accept discard/warning) and be able to use a real C++ compiler to do the heavy work. Example: class Klass //struct Klass { int_t i; //constructor() Klass() { print("Klass constructor", i); } ~Klass() { print("Klass destructor"); } } Klass k = new Klass(); typedef int_t int; int test10(int x) { dente: if(x > 10) { goto dente; goto done; return true; } done: return false; } print(test10(23)); output: test-class-constructor.nut:22:6 warning labels are only parsed right now test-class-constructor.nut:25:7 warning goto is only parsed right now test-class-constructor.nut:26:7 warning goto is only parsed right now test-class-constructor.nut:29:5 warning labels are only parsed right now Klass constructor (null : 0x(nil)) true
- mingodad 10y agoBut now Haxe http://haxe.org/ http://haxe.org/ has several advantages that's worth consider.
- mingodad 10y agoAlso worth look at Skew http://skew-lang.org/ http://skew-lang.org/
- mingodad 10y agoIdeally it'll lead to something like Terra http://terralang.org/ http://terralang.org/ or Cxx.jl https://github.com/Keno/CXX.jl https://github.com/Keno/CXX.jl
- ciroduran 10y agoOpenTTD (http://www.openttd.org/en/ http://www.openttd.org/en/) is a Transport Tycoon clone that allows you to write an AI player for the game. The AI player is written in Squirrel.
- dalbin 10y agoThis language is used in Electric Imp, an "IoT" oriented ARM μController with WiFi, used in Wink products and Lockitron : https://electricimp.com/docs/squirrel/squirrelcrib/ https://electricimp.com/docs/squirrel/squirrelcrib/
- neukoelln 10y agoI think Ron Gilbert uses Squirrel in his upcoming game Thimbleweed Park.
- potomak 10y agoCorrect, see https://blog.thimbleweedpark.com/engine https://blog.thimbleweedpark.com/engine and https://blog.thimbleweedpark.com/scripting_test https://blog.thimbleweedpark.com/scripting_test.
- kkirsche 10y agoHow does this compare to Lua which seems to be the go to scripting ish language in games like world of Warcraft