LuaGravity / Functional Reactive paradigm - will it work with Corona SDK?

I’m new to Lua and am excited to get started with Corona SDK. I just signed up today and am looking to both learn from the samples and (hopefully) to rapidly experiment with an idea I have for a game!

There’s a Lua language question in this post, honest, but I need to provide a little context…

Day to day, I mostly program in JavaScript and in December 2010 I “discovered” and became fascinated by a seemingly little-known JS library called Flapjax:

http://www.flapjax-lang.org/
https://github.com/brownplt/flapjax

It provides an event driven programming model by way of a paradigm called “Functional Reactive” – the key concepts being “event streams”, “behaviors” , and (functional) “transformers” (as opposed to working directly with callbacks/listeners). This was/is a big deal for me, as it provides a powerful formalism for modeling and managing complex flows of data/events between sinks and sources spread across the Internet. In fact, I’m busy re-implementing Flapjax into a library I’ve named “Jolt” which generalizes certain aspects of the original (n-ary vs. 1-ary “pulses”, time synced event streams, and more):

https://github.com/michaelsbradleyjr/Jolt
(nothing of note in the README yet, no examples … but I’m getting there, still hammering out my port and the new features, a real brain-stretching experience!)

Since diving into this new (for me) world of Functional Reactive programming, I’ve learned about a few other implementations of the same paradigm. There’s one for OCaml:

https://github.com/jaked/froc

There’s one for Scala too; there’s even a dedicated FR language called “Timber”. And low and behold, there’s an FR implementation for Lua, called “LuaGravity”:

http://www.lua.inf.puc-rio.br/luagravity/
https://github.com/fsantanna/luagravity

Now, obviously, I’m growing partial to this style of programming. My question is whether or not attempting to use LuaGravity in the context of Corona is going to be a non-starter? I’ll admit that I’ve haven’t tried it yet, but this really is day-1 of Lua for me and I thought it might be good to just ask those who are familiar with Lua/Corona, so as to avoid running into a brick wall in the first place. Besides a potential lack of support for using this Lua runtime extension in Corona, perhaps someone here may know whether trying to use this programming style would be a poor fit in connection with Corona’s game engine? Maybe someone here is already using LuaGravity and Corona together?

Thanks for your feedback. Wish me luck as I begin to explore Lua and Corona!
[import]uid: 46512 topic_id: 8025 reply_id: 308025[/import]

Correct me if I’m wrong, it seems “Functional Reactive Paradigm” is simply event-driven object oriented programming. In that, I do not see any limitation for its use with Lua + Corona.

Having said that, LuaGravity will not work out of the box as I can see at least one place where loadfile is used. You’ll have to make several changes to make it work. For functions removed see http://developer.anscamobile.com/content/changes-lua

Disclaimer: My experience with Lua is limited; I come from a .NET world. [import]uid: 40932 topic_id: 8025 reply_id: 28684[/import]

Functional Reactive can certainly be mixed with OO programming, that’s how I’m planning on using it. But of itself, it lends to a functional approach to software development and helps one to move toward “side-effects free” programming.

There is an excellent student-paper authored by the Flapjax team (circa 2009) which can help you get the bigger picture:

http://www.cs.brown.edu/~sk/Publications/Papers/Published/mgbcgbk-flapjax/paper.pdf

If you’re interested in learning what the FR style has to offer, I highly recommend you give it a patient read-through. LuaGravity is implemented a bit differently, though both have a common ancestor in FrTime, and the underlying concepts are the same.

I don’t want to suggest this as a definitive interpretation of FR’s place in web/mobile development, but this is kind of how I see it at present: For modeling the flow of data/events through your application, the FR formalisms provide a substantial step-up from “raw callback” composition or even a continuation passing sugar. For encapsulation of reusable components/logic within your application, use OO techniques (inheritance, interfaces, etc.).

In the land of JavaScript, I’m thoroughly hooked on Joose for OO:
http://joose.it/
http://joose.github.com/Joose/doc/html/Joose.html

Joose gives JS a lot more OO powers than the raw prototype chain. After using Joose for a year+ I can’t imagine doing JS development without it. It’s *not* an interpreted lang that compiles to JS (like CoffeeScript); rather, it’s an über clever layer of JS that gives you an advanced OO API within JavaScript. It’s tested and works well in all modern browsers, and it works unmodified in node.js too.

In fact, my Flapjax re-implementation (Jolt) is built atop Joose.

There’s a port of Joose (or really it’s Perl cousin “Moose”) for Lua:
http://code.google.com/p/loose/

However, it’s not feature complete and Joose has come a long way since 2008 (which is the last time Loose was updated). I’d love to see a full port of the Joose ver3 API to Lua, if only because I’m so comfortable with Joose now that it (probably) would help me get going with Lua faster. If I actually get hooked on Lua/Corona, it’s something I may work on myself. I’ve been more a “consumer” of Joose since early 2010, but I’ve had it as a personal goal for some time to get hot and heavy with its internals. We’ll see… [import]uid: 46512 topic_id: 8025 reply_id: 28692[/import]

…LuaGravity will not work out of the box as I can see at least one place where loadfile is used…

Yes, I see that in a definition of a “dofile” function in the LuaGravity repo’s “meta.lua” file. However, I don’t see anywhere else in that or the other .lua files where it’s called (I could be misunderstanding, though), so maybe it’s just a convenience method that’s not critical to the functionality of the library.

I appreciate you’re pointing it out.

I suppose experimentation is in order here, just trying to find the time. :slight_smile: [import]uid: 46512 topic_id: 8025 reply_id: 28694[/import]

Well, welcome to Lua! I don’t get a chance to do a lot of heads down coding but looking forward to collaborating with you in the future… you sound like you know your stuff :slight_smile: [import]uid: 40932 topic_id: 8025 reply_id: 28698[/import]