0
votes

I assume most Clojure experts have seen Rich Hickey's ants demo ( http://gist.github.com/1093917 and http://blip.tv/clojure/clojure-concurrency-819147). If one were to try to make a distributed version of the same app, but browser-based where each browser controlled one ant, is there anything from Clojure/ClojureScript that would aid in the transactional nature of the behave function (assuming behave was run on the client)? Or are Clojure/ClojureScript's STM features really not intended for distributed use?

i.e., if on the client I'm at (3,2) and want to move to (3,3), and in my client (browser)'s world (which could be slightly stale, the same way in Rich's original version that the Thread was slightly stale) that square is empty, but then I send the request to the server and in the server's world that square is full, is there any kind of distributed STM in ClojureScript that can tell me—nope that square was full and you have to revert that move so your next move will have to start from (3,2) again. In Rich's original presentation that was all automatic, built into Clojure's STM functionality. But distributed, will that have to be more explicit, or is there existing functionality built in to do this?

If that kind of thing is not built into Clojure/ClojureScript, are there other platforms that might be more suitable?

1

1 Answers

0
votes

Yes this can be easily done using Clojure (for backend) and ClojureScript OR JavaScript (for frontend).

Basically the client js code will use websockets to connect to clojure server and on server you can have a state wrapped in an atom that is access by each client and each client is updated about the state through the connected websocket... something similar you do in a chat web application.

For websocket you can use Aleph.