Live data from Hacker News

Crunch – a Scheme compiler with a minimal runtime

more-magic.net

1–10 of 73 posts

Re: Crunch – a Scheme compiler with a minimal runtime

#2
so if I understand this right, it could be a way to run scheme on esp32 and similar microcontrollers, isn't it?

Also its small size would make it a perfect target to compile to typescript/deno/wasm without rejecting the s-exp power and runtime possibilities in its full chicken code at the backend...

Re: Crunch – a Scheme compiler with a minimal runtime

#3
post #2

so if I understand this right, it could be a way to run scheme on esp32 and similar microcontrollers, isn't it? Also its small size would make it a perfect target to compile to typescript/deno/wasm without rejecting the s-exp power and runtime possibilities in its full chicken code at the backend...

Not in the way I would like: you cannot have a REPL running. Seems only a transpiler for R7 Small.

Re: Crunch – a Scheme compiler with a minimal runtime

#4
I'm glad to see more projects exploring the statically compiled Scheme space. One difference from PreScheme listed is R7RS conformance, but the PreScheme restoration project is also targeting R7RS so that the compiler is portable to many Scheme implementations. The biggest difference I can see is manual memory management vs. reference counting. Though, one of the TODO items for the PreScheme restoration is to revisit memory management. Maybe PreScheme will end up with reference counting, as well.

Re: Crunch – a Scheme compiler with a minimal runtime

#5
post #3
post #2

so if I understand this right, it could be a way to run scheme on esp32 and similar microcontrollers, isn't it? Also its small size would make it a perfect target to compile to typescript/deno/wasm without rejecting the s-exp power and runtime possibilities in its full chicken code at the backend...

Not in the way I would like: you cannot have a REPL running. Seems only a transpiler for R7 Small.

It's compiling a subset of Scheme that can be statically typed. It's not for full-blown live-hackable Scheme programs. You'd use Crunch or PreScheme to implement things that you can't implement in Scheme, like a garbage collector. I don't know if Crunch has this feature, but with PreScheme you can run your PreScheme programs at the Scheme REPL so you can have your comfy REPL-driven dev environment and then create a static executable when you're ready.

Re: Crunch – a Scheme compiler with a minimal runtime

#6
post #2

so if I understand this right, it could be a way to run scheme on esp32 and similar microcontrollers, isn't it? Also its small size would make it a perfect target to compile to typescript/deno/wasm without rejecting the s-exp power and runtime possibilities in its full chicken code at the backend...

There are specialized Scheme implementations that aim to be small.

A recent paper (see also the presentation on YouTube):

Leonard Oest O'Leary, Mathis Laroche, and Marc Feeley A R4RS Compliant REPL in 7 KB

For systems with a C compiler:

Vincent St-Amour and Marc Feeley. PICOBIT: A Compact Scheme System for Microcontrollers. (This one got a best paper award).

Finally, there is also PICBIT available for PIC microcontrollers:

PICBIT: A Scheme System for the PIC Microcontroller

Re: Crunch – a Scheme compiler with a minimal runtime

#7
post #2

so if I understand this right, it could be a way to run scheme on esp32 and similar microcontrollers, isn't it? Also its small size would make it a perfect target to compile to typescript/deno/wasm without rejecting the s-exp power and runtime possibilities in its full chicken code at the backend...

Not a scheme, but for running a lisp on microcontrollers uLisp is pretty amazing. http://www.ulisp.com/

You even get a REPL and everything WHILE running on the hardware. Super easy to set up and get going. Though as it is interpreted so you will of course not have native performance. Still very useful for prototyping and hobbyist projects.

Re: Crunch – a Scheme compiler with a minimal runtime

#8
For Common Lispers such as myself, who are vaguely aware of developments in the Scheme space: the most important difference between CRUNCH and Chicken appears to be that, while both compile down to C/object code, CRUNCH is additionally targeting a statically-typed subset of Scheme.

Opinion: this is great. The aversion of Lispers to static types is historical rather than intrinsic and reflects the relative difference in expressiveness between program semantics and type semantics (and runtime vs tooling) for much of computing. Now that types and tools are advancing, static Lisps are feasible, and I love that.

Re: Crunch – a Scheme compiler with a minimal runtime

#9
post #2

so if I understand this right, it could be a way to run scheme on esp32 and similar microcontrollers, isn't it? Also its small size would make it a perfect target to compile to typescript/deno/wasm without rejecting the s-exp power and runtime possibilities in its full chicken code at the backend...

Not a scheme, but for running a lisp on microcontrollers uLisp is pretty amazing. http://www.ulisp.com/ You even get a REPL and everything WHILE running on the hardware. Super easy to set up and get going. Though as it is interpreted so you will of course not have native performance. Still very useful for prototyping and hobbyist projects.

As a rule, interpreted code has a smaller memory footprint than natively compiled programs.

Even interpreted on a several hundred MHz classic RISC microcontroller, Lisp will chew through a million cons cells a second or more - an order of magnitude or so faster than the old Lisp machines in the 80s were and they used to run giant CAD systems on those to design aircraft and stuff. (Albeit slowly...)

Post reply on HN