Flapjax - Functional Reactive Ajax

Flapjax s a functional reactive compiler and Javascript library for creating interactive web GUIs, created by Brown PLT. You can try the compiler online, or read the docs to get more of an idea of how the language works. If you've used OO style MVC before, but not functional reactive programming (FRP), take a look at Flapjax for a different, and in my opinion, cleaner approach to the same problem.

If you're familiar with FrTime you'll recognise the elements of Flapjax -- Flapjax is essentially a Javascript implementation of FrTime, and a compiler from the Flapjax language to Javascript to make writing code less verbose. The key differences compared to the Haskell FRP tradition are that FrTime is asynchronous and uses mutable state. This means behaviours (time varying values) can be sampled at any time, whereas in Haskell FRP behaviours are all sampled at the same time, and it isn't necessary to use the arrow combinators to hide accumulators. Of course it isn't all roses: the implementation is more complex, and doesn't work well in, say, a continuation based web server as mutable state will mess up resumptions of previous continuations. (Don't get the idea that this is a problem for Flapjax -- it runs on the client, not the server.)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Where's the download?

As far as I can tell there is no Flapjax download, which rather limits it's use. Snooping on the HTML shows rather a melange of implementation languages: Java, Python, and Scheme, so I don't think it will be easy to package up Flapjax.

Althought they don't talk about it much, there is an event wrapper for talking to servers, getWebServiceObject_e. If you just read the tutorial you might get the impression that Flapjax didn't support this, which would be unfortunate as the ability to load data via Javascript (typically using the XMLHTTPRequest object) is really what kicked off AJAX/Web 2.0.

getWebServiceObject_e (and friends)

The AJAX stuff is well-represented in the Yaggle demo. Using a Flash proxy, the Javascript security model is bypassed, so a client can make requests away from its own server -- making Yaggle a truly client-side mashup. We've also done some fun stuff in terms of making XML-based RPC systems more accessible -- the Flapjax programmer sees only objects and never has to parse a thing.

There's another way to get data from foreign sources, and it doesn't require Flash: evalForeignScriptVal_e. Delicious, for example, offers a Javascript file which, when imported into a running page, will put the relevant bookmark data into a pre-arranged global variable. This is of course a little unsafe, but if you trust them (and us!), you can check out the Delicious demo.

Lastly, we have our own persistent store. No mashups here, but this is what most of AJAX is being used for now. You can see it at work in the draft saver demo. It's also worked through in the tutorial, I believe.

From the blog:

Cut and pasted...

Friday, October 13, 2006

Some of you have asked for a downloadable compiler.

We didn't expect the demand for it so soon, but we're working on a solution to this problem. Please expect something within the next few days. We'll announce it here on the blog.

posted by Shriram Krishnamurthi at 6:18 PM

A command-line compiler is now available!

The command-line compiler is written in Python; it proxies compilation requests to our compilation web service, so it may not exactly fit your needs. Nevertheless, Flapjax can now be part of a multi-person development cycle.

A Kind of Download

Packaging the compiler is, as Noel has noticed, a bit of a chore. But if by “compiler” you (like Noel) want something you can invoke from a command-line and incorporate into your build process, it's now available. More information in our blog post.

If the compiler's a high priority, please tell us!

Some strange math in the

Some strange math in the tutorial:
Returning to the example, the expression timer_b(100) creates a timer
behavior that returns a value every 100 milliseconds, i.e., every second.

Yeah, that made me wince.

Yeah, that made me wince.

fixed

Thanks for catching that! I hope it didn't prove to be a show-stopper for you guys.

Regards,

- Leo

It's the Numeral System Wot's the Problem

Sorry, yeah, my bad. Problem is, all this decimal stuff freaks me out. But we decided it'd be a bad idea to write the tutorial in Church numerals.

valuable docs

This is great. I probably won't use the framework, but hopefully this will help me understand FRP :)

ssems popular

I note that several popular blogs have picked up on Flapjax, perhaps because it's in tune with the current mania for AJAX-style web-development? Especially among the youthful web developer set aspiring to financial independence after hitting on the next big web-thing!

Popular is Not Not Interesting

I don't think anyone in the past thirty years has gone wrong putting the letter `x' in the name of something they want regarded as technologically advanced. Guilty as charged.

But you might also consider that Flapjax is at a cutting-edge of programming language technology. It's ambitious, it's flawed, it's ambitiously flawed. And even if the only (“only”) thing Flapjax achieves is to make a collection of the technologies discussed endlessly on LtU available to the masses, I'd consider that a win. Go through the tutorial to see what's on offer; once you have, flame away and I'm all ears!