CPS for the win?

My old half-baked idea/dream of a cranky day job programmer who doesn't really know what he's talking about:

  • Convert everything in to CPS.
  • Each function call is a new continuation.
  • Have a top level 'event loop' that runs the next continuation one at a time.
  • The runner checks the signature of the next function vs. a lookup table for hooks to run before and/or after the invocation.

This gives super powers like:

  • AoP join points at every function. In languages that are more expression than statement oriented, more pure fp style, then that means there's a lot of opportunity for join points.
  • Logging is more flexible, at any join point, dynamically adding/removing/tweaking at runtime.
  • Ability to run prod & test versions of any function side by side and compare behaviour.

Code would still be interacted with by developers in original format. Since e.g. hypothetically anything can be converted from imperative to monadic pure fp style then e.g. Java could be set up this way. The UX for adding hooks would be nice and all at a high level, looking like source code, not some internal runtime CPS hell.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Scheme

That's exactly how the first two implementations of Scheme worked, the original interpreter and the Rabbit compiler. Except without the hooks.