Live data from Hacker News

Fargo: new Scheme-like language working in Node.js/browser

fargo.jcoglan.com

31–37 of 37 posts

Re: Fargo: new Scheme-like language working in Node.js/browser

#31
post #24
post #21

Any reason why not to implement call/cc and then write fibers in terms of call/cc? The implementation may not actually be any different from what it is. (I've not studied the code enough to understand how it implements fibers, although I got the impression that it handles call frames explicitely (source/fargo/runtime/stack{,less}.js).)

I was going to do call/cc but fibers are cheaper. The implementation is very similar, but because fibers can only be resumed once from the last yield you don't need to copy the stack when yielding and resuming. They also require the user to explicitly start a fiber. This means when you're not in a fiber you can use a faster stackless engine because you don't need to track the state of the current continuation.

> explicitly start a fiber

Fair point.

BTW what's interesting about yield based versus lazy evaluation (functional stream) based sequence generation? Advantages of the latter are that they can easily be understood as sequences and thus further processed by lazy versions of the known sequence processing functions (map etc.), also they can be re-read multiple times, which you just made impossible for yield by not basing it on call/cc :).

Re: Fargo: new Scheme-like language working in Node.js/browser

#32
post #30
post #25

Earlier quoted context omitted.

With regard to maturity, Fargo is one week into development. I'm not even sure if its just a quick hack to show off an idea or if it will become a production language. Certainly I have a lot to learn about compilers and VMs before that happens.

Hey, didn't mean to be mean, my apologies. I love to see people experimenting with new things. I may play around with it tonight :)

Oh, no offense taken. Thanks for pointing out other lisps, I should check them out for alternative ideas.

Re: Fargo: new Scheme-like language working in Node.js/browser

#33
post #26
post #9

I'm a newb or something but : (cdr ()) makes it explode. What's nil? null nil don't exist I do really like this. I was hoping for something like this where it would allow me to write lisp instead of javascript.

well, (cdr ()) is an error in standard Scheme, as empty list is not pair.

I'll fix this so that invalid expressions are reported and car and cdr of () are errors.

Re: Fargo: new Scheme-like language working in Node.js/browser

#34
post #31
post #24

Earlier quoted context omitted.

I was going to do call/cc but fibers are cheaper. The implementation is very similar, but because fibers can only be resumed once from the last yield you don't need to copy the stack when yielding and resuming. They also require the user to explicitly start a fiber. This means when you're not in a fiber you can use a faster stackless engine because you don't need to track the state of the current continuation.

> explicitly start a fiber Fair point. BTW what's interesting about yield based versus lazy evaluation (functional stream) based sequence generation? Advantages of the latter are that they can easily be understood as sequences and thus further processed by lazy versions of the known sequence processing functions (map etc.), also they can be re-read multiple times, which you just made impossible for yield by not basin…

I've been thinking about this. I might try out making all the primitive functions understand promises. So not lazy evaluation per se, but having the core library transparently deal with asynchronous values. Maybe monads would help but that really requires a decent type system.

Re: Fargo: new Scheme-like language working in Node.js/browser

#35

I've been working on Ralph for a while now: https://github.com/turbolent/ralph It compiles a major subset of Apple's Dylan ( http://lispm.dyndns.org/documentation/prefix-dylan/book.anno... ) to JavaScript, both for use on a CommonJS implementation and in the browser. A bootstrapping compiler is implemented in JS, but the same compiler is also available in Ralph itself and features define-macro (Cl-like). The whole ru…

I notice that it doesn't support multiple inheritance or multimethods; out of curiosity, is that because of a principled objection to them, or more because it wouldn't be convenient to implement them?

Re: Fargo: new Scheme-like language working in Node.js/browser

#36

I've been working on Ralph for a while now: https://github.com/turbolent/ralph It compiles a major subset of Apple's Dylan ( http://lispm.dyndns.org/documentation/prefix-dylan/book.anno... ) to JavaScript, both for use on a CommonJS implementation and in the browser. A bootstrapping compiler is implemented in JS, but the same compiler is also available in Ralph itself and features define-macro (Cl-like). The whole ru…

I notice that it doesn't support multiple inheritance or multimethods; out of curiosity, is that because of a principled objection to them, or more because it wouldn't be convenient to implement them?

At the beginning I tried implementing various object systems. The first one was indeed multiple inheritance with multimethods, based on C3 linearization (http://en.wikipedia.org/wiki/C3_linearization) and didn't use the prototype chain, but wasn't finished. The second one was similar to Clojure's protocols (define-protocol, extend-protocol, ...), but wasn't very handy.

The current one is single-inheritance, because it uses the prototype chain. It's a compromise between speed and usefulness. I'd prefer having multimethods (and maybe also multiple inheritance), but speed is a bit more important, as JavaScript is already quite slow.

So far I'm quite pleased with the single-inheritance and single dispatch solution, which basically works like that: https://gist.github.com/866506

Post reply on HN