4 ms·
I looked into JS as an alternative, given that ES6 cleaned up a lot of the things that had previously been bugging me about JS. I thought JS must be well-suite
by gyulai 4y ago
I looked into JS as an alternative, given that ES6 cleaned up a lot of the things that had previously been bugging me about JS. I thought JS must be well-suited for embedding usecases, and the vastly larger language community, compared to Lua, must be an advantage of some sort.
But I ended up concluding that I still don't want to go anywhere near JS.
It's like browser-based use of JS and node-based use of JS are sucking the air away from JS's potential as a language for embedding.
e.g. Nashorn was part of the Java standard API in Java 8 but then got dropped. There's project Detroit to try to replace it, but it doesn't seem to be going anywhere. Most people interested in embedding JS in Java will presumably want node compatibility, even though node is not a great architecture for embedding, so that's what GraalJS is doing, but it comes at the cost of a loss of portability to non-Graal Java environments. A widely-used way of embedding JS in C# is by actually invoking the system browser through WebView in some weird and convoluted way. ...it's things like that which make me recoil in horror. Meanwhile Lua for Java and Lua for C# is just quietly and humbly in existence and using a sane architecture.
...and then JS libraries are full of this async-stuff with promises and whatnot, and I'm reluctant to go anywhere near that if I'm positively certain that it serves absolutely no purpose in the applications I actually intend to build and comes at the price of making code so much more complicated and unreadable.
- hunterb123 4y agoI've had some success with https://github.com/TypeScriptToLua/TypeScriptToLua https://github.com/TypeScriptToLua/TypeScriptToLua Luau may be an alternative as well, haven't tried it. I love Lua, but at larger scales it's unmanageable. Nim is used heavily in the gaming industry as a Lua replacement as well.
- gyulai 4y ago> ...but at larger scales it's unmanageable. Can you elaborate on what it is you find unmanageable about Lua at scale? Is it just typing that you're missing? The biggest difference between Lua and TypeScript in my mind is that Lua has been going on a minimally-invasive and continuous upgrade path for decades, so I assume that it will likely keep doing that for several more decades. With TypeScript I can't tell whether it's here to stay or just this week's iteration of CoffeeScript on the JS fashion treadmill. That may be less of a consideration for more ephemeral types of applications like websites and games, but it becomes a huge consideration for applications that require large spans of time to ammortize the cost of building them like individual software in the corporate space or applications that are somehow highly specialized. (This is the area that I'm in).
- otikik 4y agoTeal is like typescript for Lua: https://github.com/teal-language/tl https://github.com/teal-language/tl
- pull_my_finger 4y agoI want to like Teal, but the lack of nil checks[1] is a pretty big sacrifice in the name of "staying true to Lua idioms". >>> Every type in Teal accepts nil as a valid value, even if, like in Lua, attempting to use it with some operations would cause a runtime error, so be aware! I know you can use (or implement your own in about 8 lines) strict.lua[2], but that just seems like such a shame to omit nil checks from a gradual type system. I still follow the project, but I put a little more hope in Pallene's[3] development, although the aims are slightly different. [1]: https://github.com/teal-language/tl/blob/master/docs/tutorial.md#local-variables https://github.com/teal-language/tl/blob/master/docs/tutoria... [2]: https://www.lua.org/extras/5.1/strict.lua https://www.lua.org/extras/5.1/strict.lua [3]: https://github.com/pallene-lang/pallene https://github.com/pallene-lang/pallene
- wswope 4y agoI think your reasoning makes total sense and agree with the criticisms of the JS ecosystem. Just to throw out an alternative embedded-JS option for you or anyone else looking to do something similar though, there’s QuickJS from Fabrice Bellard (author of ffmpeg and more) which seems to have a very Lua-like vibe to it in terms of intended use. Only used it for throwaway/toy code myself, but it’s been a generally pleasant and frictionless experience. https://bellard.org/quickjs/ https://bellard.org/quickjs/