Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In the realm of embedded languages (which is dominated by Lua), Gravity seems like a great improvement.

A lot of game developers attach a small scripting language to their game engines because C++ isn't a good language for rapid game logic prototyping, and takes ages to compile. The majority of them use Lua for this purpose. Lua is certainly simple and elegant, but has its shortcomings (no direct support for classes, 1-based indexing, indexing a wrong field returns nil, can accidentally declare global variables on assignment, lack of syntactic sugar...) I've looked at other languages such as Angelscript, Squirrel, Wren, etc..., to use for game development, but I think Gravity is the cleanest and has the most features so far. I'm still curious about the performance though (If it runs about the same as non-JIT Lua I'll call it a success, given how Lua is much simpler than Gravity)

Even if you aren't a game developer, scripting languages also has its use with UI development. The majority of UI developers use Javascript with a combination of web technologies, so that's one example. Even QT developers use a scripting language called Qt Quick (which also resembles Javascript a bit), because C++ can be too tedious for rapid prototyping. The author of Gravity have also developed this language for mobile UI Development, so it seems good for its intended usage.

The language isn't particularily shining on new concepts, but I think it will be very useful for some of us.



The semantics and capabilities of Gravity mirror those of Lua almost exactly. Class systems, there are literally hundreds to choose from, basic Object/Method support is built into the language. As for globals detection, http://lua-users.org/wiki/DetectingUndefinedVariables and non-existent attribute lookup https://www.lua.org/pil/13.4.4.html

Anyone programing in Lua should be well versed in http://www.luafaq.org/gotchas.html

Gravity's class system is inflexible compared to Lua where it has Multiple Inheritance https://github.com/limadm/lua-oo Prototypical OO https://github.com/nusov/lua-object or anything else you desire.

As for extending syntax and semantics, http://lua-users.org/wiki/MetatableEvents provide a clean mechanism to do so.

Lua coroutines are more powerful than Gravity's fibers.

I was hoping that Gravity had pattern matching support, but it looks like it does not.

Given that Lua has more capabilities than Gravity could you substantiate

> Lua is much simpler than Gravity

In what ways?


You can create elaborate class systems using metatables in Lua; the problem is that there are hundreds of them. I've done some Lua programming using Love2D, and one of the painful parts was that a lot of the major libraries implemented different class systems (or rolled one of their own), making it hard to include in a single codebase. (At least Lisp has CLOS as its common class system...) Also you can mitigate the "undeclared variable = nil" problem using a script like strict.lua (https://github.com/deepmind/strict/blob/master/strict.lua), but when you try to expand that for field accesses you then want to make sure all of those libraries with different class systems or methodologies are also compatible with it (which a lot of the libraries do not).

The underlying problem with Lua is that it went too wild with the philosophy of "being the most expressive using the least amount of features" (so you can implement everything using only metatables). Although many would say that this is a good thing, for me it seems better for a language to have some kind of subset for which people can conform and rely on.


Lua provides only a meta-object protocol, without blessing a single class system.

I prefer this. Its more Scheme-like, philosophically. I've seen your criticism from many quarters and here's my guess at what happens: people come to Lua from other languages, find missing abstractions, recreate them, and in the process don't thoroughly learn the metamethod system.

Pure prototyping is a joy once you realize what all the moving parts are and how many ways they can be usefully combined. This is my experience anyway.


> the problem is that there are hundreds of them

It is a problem when writing general-purpose code in Lua. But why would it be a problem when deciding to embed it, and comparing it to Gravity in this context? With Lua, you'd pick one such system, and stick to it. With Gravity, the system is picked for you - if you don't like it, too bad.


This has been my experience.


>You can create elaborate class systems using metatables in Lua; the problem is that there are hundreds of them.

I have done quite a few Lua projects, and I can tell you've not quite gotten it right.

The Class system you use is the one you take with you on the project. This is a strength, not a weakness; your patterns are a base file in the project.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: