Re:X server in 5000 lines of Common Lisp
by xenophonf on Friday December 06, 2013 @08:59PM
(#6865064)
What do you think a compiler does? The target instruction set can be any Turing-complete language. Compiling C to LISP is no different than compiling LISP to C (e.g., GNU Common Lisp), compiling ML to Java (which is so easy students can do it in 300/400-level CS), and so on.
[ Parent
| on HN ]
Re:X server in 5000 lines of Common Lisp
by stormcrowsx on Friday December 06, 2013 @09:22PM
(#6865152)
You make it sound of easy. How hard is it to go from a GC language to a non-GC language? What methods do you use to fill in GC?
It's the runtime environment that provides that. And GC's for C are pretty easy to come by :)
Re:X server in 5000 lines of Common Lisp
by xenophonf on Monday December 09, 2013 @06:45PM
(#6877933)
Well, the naïve way is to allocate a big block of memory for your C program and manage it using malloc/free like normal (basically, use the LispOS equivalent of sbrk(2)). Alternatively, since pointers are pointers, nothing stops you from having malloc(3) call out to the Lisp runtime's GC. (free(3) is a no-op.) That's basically how the Boehm G. works. I'm not a systems programmer so I'll admit this is a bit hand-wavy. Also, note that malloc/free are not part of the core C language, per se, but the standard library (a/k/a the C runtime). Even if they were in the core language spec, you as the compiler author can implement them however you choose. They aren't magical.
Re:X server in 5000 lines of Common Lisp
by SimHacker on Saturday December 07, 2013 @02:01PM
(#6867233)
How would a language's support for garbage collection make it any harder to compile a non-garbage-collected language into it? Why would you think that?
Re:X server in 5000 lines of Common Lisp
by stormcrowsx on Monday December 09, 2013 @09:51AM
(#6874505)
There's no code to hint at how garbage collection should be done, since its automatic. You have to essentially include a library that would emulate the source language gc that it came from so its not a direct translation from one language to another. At least that's what I was thinking