Live data from Hacker News

MIT Scheme on Apple Silicon

kennethfriedman.org

21–30 of 87 posts

Re: MIT Scheme on Apple Silicon

#21
post #10

Earlier quoted context omitted.

So Java, Groovy, Scala, Kotlin and Clojure aren't running on x86, nor ARM, nor Apple Silicon?

In a lot of ways, yes. Their runtimes are so massive that saying they "run" on any of those architectures is a stretch of what is actually happening at a lower level.

In "a lot of ways", sure, but definitely not by the most common meaning of "program x runs on y architecture", and not the one being used by most people in this thread.

If you ask any random programmer if "Java runs on x86", 99% of them will say either "yes" or "I don't know what x86 is". Similarly, if you ask them "does Kotlin run on the SPARC architecture", they'll say "I don't know" and, if you give them some time to find [1], they'll amend to "no".

To be precise: the meaning being used by most programmers (and here) is "either the compiled binaries, the virtual machine, or the interpreter runs directly on the given architecture" - which clearly excludes MIT Scheme running on Rosetta, just as (to take a less controversial example) the fact that might be able to run the JVM on qemu on SPARC doesn't mean that the JVM runs on SPARC.

Thinking about the various levels of abstraction of VM's and interpreters is a fun exercise in general, but I don't think it's constructive in this particular situation.

[1] https://openjdk.java.net/jeps/381

Re: MIT Scheme on Apple Silicon

#22
I got MIT Scheme running on my M1 MacBook Pro about 6 months ago when I bought the book "Software Design for Flexibility" and although I can't find my notes for that, I think I remember building from source natively, not via Rosetta - but I may remember incorrectly.

I also remember it taking a while to get Gerbil Scheme running on M1.

Re: MIT Scheme on Apple Silicon

#23
post #17

Earlier quoted context omitted.

Apple Silicon has a (mostly) hardware translation layer, which this software is running on. There's a special aarch64 build of the software available, so it clearly runs on ARM. Perhaps there's some kind of issue specifically on macOS that makes the existing ARM port incompatible with Apple's ARM implementation?

> Apple Silicon has a (mostly) hardware translation layer… I can’t imagine what you mean by this, Rosetta 2 is a binary translation system implemented in software, based on QuickTransit. There are a few features implemented in Apple Silicon to make translation easier and more efficient, such as supporting Intel memory ordering, but thats about it. I think it’s reasonable to worry about how long rosetta2 will be avail…

Looks like QuickTransit was a jit engine which was the base of Rosetta 1. Rosetta 2 is AOT translation.

Re: MIT Scheme on Apple Silicon

#24
post #6

I've been engaged in a 1.5 year long (so far) project to port the entirety of GJS's "scmutils" package over to Clojure, and the erratic behavior of MIT Scheme over Rosetta has been a pain I've consigned myself to for months. I keep an old machine handy when I need to test functions that can't work on the M1. I am SO HAPPY to see this work! Major timesaver for me and anyone looking to run the executable versions of Fu…

I have to ask, how far along is this project? Is it good enough to run all of the examples in the books? I have run into the issue where the provided compiled version of scmutils from GJS' website doesn't run on recent versions of MIT Scheme (version 11 and up) and there's not much info on compiling it yourself.

Re: MIT Scheme on Apple Silicon

#26
post #17

Earlier quoted context omitted.

Apple Silicon has a (mostly) hardware translation layer, which this software is running on. There's a special aarch64 build of the software available, so it clearly runs on ARM. Perhaps there's some kind of issue specifically on macOS that makes the existing ARM port incompatible with Apple's ARM implementation?

> Apple Silicon has a (mostly) hardware translation layer… I can’t imagine what you mean by this, Rosetta 2 is a binary translation system implemented in software, based on QuickTransit. There are a few features implemented in Apple Silicon to make translation easier and more efficient, such as supporting Intel memory ordering, but thats about it. I think it’s reasonable to worry about how long rosetta2 will be avail…

I can't say what Apple will do, but I'm really hoping they'll keep Rosetta 2 around for longer than Rosetta 1.

For starters, the Mac became a lot more popular in the Intel era than it ever was while on PPC, so there's a much larger quantity of legacy software that Apple would be cutting off. Secondly, the overall user experience of running apps via Rosetta 2 seems to be a lot better than Rosetta 1. And for Apple, Rosetta 2 was developed in-house and doesn't require continuous licensing fees to keep around (not that I'm particularly sympathetic to Apple's pocketbook.)

Re: MIT Scheme on Apple Silicon

#27
post #23
post #17

Earlier quoted context omitted.

> Apple Silicon has a (mostly) hardware translation layer… I can’t imagine what you mean by this, Rosetta 2 is a binary translation system implemented in software, based on QuickTransit. There are a few features implemented in Apple Silicon to make translation easier and more efficient, such as supporting Intel memory ordering, but thats about it. I think it’s reasonable to worry about how long rosetta2 will be avail…

Looks like QuickTransit was a jit engine which was the base of Rosetta 1. Rosetta 2 is AOT translation.

They’re both based on QuickTransit, but Rosetta 2 has an AOT mode as well as JIT. I’m sure the R2 engine is more advanced than the original engine, Apple employed several engineers from the original team, but it still uses and is based on licensed tech.

Re: MIT Scheme on Apple Silicon

#28
post #4

Just a UI comment, the white highlighting of white text on a black/grey background is pretty unreadable in my browser

Just turn off dark mode. So many sites have css that claims to support dark mode but doesn’t. The other direction seems less common.

We should really expect better from someone who's about page says they are an interface designer, though.

Re: MIT Scheme on Apple Silicon

#29
post #14
post #8

What's stopping people from just compiling Scheme for ARM? The website has a separate aarch64 download it seems, so why not patch that instead of relying on Rosetta2? The vfork/fork issue and the compiler upgrade issue don't seem to be too problematic to work around, so there must be some kind of ARM limitation that's preventing Scheme from working, but what?

MacOS on the M1 processor is the first to use, and require, the W^X bit in memory, meaning that pages of memory are either writable, or can be executed from, but not both. MIT Scheme's front page says this is fundamentally incompatible with their design, and therefore it won't build. When running in the emulator, this requirement would be relaxed for compatibility reasons. There is an escape hatch for writing JIT com…

Wow really? A common intro to security exercise (think CTFs and university courses) is to write increasingly complicated C programs that leverage W&X. Classic buffer overflow into the stack kind of stuff. On M1 it’s now impossible to exploit even a self-compiled toy in this way?

Re: MIT Scheme on Apple Silicon

#30
post #6

I've been engaged in a 1.5 year long (so far) project to port the entirety of GJS's "scmutils" package over to Clojure, and the erratic behavior of MIT Scheme over Rosetta has been a pain I've consigned myself to for months. I keep an old machine handy when I need to test functions that can't work on the M1. I am SO HAPPY to see this work! Major timesaver for me and anyone looking to run the executable versions of Fu…

I have to ask, how far along is this project? Is it good enough to run all of the examples in the books? I have run into the issue where the provided compiled version of scmutils from GJS' website doesn't run on recent versions of MIT Scheme (version 11 and up) and there's not much info on compiling it yourself.

It is good enough! Almost all code forms from the book live in the tests (see the FDG directory[0], for example), and there are a few nice environments like Nextjournal[1] where everything from the books works in the browser.

The Clojure port is quite fast, faster than the original for all benchmarks GJS has sent me, and more fleshed out. (That will change, as I've been pushing bugfixes and performance improvements back upstream as I go, as a meager gift to GJS for making this huge, amazing library in the first place.)

I actually wrote to GJS this morning asking for instructions on how to compile the original "scmutils", since I have the same problem. He responded saying he'll get back to me this afternoon, so I'll post here once I have details.

If you are still interested in getting the books going with MIT-Scheme, I put a decent amount of work into the exercises using the original codebase here[2], including a dockerized version of mit-scheme[3] and the scmutils package[4] that might be useful.

- [0] https://github.com/sicmutils/sicmutils/tree/main/test/sicmut...

- [1] https://nextjournal.com/try/samritchie/sicmutils/

- [2] https://github.com/sicmutils/sicm-exercises

- [3] https://hub.docker.com/r/sritchie/mit-scheme

- [4] https://hub.docker.com/r/sritchie/mechanics

Post reply on HN