{"library":"ranger-compiler","title":"Ranger Compiler","description":"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.","language":"javascript","status":"active","last_verified":"Fri May 01","install":{"commands":["npm install ranger-compiler"],"cli":null},"imports":["import R from 'ranger-compiler'","import R from 'ranger-compiler';\nR.addFile('file.clj', source);","import R from 'ranger-compiler';\nR.compile({ files: [], outputDir: 'bin' });","import type R from 'ranger-compiler';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"// Install: npm install -g ranger-compiler\n// Save this as hello.clj:\n// class Hello {\n//     static fn main () {\n//         print \"Hello World\"\n//     }\n// }\n// Then run: ranger-compiler hello.clj\n// Output: bin/hello.js\n\n// Alternatively, from TypeScript:\nimport * as fs from 'fs';\nimport R from 'ranger-compiler';\n\n// Load standard library files\nR.addFile('Lang.clj', fs.readFileSync('./libs/Lang.clj', 'utf8'));\nR.addFile('stdlib.clj', fs.readFileSync('./libs/stdlib.clj', 'utf8'));\nR.addFile('stdops.clj', fs.readFileSync('./libs/stdops.clj', 'utf8'));\nR.addFile('JSON.clj', fs.readFileSync('./libs/JSON.clj', 'utf8'));\n\n// Add your source files\nconst files = ['hello.clj', 'other.clj'];\nfiles.forEach(f => R.addFile(f, fs.readFileSync(f, 'utf8')));\n\n// Compile to JavaScript\nconst result = R.compile({\n  files: files,\n  outputDir: 'bin',\n  language: 'es6'\n});\nconsole.log('Compilation successful:', result);","lang":"typescript","description":"Shows CLI usage and TypeScript API to compile a Ranger file to JavaScript, including loading standard library files.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}