4 ms·
One thing that I like about Lua over Javascript is how self-documenting, fun to write, and easy to read it is. It has a very simple syntax, but the extensibilit
by leggomylibro 8y ago
One thing that I like about Lua over Javascript is how self-documenting, fun to write, and easy to read it is. It has a very simple syntax, but the extensibility of its core structures (like tables) let you accomplish a lot with that simplicity.
Its 3rd-party libraries also tend to be closer to C/C++'s "drop-in" solutions like STB[1] than the enormous JS ecosystem which often requires extra tools like Node and/or extra packages like JQuery.
Admittedly, Lua's ecosystem is much smaller than Javascript's, but in my experience Lua is vastly easier to maintain. You can certainly write bad Lua, but it's one of the only languages where I don't implicitly dread reading other people's code.
It is sort of annoying that tables which are treated like arrays are 1-indexed by convention, though.
[1]: https://github.com/nothings/stb https://github.com/nothings/stb
- chrisco255 8y agoDoes C/C++'s STB or Lua's 3rd party libs cover cross-browser quirks and http methods like JQuery does? It sounds like Lua/C and JavaScript are used for totally different things. And Node isn't an "extra tool" it's a server. No doubt JS projects sometimes come loaded with excessive dependencies but Node/JQuery are bad examples and not equivalent by any stretch to STB.
- nikki93 8y agoLua doesn’t really run in browsers (except with emscripten or WASM? and also fengari (Lua interpreter written in JS with interop and GC sharing)) but for http luasocket / cqueues / openresty libs are good, and for servering also openresty seems good. The equivalent for stb libs would be crossplatformness and in my experience they’ve worked for their advertised purpose on mac, windows, linux, android, ios.
- leggomylibro 8y agoNope; Lua is not a good choice for a website's frontend. But people use Javascript for a lot more than just websites, and I've lost count of how many times I've been frustrated that a JS library is distributed exclusively through package managers like NPM even when the library is not specific to a browser.
- paulddraper 8y agoNPM isn't specific to a browser.
- shawnz 8y agoIs NPM even usable from the browser in any capacity? I would argue that it's specific to everything except browsers!
- s_ngularity 8y agoNPM is definitely usable as a package manager for frontend Javascript applications, just needs a little more complicated webpack or similar setup than a node.js app.