Dmitry Petrov Back

Taming the Asynchronous Beast with CSP in JavaScript

Another amazing article by James Longster, that continues his series of blog post about web development from future, where he speaks about all kinds of features, techniques and new abilities of Javascript language that completely change the way how we can deal with common problems during the development.

One of the problems is constant dealing with events, wich leads to rather complicated code that balances between different events by containing intermediate state somewhere and the more complex interaction gets the more complex code we get. Another source of asynchronous complexity is actual async part which comes from any ajaxy activity.

Js-csp is a neat way of dealing with all these two issues in a uniform way. The way it unified if that all the differences are abstracted away by channels where any value can be put in and read from. The key difference, that these operations are blocking with proper try/catch support etc. Hence you get several blocking blocks of code that actually only block themselves and communicate via channel messages.