Here's an idea for a project (maybe for a motivated undergrad?): a Racket 
sub-language that, like Node.js:

- restricts you to only non-blocking I/O
- restricts you not to have access to Racket threads
- uses the control-flow model of JS where a single event loop invokes only one 
user callback at a time
- provides Node.js-like API's

but *also* uses send/suspend and friends to allow writing event handlers in 
direct style. That's something JS just can't do, since it doesn't have 
first-class continuations.

An even more ambitious student might even play with doing this in a variant of 
Typed Racket with an effect system, where you distinguish functions that might 
suspend their continuation from functions that won't, as well as 
effect-polymorphic higher-order functions such as map and for-each. This would 
make it possible to write expressive server programs where it's nonetheless 
still statically detectable where all the possible points of pre-emption are. 
This makes it easier to reason about shared state, since only calling 
suspendable functions can trigger a pre-emption.

IOW: JS control-flow model + send/suspend + Typed Racket + "suspendability" 
effect.

Dave

On Jan 14, 2011, at 9:40 AM, Neil Van Dyke wrote:

> Eli Barzilay wrote at 01/14/2011 09:21 AM:
>> 
>> 9 hours ago, David Nolen wrote:
>>   
>>> With a good FFI it seems like someone could write a great Racket DSL for 
>>> evented network programming a la Node.js minus all the JS callback cruft.
>>>     
>> 
>> I know very little about it, but it looks like it covers stuff that racket 
>> includes as built in functionality.
>>   
> 
> Yeah, I don't know Node.js, but most of "http://nodejs.org/api.html"; looks 
> like ways to make JavaScript more easily do things that Racket already does 
> better than Node.js does.
> 
> Regarding event-driven API like I see in the documentation for Node.js 
> "net.Server" documentation, you could implement that in pure Racket pretty 
> easily, without needing FFI.
> 
> I've done some fairly high-performance I/O for TCP and interactive subprocess 
> pipes in pure Racket.  Racket's own event conception, buffer operations, and 
> multithreading have been up to the task.  Of course, Racket certainly lets 
> you implement simpler abstractions like Node.js's atop this.  You can even 
> make Racket special-syntax like 
> "define-Node.js-like-server-and-with-some-static-checking". :)
> 
> -- 
> http://www.neilvandyke.org/
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users

_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users

Reply via email to