4 ms·
Callback wars! - New abstractions to clean up your code
On the subject of callbacks and the mess that ensues, here is a paper I wrote for my Ph.D. which proposes extensions to the event based programming model which can be used to clean up lots of callback code. The basic idea is to break down a program into computational blocks called Multi-Event Handlers (named that because multiple events can cause them to fire). Code isn't nested, instead we write a number of these handlers to represent our program and allow it to execute. We can then chain the event handlers together by the input and output events that they accept and emit.<p>http://www.dsg.cs.tcd.ie/~reillyse/pub/short.pdf<p>The abstractions were created to solve problems programming sensor-driven applications but the ideas are general to all event based programming.
- throowawwwy 13y agoTips for a more successful submission: 1) If you're writing about code, link to some code. 2) Your title should be more specific and less circumstantial. I don't understand your short.pdf at all; but the biggest challenge in JS is getting any of your ideas to work within it. No one can use your technique if it requires modifications to the JS engines.
- clubhi 13y agoA few suggestions to have people take you seriously. At least hint that you are knowledgeable about some preexisting competing solutions to what you are recommending. Make some reference to the language that these callbacks should be implemented in. Eat your own dog food. Have you actually used this in a project that you can talk about? Was the squash diagram as far as you took this?
- reillyse 13y agoOk, so I should have put more effort into this submission, but it was early on a Saturday morning and I was just a bit annoyed with all the chatter about callbacks & their failings. Also people spend a lot of time bemoaning the lack of new ideas or research and I was just making the point that new ideas are being explored and research is being undertaken all of the time, but is largely ignored :) I guess I'll write a blog post about it and write it in a more "hacker news friendly" format and then submit it again. But just to answer your questions, yes I've implemented this fully in 2 different languages, C https://github.com/reillyse/C-AESOP https://github.com/reillyse/C-AESOP and Java https://github.com/reillyse/J-AESOP https://github.com/reillyse/J-AESOP and partially in Javascript https://github.com/reillyse/alacrity https://github.com/reillyse/alacrity . The focus of the research was for sensor driven applications so I didn't do the partial implementation in JS until later on. I used it in two applications as part of the evaluation section of my thesis. So, dog food well and truly eaten.