A Scratch JIT compiler written in rust using cranelift.
Warning: This is highly experimental, incomplete software. If you want an existing production-ready solution, see scratchcpp
Scratch is a visual programming language aimed at children, and people push it to its limits (with projects like path tracers, 3d minecraft clones, neural networks and more), running into performance bottlenecks.
Rash aims to run scratch code with a JIT compiler, where the code is compiled to machine code and executed directly, much like Java, C#, JavaScript, etc.
You can see the progress in implementing blocks in this Google Docs spreadsheet
(WIP means Work-In-Progress)
- Implement loading from SB3 files (WIP)
- Implement Control operations
- If, If-Else
- Repeat, Repeat Until, Forever
- Wait
- Wait Until
- Stop this script
- Stop all
- Stop other scripts in sprite
- Math Operations
- Add, subtract, multiply, divide
- && || !
- < > (incomplete)
- ==
- String: Join, Contains, Length
- Mod, Round, Abs
- Floor
- Ceiling
- Sqrt
- Sin, Cos, Tan
- ASin, ACos, ATan
- Ln, Log
- E^, 10^
- Other blocks
- Days since 2000
- Timer, reset timer
- Keyboard/mouse input
- Core features
- Custom Blocks
- Variables
- Lists
- Broadcasts
- Clones
- Add Graphics
- Hide, Show blocks
- Position blocks
- Rotation blocks
- Size block
- Render sprites & stage
- Render text
- Render speech and thought bubbles
- Sprite costumes and backdrops
- Sprite graphical effects (Ghost, Fisheye, etc)
- Pen canvas and clear operation
- Pen stamps
- Pen lines
- Variable monitors
- UI library
- Add sound
- Install the Rust language if you haven't already.
- Clone the repository:
git clone https://github.com/Mrmayman/rash.git - Change directory:
cd rash - Compile and run Rash:
cargo run --release -- path/to/file.sb3 - To run the test suite, do:
cargo test
Feel free to submit any changes you make as a pull request, I'll be happy to review it.
Pi calculation:
- Scratch:
621 ms - Turbowarp:
13 ms - Rash:
7 ms