zlacker

[parent] [thread] 6 comments
1. oerste+(OP)[view] [source] 2024-10-14 10:48:48
I agree. I'm sure that CPS has much more robust theoretical roots and that it's more general and powerful, but in practice it doesn't often look much different from classic callback-hell.

Generally, I prefer the coroutine/generator style, it is more explicit and straightforward syntax-wise. More importantly, it decouples operation execution from chaining. A function that emits multiple values in sync/async shouldn't be responsible for running the next function in the pipeline directly. It's better when the user of the interface has direct control over what function is run over which values and when, particularly for parallelizing pipelines.

I do understand that Rama builds such a syntax on top of CPS, and a compiler that implements generators has a similar execution model (perhaps an explicit state-machine rather than leveraging the function stack to do the same thing implicitly).

replies(2): >>pyrale+dd >>gpdere+QH2
2. pyrale+dd[view] [source] 2024-10-14 12:55:54
>>oerste+(OP)
That's because CPS is the callback hell.

Promises are a mechanism that was devised to separate the composition mechanism and the function itself, much like shell pipes exist to separate the control flow from the called function.

In this article, they implement a pipe-like mechanism, that avoids having to do "traditional" CPS. That is why they say the continuation is implicit. That being said, that mechanism goes further than that, and looks very much like Haskell's do-notation which enables programmers to use functional languages in an imperative style without knowing too much of the underlying implementation.

replies(1): >>nathan+os
◧◩
3. nathan+os[view] [source] [discussion] 2024-10-14 14:44:46
>>pyrale+dd
The Cont monad in Haskell is only for single continuation targets and can't do branching/unification like Rama. That kind of behavior doesn't seem like it would express naturally or efficiently with just "do".
replies(2): >>pyrale+7W >>tome+Hb1
◧◩◪
4. pyrale+7W[view] [source] [discussion] 2024-10-14 17:43:12
>>nathan+os
Yes, Rama probably isn’t semantically comparable to one single monad.

I was talking about the do notation as a way to sugar the syntax of cps monadic operations into a flat, imperative syntax. This is exactly what Rama is doing.

If you look at a tutorial of what haskell do-notations desugar into, you’ll find the same cps stuff described in this article.

◧◩◪
5. tome+Hb1[view] [source] [discussion] 2024-10-14 19:12:10
>>nathan+os
Could you say more about what branching/unification is in this context, and how Rama supports/uses it?
replies(1): >>nathan+qc1
◧◩◪◨
6. nathan+qc1[view] [source] [discussion] 2024-10-14 19:17:15
>>tome+Hb1
Those are explained in the post starting here: https://blog.redplanetlabs.com/2024/10/10/rama-on-clojures-t...
7. gpdere+QH2[view] [source] 2024-10-15 09:25:41
>>oerste+(OP)
As far as I know, CPS is supposed to be an intermediate form for compilers and a theoretical framework to understand control flow and concurrency constructs. The second part is I think a very good reason why most programmers should learn about CPS; but I don't think CPS was ever meant to be something you were supposed to routinely program into, in the same way you don't routinely program in assembler.
[go to top]