Re:Vacietis, a C compiler targeting Common Lisp
by amir734jj on Friday December 25, 2020 @11:11PM
(#25541310)
But why? Can someone explain the reason behind it? I'm confused.
[ Parent
| on HN ]
Re:Vacietis, a C compiler targeting Common Lisp
by sedachv on Saturday December 26, 2020 @01:12AM
(#25541792)
I wanted a way for a Lisp operating system to be able to use OpenBSD or NetBSD hardware device drivers without modifying the driver source code. NetBSD hackers started writing their device drivers with well-specified interfaces between the driver and kernel (eventually that turned into the rump kernel idea https://wiki.netbsd.org/rumpkernel/), OpenBSD hackers borrowed a lot of the ideas (like bus_dma) into OpenBSD drivers. The Lisp operating system runtime would need to implement the applicable kernel functions used by the drivers, and designate certain pointers (hardware registers and buffers) as real memory writes/addresses, and the drivers should "just work."
Obviously this is also useful for userland stuff.
There are other approaches to this, but Vacietis maps C data and pointers to Common Lisp data structures, so they are inspectable but still memory safe (and you can run a bunch of things in a single address space if you want), and C functions are just Common Lisp functions so all of the development and debugging tools "just work."
Re:Vacietis, a C compiler targeting Common Lisp
by andi999 on Saturday December 26, 2020 @03:33AM
(#25542169)
I see some potential for rapid application development. Shouldnt give you this a C repl?
Re:Vacietis, a C compiler targeting Common Lisp
by sedachv on Saturday December 26, 2020 @10:14PM
(#25548500)
It does.
Re:Vacietis, a C compiler targeting Common Lisp
by fiddlerwoaroof on Friday December 25, 2020 @11:17PM
(#25541332)
One advantage of C -> Common Lisp vs. FFI is that issues in the C code are less likely to be exploitable since the C is compiled to a more memory-safe language.
Re:Vacietis, a C compiler targeting Common Lisp
by fiddlerwoaroof on Friday December 25, 2020 @11:31PM
(#25541397)
Vacietis is interesting and similar to the way C worked in the Symbolics Lisp Machines (Zeta-C), but I think llvm IR -> CL is more practical these days. Iota (made to port Doom to a pure-CL OS, Mezzano, I believe) is an example of this strategy: https://github.com/froggey/Iota
Re:Vacietis, a C compiler targeting Common Lisp
by dgb23 on Saturday December 26, 2020 @05:26AM
(#25542541)
I misunderstand what you're saying or miss an obvious joke. I would have thought a garbage collected language is typically safer.
Re:Vacietis, a C compiler targeting Common Lisp
by lispm on Saturday December 26, 2020 @10:09AM
(#25543867)
Given that one has plain C code, then it is possibly safer to run it when compiled to a memory safe runtime (with bounds checks, no pointers, etc.) than to use a C to machine code compiler and call the compiled code from Lisp via a Foreign Function Interface (FFI).
Re:Vacietis, a C compiler targeting Common Lisp
by dgb23 on Saturday December 26, 2020 @03:14PM
(#25546129)
Thanks for clarifying!
Re:Vacietis, a C compiler targeting Common Lisp
by jrumbut on Saturday December 26, 2020 @01:29AM
(#25541844)
I could see this being easier than FFI to use some algorithm implemented in C in a one-off lisp script.
Re:Vacietis, a C compiler targeting Common Lisp
by amelius on Saturday December 26, 2020 @09:16AM
(#25543586)
To implement proper tail recursion?
Re:Vacietis, a C compiler targeting Common Lisp
by aidenn0 on Saturday December 26, 2020 @11:54AM
(#25544589)
Common lisp has exactly the same requirements on tail calls as C, and in fact has certain features that make tail call elimination not possible when used (e.g unwind protect and dynamic bindings)