HN Theater @HNTheaterMonth

The best talks and videos of Hacker News.

Hacker News Comments on
Event-Driven Programming in Clojure

Zach Tellman · InfoQ · 85 HN points · 0 HN comments
HN Theater has aggregated all Hacker News stories and comments that mention Zach Tellman's video "Event-Driven Programming in Clojure".
Watch on InfoQ [↗]
InfoQ Summary
Zach Tellman explains how to deal with asynchronous programming difficulties in Clojure using an event-driven data structure.
HN Theater Rankings

Hacker News Stories and Comments

All the comments and stories posted to Hacker News that reference this video.
Apr 10, 2012 · 68 points, 11 comments · submitted by Mitt
prospero
Hey, I'm the guy in the video. If anyone has questions, I'd be happy to answer them.

Any questions regarding odd numbers will have to wait for my upcoming presentation.

muyuu
Can you put the slides somewhere else? the link in infoQ is not working for me.
prospero
http://github.com/strangeloop/2011-slides/raw/master/Tellman...
andrewcooke
i just had time to watch this; it's very nice work.

i guess this is either obvious or wrong, but your async macro reminded me of logic variables (eg in oz) (ie you appear to be rewriting the system so that, effectively, the variables in your dataflow are logic variables, and then adding concurrency to match). that suggests that the debugging issues you have are similar to ones that they have to deal with. i don't know what solutions they have, but if this makes sense, and you haven't talked to van roy et al, it might be worth doing so.

(and i guess other parallel logic program(mer)s too - oz is just what i am most familiar with. mercury?).

prospero
From now on, I'm going to start all my questions with "this is either obvious or wrong, but ...".

I hadn't made the connection between dataflow and logic programming. I'm not sure if the programming practices surrounding logic programming would be useful in this context, but I'll certainly look into it. Thanks for the suggestion.

andrewcooke
"logic programming" is a bit misleading. oz (at least) doesn't have built-in DFS like prolog. but it does keep the idea of logic variables, which it uses to make concurrent programming "easy" (in the sense that what you are doing is deadlock free), so it is more similar than you may think...
prospero
Okay, I've only ever skimmed CTM before, I'll give it a closer look.
drivebyacct2
The odds don't get to drive?
__abc
Have you ever seen an odd drive? Horrible! HORRIBLE!
grayrest
Do you have an overview of how the async macro works? The presentation wasn't long enough to fit in but I'm hoping you have a written explanation somewhere. Cursory search didn't turn up anything.

I've seen flows of roughly the same complexity from a variety of abstractions: monadic (F# async), generator/coroutine (Python gevent, node fibers), futures/promises (twisted, mochikit, commonjs q), and callbacks (a million node async flow helpers) but they always involve more code. This looks like auto-transformed futures with error bubbling instead of error callback but I'd like to know how it's actually working. The lack of ceremony/annotation is commendable but I'm concerned it's fragile magic.

prospero
I haven't really written about this anywhere, and the code in its current state is far from self-documenting, so I'll give it a shot here.

The code transformation is pretty much all local. Since everything in Clojure is an expression (this is not true of Python or JS, I'm not sure about F#), I don't need to perform much analysis, I just need to make sure that each expression doesn't care about the difference between a future and a realized value.

Let's assume three primitives:

* an asynchronous future [1]

* something which merges a list of futures and realized values into a single future representing a list of values

* something which takes a function and a future, and returns a future representing '(apply fn value-of-future)', that will be realized once the future is realized

All we need to do is take every expression where a function is called, merge the arguments together, and apply the final primitive to the expression. The expression will return a future, which can then be picked up by the parent expression, and so on.

This glosses over how special forms are handled, and how the 'force' functionality works. Also, as I mentioned in the presentation, how the code executes is pretty opaque, and some sort of higher-order analysis would be nice so that it could be visualized using graphviz or something.

This is still an experimental feature, and will probably remain so until the 1.0.0 release of Lamina (I'm working on 0.5.0 right now). I'm not aware of any other macro that rips apart normal Clojure code quite as completely, which means that this is sort of uncharted territory. I want to make sure I've avoided all the pitfalls before calling it ready for production usage.

[1] https://github.com/ztellman/lamina/wiki/Introduction

Feb 22, 2012 · 12 points, 1 comments · submitted by calebmpeterson
calebmpeterson
I found this a thought provoking talk at Strange Loop by the author of Lamina (async in Clojure) and Aleph (async networking in Clojure, built on Lamina).
Jan 26, 2012 · 5 points, 0 comments · submitted by puredanger
HN Theater is an independent project and is not operated by Y Combinator or any of the video hosting platforms linked to on this site.
~ yaj@
;laksdfhjdhksalkfj more things
yahnd.com ~ Privacy Policy ~
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.