The State of the Fork in the Road

If you haven’t read The Road We Didn’t Go Down, you really should. Joe Armstrong reflects on Steve Vinoski’s thoughts on RPC and CORBA (and by extension, WS-*).

Steve Loughran commented that

What needs to be considered is whether blocking method invocation is the main metaphor used in Java/C# style languages, because that is the only metaphor the language allows. You have objects, you have methods, so everything has to make your communication look like method calls on objects, passing other objects as parameters.

I know that .NET offers another metaphor that gets you part of the way; you can use delegates to build an event-driven mechanism. Still, it takes some major engineering to get away from the RPC model to be able to do CPS-style calls like Joe’s last couple of examples. My employer’s put that time in, so we can write things like this (assuming OnContinue, OnException, and OnTimeout are defined as methods):

pre(code).public delegate void SomeTaskDelegate(Continuation);
public void SomeTask(Continuation) { … }

Continuation.Invoke( new SomeTaskDelegate(SomeTask), new WaitCompleteDelegate(OnContinue), new Continuation.ExceptionDelegate(OnException), new Continuation.TimeoutDelegate(OnTimeout), TimeSpan.FromSeconds(1500), null); // parameters to SomeTask would go here

What I dislike about this is that it feels like you’re back in C – you have to declare everything twice; as a delegate (.h) and the implementation (.c) – the invocation is quite noisy because you’re trying to do something that’s not natural to the language. And as I mentioned, there was a considerable engineering effort to build the CPS framework. The lambda expressions and anonymous delegates C# 3.0 should make that somewhat more palatable. Rick Brewster’s example shows a simple implementation. What Rick’s example doesn’t address is the blocking problem Steve pointed to – what good is it to use CPS for remote operations if they still block? Volta is supposed to address this, but that’s a long way from being able to say that .NET developers have all this baked in the way Erlang bakes it into OTP.

— Gordon Weakliem

---

Comment

Commenting is closed for this article.