Ranger Compiler (v2.1.70, experimental) is a self-hosting cross-language compiler that translates Ranger source code into JavaScript, Java, Go, Swift, PHP, C++, C#, and Scala. It features type safety, classes, inheritance, operator overloading, lambda functions, generic traits, class extensions, and type inference. Unlike single-target compilers, Ranger allows writing portable algorithms that can run on multiple platforms. The compiler runs on Node.js and can be used from TypeScript. Currently, only JavaScript target is fully self-hosted; other targets are in varying stages of completeness. The package is experimental and released on npm.
npm install ranger-compilerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows CLI usage and TypeScript API to compile a Ranger file to JavaScript, including loading standard library files.
Update code to use R.addFile, R.compile etc. instead of calling R as a function.
Remove the `-typescript` flag from CLI invocation. The compiler now always generates TypeScript-annotated JavaScript when compiling to ES6.
Use `-l=scala` and configure Scala output manually if needed.
For production, use JavaScript target. Test other targets thoroughly before relying on them.
Locate the libs folder relative to the package (e.g., node_modules/ranger-compiler/libs/) and load the necessary .clj files using addFile.
Run `npm install -g ranger-compiler` for CLI, or `npm install ranger-compiler --save-dev` for local usage in a project.
Use `import R from 'ranger-compiler'` and then `R.addFile(...)`.
For v2.0+, use `import R from 'ranger-compiler';` and call methods on R instead of calling R directly.
Ensure you load required files (Lang.clj, stdlib.clj, stdops.clj, JSON.clj) via `R.addFile()` before calling `R.compile()`.