
A New R6RS Scheme Compiler - widdershins
https://weinholt.se/articles/new-r6rs-compiler/
======
scriptdevil
There is definitely room for a scheme compiler. But the scheme ecosystem felt
extremely fractured the last time I took a look. Chicken had a decent but
aging repo. Chez had a great compiler (I prefer not compiling to C) but it's
package ecosystem was not something well advertised if it did have one. Racket
has too many dialects which might appeal to some but found the number of sub
languages overwhelming for a casual schemer.

~~~
noelwelsh
Making languages is the thing that Racket does better than any other language,
so they do tend proliferate. However, for getting stuff done the majority of
work is done in just Racket. You don't need to know the other languages unless
you're interested in some specialist task they target.

Back when I was a regular Scheme user Racket had by far the biggest ecosystem
and community, so it would be my suggestion if you're interested in exploring
Scheme.

~~~
mapcars
>Making languages is the thing that Racket does better than any other language

Have you tried Rebol/Red?

~~~
soapdog
I did and even though I'm forever in love with both Rebol and Red, Racket does
languages in a more fun way and powerful way for my own personal taste. Don't
know if you have checked this book out but
[https://beautifulracket.com/](https://beautifulracket.com/) is a wonderful
introduction for building languages with Racket.

~~~
greggirwin
For me, the power of the Redbol approach lies in the rich set of datatypes, so
you can create dialects at the block/value level, leveraging the syntax
without having to tokenize at the string level. It's no small thing to be able
to create languages that natively understand values like email addresses,
URLs, IP addresses, files as distinct from strings, and more.

------
exDM69
The related article about using CPU alignment checking for "type checking"
tagged pointers is quite interesting. I wonder if this technique has been used
before (in lisp machines or something?). I'd be interested in hearing about
practical matters like performance and CPU support too.

[https://weinholt.se/articles/alignment-
check/](https://weinholt.se/articles/alignment-check/)

~~~
rjsw
The SPARC CPU was designed to make use of this. Alignment checking was enabled
by default, the tagged add/sub instructions required that the tag in the lower
two bits for an integer was 0, tags for pointers were expected to be 3.

Lisp Machines were word addressed so the technique wouldn't work for them.

------
neilv
This looks like impressive progress towards a Scheme implementation for
systems programming. I'll be interested to see how GC, interrupt-handling,
etc. work.

With an aarch64 backend, and some graphics&GUI work, it might also make sense
atop PostmarketOS Linux kernel, for handhelds.[1] If one needs to heavily
rework Linux userland anyway, and especially if motivated by enthusiasm, it's
an opportunity to rethink, rather than automatically inherit decades of
desktop stack.

[1] Notes on approaching this incrementally at
[https://www.neilvandyke.org/postmarketos/](https://www.neilvandyke.org/postmarketos/)
, though you could alternatively start by building up atop bare
kernel&drivers, and Loko Scheme looks like a promising candidate for that.

------
pjmlp
> It is written in R6RS Scheme and a wafer thin amount of assembly. Once it
> has been bootstrapped it can self-compile. There is no C code in the
> compiler or the runtime.

> ...multiboot binaries for bare hardware

Multiple brownie points combo!

Congratulations on the work achieved.

~~~
jacobush
PicoLisp also has a tiny assembler layer. (And two parallel implementations,
one in Java, one in C.)

~~~
pjmlp
I am aware of it, thanks for bringing it up.

The more the merrier.

------
zucker42
About the AGPL license, does it extend to programs compiled with Loko? The
author seems to not want it to with the comment about the license not
extending to user space. My understanding, however, is that would iff the
programs used a library provided by the AGPL compiler. Hence why gcc has the
linking exception.

~~~
_ph_
Yes, unless there is a specific exception, the program would be covered by
AGPL. Even if you just use it on the server, you have to release your programs
code under the AGPL.

~~~
OskarS
Wow, really? So it’s essentially impossible to use this for proprietary
software? I knew about the server stuff, but I didn’t think the AGPL bound
compiled programs to the terms of the compiler.

If I use an AGPL text editor, does my written text also become APGL?

~~~
e12e
Impossible to use for proprietary software you _distribute_. So you can write
internal software, and only need to share the source with yourself.

~~~
mumblemumble
Probably more poignantly, it's not usable for open source projects that want
to distribute their stuff under a license that's more permissive than the
AGPL.

Which I'm guessing is intentional.

~~~
e12e
Well, it only prevents distributing _binaries_. You could still do source only
distribution.

------
verisimilitudes
All of my software that is not brief and trivial and so benefiting from it is
licensed under the AGPLv3, although I don't use the _or any later versions_
clause, as I don't trust licenses that have yet to be written, and the recent
events make me feel all the superior for not having done so. I'm glad to see
more AGPLv3 software. My opinion on a batch compiler is different from my
opinion on an interactive environment and I'll share a method on how to make
money with the AGPLv3:

For a batch compiler, that is a language that doesn't need the compiler to
run, write an AGPLv3 compiler without a linking exception and then demand
sufficient funds be raised to release a version with the linking exception.
This is then a way to write a Free Software compiler and still demand money
for it, for many to actually want to use it. I wouldn't license something such
as a Lisp compiler with the exception, however, as the implementation
generally exists with the program and that removes some advantages of it being
AGPLv3. Fortunately, it seems the author has used the AGPLv3 and any desired
exception uses vague language not in the license, so it's legally irrelevant.
I'd find it best if there were no exception for this program, but it's not my
decision.

In closing, this has made me want again to write my own Scheme implementation,
so perhaps I'll do that at some point soon.

~~~
nickpsecurity
I had a similar idea with it starting dual-licensed so I could straight-up
sell it to companies. Optionally use a more permissive license if it hit a
certain total. Each new version is done the same way so upgrades on the more-
permissive version still get paid for. Plus, the "get what you pay for"
companies might _only_ buy a proprietary version.

------
_ph_
Sounds like a very interesting project, but actually I belong to the crowd who
would close the tab basically after reading the second paragraph. Which is a
pity, because this sounds like an implementation which could be very nice.

