Arc Forumnew | comments | leaders | submitlogin
Arc Ported to JavaScript (amherst.edu)
37 points by nostrademons 2448 days ago | 8 comments


5 points by nostrademons 2448 days ago | link

What's a good repository to park the source in? I don't really plan on maintaining this, but want to offer it up for community hacking. Heard there's a git repository floating around, but I'm a total git newbie...

-----

3 points by vincenz 2448 days ago | link

For the repo, check this: http://arclanguage.com/item?id=809

-----

2 points by nostrademons 2448 days ago | link

I keep getting "fatal: sha1 file '<stdout>' write error (Bad file descriptor)" when I try to git-push to the wiki repository, so if someone for whom git works wants to grab the tarball and import it, feel free.

-----

4 points by vincenz 2448 days ago | link

Pretty cool,

Though I have to admit, it makes firefox hang and then it asks me to stop script. I wish javascript was faster :)

-----

8 points by nostrademons 2448 days ago | link

Fixed the hanging. Was kinda a fun fix too...manually CPS'd the loading of the libraries and then inserted a call to window.setTimeout after each iteration, which gives the browser's event loop a chance to run.

-----

1 point by dido 2443 days ago | link

You could try using an Appel trampoline to do tail calls in JavaScript. See for instance here:

http://home.pipeline.com/~hbaker1/CheneyMTA.html

and here:

http://comonad.com/reader/wiki;item=Appel%20trampoline

This last should be exceptionally interesting for you, as it contains an actual implementation of the Appel trampoline technique in JavaScript!

This technique is also used in the Chicken Scheme compiler among other places.

-----

2 points by nostrademons 2443 days ago | link

I considered it - there was a point where I thought "Wouldn't it be cool if I implemented Cheney-on-the-MTA in JavaScript?" JavaScript doesn't have setjmp/longjmp, but it can be faked with exceptions. But I wasn't sure about the garbage-collection aspect, since you don't have the same fine-grained control over memory that you do in C, and I was afraid that just holding onto the continuation closure would accidentally capture the whole rest of the stack (because of arguments.caller), trading a stack overflow for a massive memory leak. And since I didn't want to spend too much time on the project, I decided to punt on the whole thing.

I think the setTimeout trampoline is better anyways - in addition to cleaning everything up, it also gives the browser's event loop a chance to run, so you don't risk locking up the browser.

-----

2 points by sacado 2448 days ago | link

I wanted to do the same thing in Lua, but I finally thought it was too much work... Since it can be done with Javascript, I guess I'll finally give it a try... You know, just to understand better how it does work...

-----