Projections vs rxjs vs etc

There was a pretty good question this morning when I checked comments on posts.

“What is the difference between projections and say rxjs”. We could as easily include any of the functional reactive libraries out there (bacon.js, flapjax, elm, rx, etc). We can also start going way back and looking at predecessors like CLM

Let’s start with the similarities both are JavaScript. Both are functional reactive APIs (this is why they look rather similar). They if you go way back trace their lineages to the same places. All have concepts like “streams”, “events”, and “behaviours” as these are underlying concepts. There are however some differences as well.

In particular the tools are handling CEP

The largest difference is most of those tools listed are only capable of being run from now forward (for some you could write persistent adapters, we had experimented with one for rx). They are small libraries for dealing with things like events in a javascript UI. You could build up everything around something like rxjs as well (eg we could switch out our definitions for ones matching theirs).

When we talk about projections, the streams are persistent (and distributed). We host v8 internally and use this API as our query language over persistent streams of events. A projection is not just for running from this point forward but for running against previous history as well. This is a very powerful idea (and not a new one).

Projections are the query language of the Event Store. When you write a projection you can specify that you want it to run for history and stop or you want it to run for the history and continue. The Event Store will also handle you doing this in a durable, consistent, and distributed way (over terrabytes of indexed data). A projection will survive a power outage as example if configured to do so.

I hope this helps to clear up some of the similarities and differences between the options.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: