Ask HN: Do you recognize this approach to programming?
The convential approach for commercial flight simulators is to use a large shared memory to hold the state of the simulation, and a game loop. Hardware interface signals are fed into that shared memory, and every iteration of the game loop executes software that reads and updates the shared memory.
The novel approach uses no shared memory. When a hardware input signal changes, it raises an "event" consisting of a name and value. The software then raises any other events that depend on this one. They have created a programming language to get the most from this. In that language, say you have:
a = b + c
d = e + f
These two lines will NOT get executed in sequence. They declare relationships between events. When event "b" occurs, the event "a" will be raised and its value depends on b and also the last value of the c event.
It turns out this is really powerful and works well on a distributed system. Did they create something new here?
36 comments
[ 3.2 ms ] story [ 1531 ms ] thread- Ken
http://www.amazon.com/Constraint-Processing-Kaufmann-Artific...
... and this one, which is a survey of the literature:
http://www.amazon.com/Constraint-Programming-Foundations-Art...
None of the other books I looked at was even close to as useful as these. Maybe this will save somebody some trouble.
The value of such an approach lives and dies on how well-defined the problem space is. If the domain covered by those events is relatively walled-off and has a very clear protocol for interacting with the rest of the system, that's good. But if it turns out to require lots of special cases, you end up wanting (and probably hacking your way to get at) a general-purpose language and can end up with something more complicated.
Event propagation in response to unpredictable signals from hardware is pretty much what GUI logic consists of. GUI event handling written the obvious way quickly generates into spaghetti under complexity. I've often wondered about a better way, since much of that complexity doesn't feel intrinsic.
I don't know much about games but it seems like a lot of them might be in the sweet spot for this approach, with a lot of complexity that can be expressed using such rules and encapsulated in a way that works nicely with the rest of the program. The devil is in the details, though.
In the event-based approach they implemented, different nodes (PCs) subscribe just to the events they are interested in. It's light-weight, easy to understand, monitor and debug, and it fits the problem well in this case.
If you're using VHDL for design automation, and you're going to synthesize it to hardware, then the synthesis program does logic mapping to whatever technology (standard cells, FPGA blocks, etc.) is being used, figures out the logic and interconnect delays, and tries to satisfy the requirement that everything be ready when the clock ticks, while allowing a reasonable clock frequency.
The way that VHDL handles both uses can be a little confusing.
http://java.sun.com/javafx/1/tutorials/core/dataBinding/
You can still think of it as the same old shared memory approach, where before the game loop frame gets to "look" at it, some conditional event propagation and generation is performed. In other words if b and c are hardware events. Their values get written to the shared memory. Before the game loop gets to look at the memory, there is a stage where a (an event derived from b and c) is generated. Of course, now you don't have the limitation of a physical piece of shared memory. These events can be distributed across many machines.
> It turns out this is really powerful and works well on a distributed system. Did they create something new here?
I think the power comes from creating a DSL that fits very well in your domain (problem space). It lets you manage a lot events and express relationships between them. Also you seem to have defined an event algebra, where events can be composed. I am not sure how applicable this is to other domains. If your language is abstract and not related to particulars of flight simulators, it might be quite useful...
What is the language called? How proprietary is it?
From what I've seen, they've included GPL notices in most of their code (something unheard of in this industry). I'm guessing the whole thing is GPL'd, but not published to the Internet.
This is actually a fantastic model for distributed systems and was implemented in the Erlang programming language for that very purpose. It is the other major model of concurrent computing outside of having some kind of shared memory space (in a true actor model there is no shared mutable data).
The application I'm working on at the moment for my future startup makes heavy use of a similar approach to pipeline computations between components. So far it works very well.