Discuss Scratch

ninjaMAR
Scratcher
1000+ posts

Could scratch be an LLVM backend?

It would be pretty cool to use clang, and get an sb3 file.

I'm not sure if I'm getting the idea correctly

Last edited by ninjaMAR (May 14, 2024 10:46:32)

imfh
Scratcher
1000+ posts

Could scratch be an LLVM backend?

It would probably be possible, but it would be a ton of work. I don't think the Scratch Team likes projects generated automatically without the Scratch editor though. LLVM would likely make a garbled project which was very clearly “compiled” and not easy to edit and remix.

To get around this, you could write an interpreter for some language or architecture in Scratch. The language could be custom made for the project or something that already exists. Then, you can compile stuff, import it into the project, and run it. This actually might be a bit easier than compiling straight to Scratch.

In fact, there are already projects which have implemented architectures supported by LLVM. For example, this project contains a RISC-V emulator. LLVM has a RISC-V backend. The emulator works well enough to run Linux: https://scratch.mit.edu/discuss/topic/710568/

Scratch to Pygame converter: https://scratch.mit.edu/discuss/topic/600562/
davidtheplatform
Scratcher
500+ posts

Could scratch be an LLVM backend?

I think someone got rust to run in a scratch project somehow. I think it was a RISC-V (or similar) emulator and not an actual LLVM backend though.

Generation 4: the first time you see this copy and paste it on top of your sig in the scratch forums and increase generation by 1. Social experiment.
ninjaMAR
Scratcher
1000+ posts

Could scratch be an LLVM backend?

davidtheplatform wrote:

(#3)
I think someone got rust to run in a scratch project somehow. I think it was a RISC-V (or similar) emulator and not an actual LLVM backend though.
I mean where you can compile C code, and get an SB3. A project called ELVM seems to be capable of outputting an SB3, but it uses a very minimal C compiler (can't get anything to work)
Arctenik
Scratcher
15 posts

Could scratch be an LLVM backend?

I've never used it myself, but I know scratch-llvm by @bobbybee exists: https://github.com/alyssarosenzweig/scratch-llvm

(Presumably it's for SB2s though, not SB3s, since it's a bit old)

Previously known as @Zatnik

Powered by DjangoBB