Arc Forumnew | comments | leaders | submitlogin
Arc 4x slower than python & now has a stand-alone interpreter
27 points by sacado 6123 days ago | 12 comments
Well, the most boring thing (as for me) with arc was its "interpreter interpreted from another interpreter" architecture. Mzscheme code can be compiled to a standalone exe, but it's rather complicated and it couldn't be made straight from Paul's source code.

So I changed a little the code from ac.scm (by merging all the .scm files together and doing tricky things from mzscheme's namespaces), and now we've got it ! Arc can be used as a standalone interpreter (sic).

As a bonus, the fibonnaci example is now less than 4x slower than its python counterpart. Well, actually, to do so, I had to make effective the optimisation someone there already wrote about, in arc< and arc>.

I promise, as soon as I can, I'll push that to the git.



6 points by elibarzilay 6122 days ago | link

"interpreter interpreted from another interpreter" is very far from the way things are. Arc works by translating arc forms to mzscheme, so it's a compiler, not an interpreter. The arc compiler itself is not interpreted, it is compiled by mzscheme -- and since mzscheme byte-compiles everything (and uses a JIT compiler on the result), it is not an interpreter.

The thing is that there are many ways in which arc can be made faster, but packaging things up in a mzscheme executable is not what speeds things up.

-----

5 points by nex3 6122 days ago | link

Except that according to sacado's benchmarks, packaging things up in a mzscheme executable apparently does speed things up.

-----

2 points by eds 6122 days ago | link

Um....

Sacado said: "Well, actually, to do so, I had to make effective the optimisation someone there already wrote about, in arc< and arc>."

-----

5 points by sacado 6122 days ago | link

In fact, both were needed to optimize things. Mzscheme's doc says explicitly (though I can't remeber where exactly) that standalones are a little faster than interpreted code (there are a few more optimisations they can perform during compilation I guess). Running arc1.scm through mzscheme -f is a little slower.

-----

4 points by elibarzilay 6122 days ago | link

There is an initial overhead for byte-compiling the code and jitting it -- but that's not something that you'd be able to measure for such a small piece of code. Once that's done, it's the same code -- mzscheme (since a good while ago) on intel and ppc does not interpret code. Ever. Even on solaris, where the jit is disabled, it's "interpreting" byte-compiled code, so it is not an interpreter in any case.

-----

2 points by elibarzilay 6122 days ago | link

Right, these two are major bottlenecks. (There are still a good number of them that can be optimized.)

-----

10 points by sacado 6123 days ago | link

Well, it's on the git now. To have the executable, just run

  mzc --exe arc1 arc1.scm
If you feel adventurous, mzc --gui-exe arc1 arc1.scm might give you access to MrEd, the graphical library of MzScheme (a MrEd binding to arc could be a nice thing :) but I didn't try it.

-----

3 points by eds 6123 days ago | link

Very nice. Both your suggested commands worked for me (on Windows XP).

I like the GUI especially (it actually solves a bug I found with mzscheme that was stopping me from pasting code directly into the command line). Although I find it somewhat strange that I have to click quit twice in order to actually close the program.

-----

1 point by ryantmulligan 6123 days ago | link

does the first click close Arc and the second close MrEd?

-----

1 point by eds 6123 days ago | link

Yes.

  Use (quit) to quit, (tl) to return here after an interrupt.
  arc> (quit)
  
  [Exited]
Clicking close after this closes the window. Similarly, clicking close twice seems to first send a break signal, then close the window.

I kind-of understand why it is doing this, but it might be nice to have it quit immediately when the user enters (quit).

-----

5 points by nex3 6122 days ago | link

It would be nice if you could add a brief comment to the top of arc1.scm explaining what it's for and how to use it. Maybe even name it something more descriptive, like arc-standalone (especially since "arc1" already refers to the version of arc distributed as arc1.tar).

-----

3 points by babo 6122 days ago | link

It's working fine even with a recent development version of mzscheme. I tried with mz-3.99.0.11, all you need is to replace set-c{a,d}r! to set-mc{a,d}r!

-----