3 ms·
I think that Lua is what Javascript may have grown into if it had 15 years mature, rather then getting its design prematurely frozen. They seem to have very sim
by silentbicycle 17y ago
I think that Lua is what Javascript may have grown into if it had 15 years mature, rather then getting its design prematurely frozen. They seem to have very similar design goals, though where Javascript has the web, Lua has C.
Lua is really powerful, but it's been carefully designed so that a subset of the language can be used for configuration files, data dumps (much like JSON), etc., without having to know anything about programming. The deep elements are there, you just have to look for them. Coroutines, prototypes, metatables, tail-calls, first-class functions, eval, real lambdas, etc. And, did I mention that it mixes well with C?
- iamwil 17y agoYeah, I recently saw that it had coroutines, which was a surprise to me. coroutines can be used to implement fibers and is also related to continuations. I think it's deceptively simple, so programmers might not think there's much there. In addition, it's pretty minimalistic, you don't get OO out of the box (which isn't necessarily a bad thing, depending on what you're doing), and the number of libraries pales in comparison, all of which deter others for exploring it more fully. That only means that the field is ripe for some exploration.
- silentbicycle 17y agoIt can seem like a weak language since it doesn't have "batteries included", but the whole design revolves around using it as a drop-in library in an existing C / C++ project (which would already have libraries) or extending the language with C. It has a great C API, and it's not hard to write wrappers for C libraries as necessary. While Lua standalone is a decent language (almost a Python/Scheme hybrid), Lua + C is quite powerful. It's particularly well-suited to the two-level programming style John Ousterhout describes here (http://www.vanderburg.org/OldPages/Tcl/war/0009.html http://www.vanderburg.org/OldPages/Tcl/war/0009.html). I haven't used TCL much, but it sounds like the same development style - since you can just use another language when necessary, Lua doesn't have to do everything. It can stay small and simple. While low-level code and hotspots for a project may be written in C, the rest can be written in shell scripts, TCL, Lua, etc. for rapid prototyping. The clear boundary between the layers of development can help keep complexity contained, too.