olahol / node-csp

Communicating sequential processes for node.
MIT License
55 stars 8 forks source link

Request for feedback #1

Open tomaskulich opened 7 years ago

tomaskulich commented 7 years ago

Frustrated with how error handling and forced termination works with standard means for writing asynchronous code (Promises, js-csp, I'm not sure what approach does node-csp take), I created my own solution for writing asynchronous code.

https://github.com/vacuumlabs/yacol/

It's strongly CSP-influenced, the main difference however is, that I separated concepts of goroutine result and channels. In other words, goroutine return one simple value and may get to error state. Return value can be read multiple times by whoever wants to. Channels, OTOH cannot get to the error state, cannot be closed and taken value is taken out of the channel (standard CSP behavior).

If you have a few spare minutes, I'll be thankful for any feedback.

Aclassifier commented 7 years ago

I am not certain if there is a standard CSP semantics on erroneous channels, if that's what you meant. Occam is perhaps closest to CSP, where there was no error handling. JCSP channels have several flavours of fault handling. Go channels do error return. I guess it's more about layering of protocols than CSP. But then one would perhaps need at least the Go concept.

An interesting point may be that C.A.R. Hoare strongly argued against Ada's exception handling (with throw and catch) after he had designed CSP, in his Turing Award lecture in 1980 [1], perhaps one of the more readable essays of computer science. 1980 is a long time ago, but history tends to repeat itself.

Another interesting point that springs to my mind is that Texas Instruments Microprocessor Pascal (MPP Pascal, rather concurrent) with built-in scheduler for TMS-9995 and TMS-99105 in the very late seventies had exception handling with hierarchical (with respect to processes), pluggable exception handlers. I think this was designed by Per Brinch Hansen.

IEEE 1355 and SpaceWire come from the transputer (& occam) world where it was seen necessary to add exception handling on channels. This might be an interesting study.

I am trying, to the best of my ability, to draw up a taxonomy of CSP-based systems [2]. I may rename it to classification only since I find it hard to do hierarchical classification. Exception handling and channels would certainly be a point. Comments welcomed there! Good luck with node-csp and yacol!

[1] https://www.infosec.aueb.gr/Besides%20Security/TALKS/TALKS-6%20Hoare%20(The%20Emperor's%20old%20clothes).pdf

[2] http://www.teigfam.net/oyvind/home/technology/135-towards-a-taxonomy-of-csp-based-systems/ (Disclaimer: no money or gifts, no ads, just hobby)

tomaskulich commented 7 years ago

Thank you for your feedback. Especially, the taxonomy looks really impressive.