lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Apr 21, 2017 12:43, "Andrew Starks" <andrew@starksfam.org> wrote:
On Fri, Apr 21, 2017 at 2:04 AM, Eike Decker <zet23t@googlemail.com> wrote:
> Hello Lua Users,
>
> I'm preparing for a talk at my company in which I want to focus on things
> that are exclusive about Lua (and which I keep missing in other programming
> languages).
>
> While metatables are are neat, the concept isn't foreign in other languages
> (albeit it's often not as complete nor as concise).
>
> Things that come to my mind which I have never/rarely/barely encountered in
> other languages is:
>
> 1) The debug API which enables me to inspect the stack variables and
> defining hook functions within my program. While this can somehow be done in
> other languages, I am not aware of any language where this is an intrinsic
> part of the language API itself; It's always a mere VM functionality that is
> "chiseled in stone".
> Also cool is the ability to set a hook function that gets executed only
> after a certain amount of instructions, which is great for programming
> contests where the most efficient solution is searched - at least this makes
> the comparison very fair.
>
> 2) Environment tables which allows faking/sandboxing the global registry for
> functions: This is not impossible to do in other languages, but it's usually
> not as simple and often not even possible at all within the language itself.
>
> 3) Coroutines: True coroutines are available in some other languages and
> some languages offer extensions for this, but again, this isn't easy nor
> cheap to do - and often not possible as well.
>
> This is the list I would go through and showing examples for each point and
> what it can be used for.
>
> Do you have anything else that comes to your mind?
>

One that I had not seen mentioned is a controllable and replaceable
garbage collector. This allows you to control latency over all and in
critical spots within your code.

--
Andrew Starks

That's another great point. One issue that Java used to have that gave it a bad reputation is that the garbage collector liked to kick in at inopportune times and bring everything to a screeching halt. In Lua you can easily control when the GC runs, so that it's happening during the idle time at the end of your game loop instead of during time-critical rendering. And it's very simple (one function call to change it to manual mode, one to run it) and the defaults are sane.