This guide contains the setup and compiler details intentionally kept out of the project README. Start with the source checkout when evaluating the current major-zero release line; packaged installation is covered in Packages And Installation.
- Haxe-first: use Haxe as the normal source language for a Ruby library or CLI, or for a Rails application. Start with the smallest Ruby program, then use the text-report library/CLI for a complete non-Rails workflow. For Rails, the todo application shows nearly all owned app source in Haxe/HHX.
- Ruby-first: keep an existing Ruby or Rails system authoritative and add a typed component or boundary. Start with Ruby interop or the gradual-adoption example below.
Both paths emit ordinary Ruby artifacts and use the normal Ruby runtime and ecosystem. Haxe-first minimizes day-to-day Ruby authoring, but target-level Ruby knowledge remains useful for gem integration, operations, and debugging.
The exact supported versions live in the Compatibility Matrix. The current CI baseline is:
- Haxe
4.3.7 - Node.js
>= 22.14.0and< 23with npm>= 10.9.2and< 11; canonical release jobs use Node22.23.1with npm10.9.8 - MRI Ruby
3.3,3.4, or4.0; Ruby3.3is transitional and the local development pin uses primary Ruby3.4.10 - Rails
8.1for RailsHx workflows; canonical CI locks Rails8.1.3.1, while other Rails lines remain permitted but unverified
The Rails examples also need the generated app bundles. The mandatory Rails runtime task installs them when needed.
From a source checkout:
npm install
npm run test:hello-worldThe command compiles examples/hello_world/Main.hx,
runs the generated Ruby entrypoint, and compares real stdout with the committed
fixture.
For a multi-file Haxe-first library and CLI with filesystem input, typed JSON, failure exit codes, and a handwritten Ruby caller, run:
npm run test:rubyhx-cliSee examples/rubyhx_cli. The Haxelib package gate
also installs the current candidate ZIP into an isolated repository and compiles
that project through -lib reflaxe.ruby.
Run the broad default suite with:
npm testSet ruby_output, include the compiler and vendored Reflaxe source, load the
bootstrap/init macros, and select the Haxe main class:
haxe \
-D ruby_output=out/ruby \
-D reflaxe_runtime \
-cp src \
-cp examples/hello_world \
-cp vendor/reflaxe/src \
--macro "reflaxe.ruby.CompilerBootstrap.Start()" \
--macro "reflaxe.ruby.CompilerInit.Start()" \
-main Main
ruby out/ruby/main.rbFor an installed Haxelib-compatible package, use -lib reflaxe.ruby instead of
source-checkout classpaths and macro wiring. See
Haxelib Packaging for the exact consumer form.
ruby: injected automatically so application/library code can use conventional#if rubytarget branches.ruby_output=<dir>: generated Ruby output directory.reflaxe_runtime: emits/copies requiredhxrubyhelpers.reflaxe_ruby_profile=ruby_first|portable: selects the semantic profile.ruby_firstis the default;idiomaticremains a compatibility alias.reflaxe_ruby_rails: enables Rails artifact layout underapp/haxe_genand emits the Rails autoload initializer.reflaxe_ruby_rails_output_root=<path>: chooses a safe relative Rails output root, including engine/plugin layouts.reflaxe_ruby_strict_examples: rejects raw__ruby__injection in repository examples and snapshots.reflaxe_ruby_strict: rejects raw__ruby__injection in user/project sources.reflaxe_ruby_strict_policy=auto|on|off: controls the strict boundary policy.
See Ruby Profiles before choosing a non-default profile and Compiler Metadata before using target metadata.
The callable example proves Haxe-owned APIs can expose ordinary Ruby blocks, keywords, forwarding, and method values to handwritten Ruby callers:
npm run test:ruby-callable-abi-exampleContinue with:
To use RailsHx as a Haxe-first authoring path, prepare and run the canonical generated Rails app:
rake todoapp:startFor the integrated edit loop:
rake todoapp:devThe reference app demonstrates a workflow where nearly all owned application source is Haxe/HHX: models, controllers, migrations, routes, HHX views, Devise-backed auth, Turbo/ActionCable, Haxe-authored browser code, Rails tests, Playwright, and a production build. See the RailsHx Skeleton And Todoapp Tutorial.
Two focused guides explain the less familiar authoring layers:
- Typed Views And HHX shows how TSX-like HHX catches markup, expression, locals, helper, route, field, and component mistakes before emitting normal Rails ERB.
- Client JavaScript And Genes explains why the canonical browser build uses the Genes custom ES-module generator rather than Reflaxe.Ruby or Haxe's stock JavaScript emitter.
To prove gradual adoption instead:
npm run test:rails-interopThat example keeps existing Ruby/ERB source authoritative while typed Haxe consumes it and Ruby callers consume generated Haxe artifacts. See RailsHx Gradual Adoption.
Rails-facing commands are normal Rails generators and Rake tasks. Common entrypoints are:
bin/rails generate hxruby:install MyApp
bin/rails generate hxruby:scaffold Todo title:String isCompleted:Bool --controller
bin/rails generate hxruby:adopt --service LegacyPriceFormatter
bin/railshx-dev # or: bundle exec rake hxruby:dev
bundle exec rake hxruby:doctor
bundle exec rake hxruby:check
RAILS_ENV=production bundle exec rake hxruby:productionThe complete command and ownership contract lives in RailsHx Generator Workflows.
For failures, use Haxe/HHX locations from compile diagnostics and generated Ruby/ERB paths from server backtraces. Debugging Generated Applications documents the ownership lookup, browser source maps, and current source-correlation limits.
- Why RubyHx for the product model and tradeoffs.
- Docs Index for all RubyHx/RailsHx guides.
- Production Readiness for supported scope and mandatory gates.
- Packages And Installation for release ZIP/gem consumption.
- Repository Development for contributor checks and layout.