News for hackers. Stuff that matters.
Re:Curl is C by wyldfire on Monday March 27, 2017 @11:15AM (#13968373)
> I honestly think that Common Lisp can do this quite well

I haven't used any lisp dialects for decades, so I have naive questions: is there really sufficient support from compilers+linkers to write a bootloader in lisp? Do I have to do a lot of bootstrapping in assembly to bring up lisp interpreter before I can execute the lisp code or does the ahead-of-time-build result in executable machine code? Can I do inline assembly (not required but a really key benefit IMO)? Are there numerous examples where someone's already written one in lisp?

Re:Curl is C by tjalfi on Monday March 27, 2017 @02:33PM (#13970411)
https://github.com/dym/movitz is a Common Lisp system that runs on bare metal x86. The source code is quite readable.

The rest of this post is an excerpt from an email I sent 6 years ago.

The following comments on runtime systems are partially based on a long c.l.l thread with posts by Lucid, Symbolics, and Franz alumni.

Franz uses a 3-layer approach: CL, a low-level Lisp, and C.

Lucid started with Lisp that generated assembler but reluctantly added some C.

Symbolics Lisp Machines used bootstrap code in a Pascal-level language with prefix syntax. A Symbolics alum said that in retrospect they should have used C.

Most Lisp implementations have subprimitives - low-level functions that can circumvent the type system, often with a prefix such as % or :.

Assembly language integration dates to Lisp 1.5 and there are several common approaches.

1. turn the optimizer off - this is easy to use and implement.

2. optimize the assembler block - Naughty Dog GOAL did this.

3. annotate the assembler block with pragmas that indicate side effects. This can be error prone and difficult to use. https://www.pvk.ca/Blog/2014/08/16/how-to-define-new-intrins... is an example of this approach.

Edited to add the SBCL intrinsic link.

Re:Curl is C by kazinator on Monday March 27, 2017 @03:24PM (#13970836)
3 sounds like where GCC got its inline asm concept from: annotate the assembly with what are the inputs and output operands with constraints (do they have to be certain kinds of registers), and whether anything has surprising side effects.
Re:Curl is C by sanxiyn on Monday March 27, 2017 @12:11PM (#13968910)
For an example of operating system kernel completely written in Lisp, see https://github.com/froggey/Mezzano