The Synchronous Blog

A blog about reactive programming languages.

A first glance at LuaGravity

with 8 comments

As a pragmatic programmer, I’ll try to mix the academic bla,bla,bla with practice, so…

LuaGravity is the name of my toy language that implements the synchronous approach for concurrency (I’ll dig into it sometime).
(Actually, it’s a *serious* toy language as a I’m very concerned to it and keep adding features and tweaking it all the time.)

When running it without a filename, you’ll see a prompt just like in the Lua Language [1].
As you type the statements and expressions you’ll attest that it’s just normal Lua…

Except, it’s reactive!

The video above shows that the variables a and b reacts to the current time, a – b to a and to b, and so on.

The INT function integrates its argument over dt (remember it from Calculus?).
It’s used here only to create a time reference for the application.
The L function states to its arguments that they should behave reactively (the name comes from “function Lifting”).

The result of the expression a – b shows the perfect synchronism between its arguments: no need for locks, no milliseconds difference, no text blinking, just zero as it is expected.

LuaGravity is roughly based on Esterel [2] and FrTime [3], two synchronous languages, the former having an imperative style, the latter being functional.
The example above shows only some functional features.

Here are some LuaGravity Implementation Facts:

  • It’s implemented over the Lua language runtime (there’s no need to parse source code).
  • The engine running the system is “just” an event handler.
  • The elapsed time during an event handling determines the dt value used by INT and varies over the time.
  • The prompt you see is a collection of graphical objects (no, it’s not a magical raw terminal).
  • It’s single threaded, of course.
  • The engine’s whole source has about 300 lines of Lua code.

In the next examples we’ll escape from the dry command line and see a lot of graphics, where LuaGravity really rocks.



Written by francisco

August 17, 2008 at 9:05 pm

Posted in Concepts, Examples

Tagged with , ,

8 Responses

Subscribe to comments with RSS.

  1. Two things:
    1)Can I write the f word here? This is f awesome, I can’t wait to see the graphics thingies! And I may stop by your office tomorrow and hit you for not talking about this before!
    2)You’re getting seriously nerdy here. I mean, a Chuck Norris joke? :P


    August 19, 2008 at 2:37 am

  2. Three things:
    1) congratulations for your initiative.

    2) I’d like to see how it works with programs involving intensive calculations. As you might know performance is a critical issue in my research (statistical learning).

    1) you are getting seriously nerd here… Chuck Norris..


    August 19, 2008 at 4:13 am

  3. About intensive calculation programs, I don’t see it as an obvious area.
    The reactivity should not slow down things, though.
    You create the relations because you need it and you’d have to implement it by hand w/o reactivity.

    Simulation, GUI, AI, CG, Games and Multimedia are more obvious areas.

    The nerdy joke is to attract my target audience. ;)


    August 19, 2008 at 4:35 am

  4. It’s a pity you can’t override == for different types in Lua, or you wouldn’t even have to lift EVEN. BTW, as you are abbreviating lift with L, have you thought about abbreviating integrate with S (the obvious mnemonic is the math symbol)? Then you could have gravity.integrate and gravity.lift as the “official” names and S and L as the aliases.

    Fabio Mascarenhas

    August 19, 2008 at 4:52 pm

  5. As you know, the same holds for ">", "not", "and", etc.
    The aliases for these liftings are: GT, NOT, AND, etc.
    So, I could have written EQ(a%2, 0) instead of EVEN…

    I'll use S for integration and D for derivative (currently DER).



    August 19, 2008 at 5:36 pm

  6. wow, congrats. let us see the example with graphics ;)


    August 20, 2008 at 5:55 am

  7. […] it’s all made implicitly. Much less verbosity. The reactive variables of LuaGravity (shown here and here) override Lua’s default behavior for […]

  8. […] graphical examples The following are two graphical applications written in LuaGravity with respective videos and source codes. The first example shows some flying rectangles whose size […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: