On Fri, Dec 11, 2015 at 7:55 AM, Brian Adkins <lojicdot...@gmail.com> wrote:
> Excuse my ignorance of Racket internals & implementation, but I'm curious 
> about why the module system is implemented in C vs. Racket. Can someone who 
> is familiar with it provide some insight?

I'll do my best. A large number of features are implemented in C.
Generally, you could divide those features in C into the categories
"runtime", "virtual machine", and "compiler". (Don't read too much in
to this division because the compiler is available at runtime and they
are all primitive functions of the virtual machine.)

By virtual machine, I mean the execution of byte-code forms, like
making closures, doing garbage collection, making lists, and other
data structures, connecting to C, etc. By runtime, I mean useful
functions like filtering lists, converting numbers to do arithmetic,
printing to ports, etc. By compiler, I mean expanding syntax then
compiling it into byte-code.

Historically, I'd say that these are all together in C because our
macro system means the compiler has to run code inside of the virtual
machine and have access to all those useful runtime functions. (Other
things are in C because the FFI came "late" to Racket and we haven't
gone back and implemented things like IO with the FFI, although
Matthew did convert all of the GUI from C to Racket a few years ago.)

Presently it would be pretty reasonable to convert C runtime code to
Racket (to take a random example: a few years ago, `map` was moved[*]
from C to Racket and performance improved due to the JIT. [* = it is
actually still there but your Racket program's don't use it, just
other internal C code calls that map.]. It's just unclear whether
that's a good use of resources at this time. Matthew plans on porting
the syntax expander part of the compiler into Racket and another
graduate student is working on converting the compiler itself to
Racket.

It is pretty implausible at this point to convert the VM itself and
get rid of everything in the runtime. You might imagine that we could
make a compiler turn the bytecode directly into assembly, but we'd
still need to have a runtime written in something to do stuff like GC.
But few languages like Racket (i.e. that have a runtime) do anything
like that.

I hope this is helpful and I hope it is accurate,

Jay

-- 
Jay McCarthy
Associate Professor
PLT @ CS @ UMass Lowell
http://jeapostrophe.github.io

           "Wherefore, be not weary in well-doing,
      for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great."
                          - D&C 64:33

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to