- GraalVM for JDK 23 (Latest)
- GraalVM for JDK 24 (Early Access)
- GraalVM for JDK 21
- GraalVM for JDK 17
- Archives
- Dev Build
- Ruby Reference
- Compatibility
- Debugging Ruby
- Runtime Configurations
- Using Ruby with GraalVM
- Installing `libssl`
- Installing LibYAML
- Installing Make and GCC
- Installing `zlib`
- Migration from JRuby to Ruby
- TruffleRuby Options and Command Line
- Polyglot Programming
- Ruby Managers and Installers
- Standalone Distribution
- Development Tools for Ruby
- Ruby Additional Functionality
- Setting up a UTF-8 Locale
- Reporting Performance Problems
- Security
- Optcarrot Example
- FAQ
Running Optcarrot
Running the Demo #
Start by installing the TruffleRuby JVM Standalone.
You also need to install SDL2:
brew install sdl2
on macOSsudo yum install SDL2-devel
for RedHat-based Linuxsudo apt-get install libsdl2-dev
for Debian-based Linux
Then clone the optcarrot repository:
git clone https://github.com/eregon/optcarrot.git
cd optcarrot
Then you can play the Lan Master game.
On Linux:
ruby --jvm bin/optcarrot --print-fps --sdl2 --audio=none examples/Lan_Master.nes
On macOS, you need an extra flag, --vm.XstartOnFirstThread
, for the GUI to appear:
ruby --jvm --vm.XstartOnFirstThread bin/optcarrot --print-fps --sdl2 --audio=none examples/Lan_Master.nes
Note: --audio=none
is used since the audio is not nice at non-60FPS speeds.
To play, use keys 1
…7
(not on numpad) to scale the screen, X
for OK/turn right, S
for turn left, arrows to move around, and Q
to quit.
More information can be found in this blog post.
Here is a recording of a talk running the demo on TruffleRuby and MRI.
Running on Other Ruby implementations #
You can also run it on MRI for comparison. You will need to install the FFI gem with:
gem install --user ffi
ruby bin/optcarrot --print-fps --sdl2 --audio=none examples/Lan_Master.nes
You can also run it on JRuby if desired:
jruby bin/optcarrot --print-fps --sdl2 --audio=none examples/Lan_Master.nes
Running as a Benchmark from the TruffleRuby Repository #
If you have a local checkout of TruffleRuby, you can also use the version of OptCarrot under bench/optcarrot
.
See the Benchmarking documentation for details.