Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lisp compiler design for embedded systems?

I am researching the development of a lisp compiler which targets embedded devices (16KB or so of RAM) and low level systems programming (i.e. Kernel modules), both of which necessitate complexity guarantees and access to low level constructs.

Even though I need these constructs, I don't want the language to be "low level", in that I want to provide the user with high level constructs which still deliver low level guarantees (I.e. Lisp macros, support for aspect oriented programming, logic or constraint solving, and functional paradigms, etc.).

My current train of thought is that I need to:

  • Create a thin wrapper of s-expression syntax over C99
  • Write macros that define higher levels of abstraction, while still exposing low level structs, pointers, etc.
  • Feed resultant C99 code into gcc, and get the binary I will run

I want to know if my reasoning is sound on this - would the code generated by such a process be able to operate with such a small memory footprint? I don't intend the language to have a runtime component.

like image 750
bmuk Avatar asked Dec 06 '25 09:12

bmuk


1 Answers

Dale is C (/a C-like language), but written with Lisp's syntax and several high-level compile-time features (macros, type inference, anonymous functions, modules... nothing that impacts runtime).

PreScheme is the same destination reached by working from the opposite direction: it is a restricted dialect of Scheme that removes those runtime features that can't be translated 1:1 into C (such as continuations, general tail calls, GC, runtime dynamic typing). PreScheme continues to support Scheme runtime features at the top-level, because this can be moved to "compile time". PreScheme is part of Scheme48 and is used to implement its runtime.

Alternatively, where the main concern is space but not necessarily bare-metal performance, it is often easier to crunch an interpreter down to very small sizes; PICOBIT ([1], [2]) is designed to run in <7Kb while providing a pretty complete Scheme implementation.

like image 144
Leushenko Avatar answered Dec 09 '25 03:12

Leushenko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!