5 ms·
Show HN: Run – a CLI universal code runner I built while learning Rust
Hi HN — I’m learning Rust and decided to build a universal CLI for running code in many languages. The tool, Run, aims to be a single, minimal dependency utility for: running one-off snippets (from CLI flags), running files, reading and executing piped stdin, and providing language-specific REPLs that you can switch between interactively.
I designed it to support both interpreted languages (Python, JS, Ruby, etc.) and compiled languages (Rust, Go, C/C++). It detects languages from flags or file extensions, can compile temporary files for compiled languages, and exposes a unified REPL experience with commands like :help, :lang, and :quit.
Install: cargo install run-kit (or use the platform downloads on GitHub). Source & releases: https://github.com/Esubaalew/run https://github.com/Esubaalew/run
I used Rust while following the official learning resources and used AI to speed up development, so I expect there are bugs and rough edges. I’d love feedback on: usability and UX of the REPL, edge cases for piping input to language runtimes, security considerations (sandboxing/resource limits), packaging and cross-platform distribution.
Thanks — I’ll try to answer questions and share design notes.
- brandonasuncion 1y agoAs a small note, Swift is a compiled language. It uses LLVM as a backend, same as Rust and Clang (C/C++/ObjC). It's currently listed under "Web & typed scripting".
- jayrhynas 1y agoIt's definitely a blurry line, this `run` tool invokes your Swift file with `swift file.swift` which runs it in immediate mode. Technically it is compiling your code to memory and and immediately executing it, but is it that different from JIT in Python or Node scripting?
- brandonasuncion 1y agoIf you look at it that way, I agree. But then the same thing is done for executing Go, which is listed with the other compiled languages.
- saghm 1y agoI wonder if the mistake might stem from Go using a subcommand (i.e. `go run`, which might appear resemble `cargo run` or `dotnet run` at a glance) compared to providing the ability to run a "script" as a top-level command, which tends to be more common with interpreted languages (`node`, `python`, `irb`, `bash`, `lua`, etc.)
- likeclockwork 1y ago"compiled" isn't a property of a language. I think the distinction that both you and the author of the tool are making is always going to be messy. It seems to me that you're talking about the language itself via an imprecise description of a particular implementation.
- esubaalew 1y agoYou're right—Kotlin can be used as Kotlin/JS for web development, and as a compiled language when we're talking about Android development. Context matters
- esubaalew 1y agoYou're right—and the same applies to Kotlin. Swift is more like Rust, C, and C++ in that it compiles directly to machine code. So yes, Swift is currently listed under the wrong category. As for Kotlin, it could reasonably be placed under either "Web & scripting" or "Compiled," depending on how it's used. Since Kotlin can also compile to JavaScript, its classification depends on the context. If we're talking about Android development, then Kotlin is clearly a compiled systems language. To clarify: Swift is a compiled, statically typed systems language, much like Rust, C++, or Go. Its core toolchain (swiftc) compiles code into native binaries.
- 8n4vidtmkvmk 1y agoThis is a quirky response. Kotlin might be able to compile to JS the same way C++ can compile to WASM but I don't think that's it's primary purpose. Either put them in their idiomatic category or don't bother categorizing at all.
- generalenvelope 1y agoI'm pretty sure OPs reply is direct from an LLM
- esubaalew 1y agoadded note on the readme
- not--felix 1y agoThis is great! How hard is it to add more languages?
- nick__m 1y agoLooking at the code it appears to be somewhat easy, you add your language to language.rs and in the engine folder you add yourlang.rs where you provide an implementation of the LanguageEngine trait for the YourLangEngine struct. It would be less tedious if some code was factored out into an Helper struct but it doesn't look like it's hard.
- esubaalew 1y agoIt's simple. It was made by someone who's just starting out with Rust.
- pipsgame 1y ago[flagged]
- Surac 1y agoI am very intrested why you choose to write such a tool. i normaly have a hand full of shell scripts doing the work, but surly i have to know the used language befor i call the script. Can you explain the motivation?
- ForHackernews 1y agoIsn't the whole point of a shebang line that scripts can identify for themselves what language/runner they want to be executed via?
- saghm 1y agoYeah, this seems to me to be comparable to something like `/usr/bin/env` or even agnostic language package managers like asdf in terms of trying to provide an abstraction over having to manually define where to find the toolchain to use for a given script. There's a pretty well-established pattern at this point of alternate takes for common CLI tools being written in Rust that bring something interesting to the table at the cost of compatibility with the older existing tool, so even if this one might or might not pan out into being useful for enough people, I think it's totally reasonable to try to come up with a new way of doing things. It's also not incredibly uncommon for people to run scripts that they haven't written themselves (like via the almost universally reviled but still somewhat common `curl <...> | bash` installation pattern). It probably would be better if things didn't get installed like this, but if it's going to happen, it might be nice to have the scripts written in something less annoying than shell so that the authors could at least use the same language for the installation script that they do for writing the software itself.
- esubaalew 1y agoYes, that's exactly the point. What I'm trying to do is: 1. Use Rust because it's fast. 2. Make REPLs universal, so we don't need separate REPLs for different languages. 3. And third—though not a new idea—is to create better abstractions, like allowing print statements without requiring a main function, and accessing variables without explicitly printing them.
- garganzol 1y agoIf someone is interested in pursuing this approach further, there exist a polyglot task runner named 'just' [1]. [1] https://github.com/casey/just?tab=readme-ov-file#shebang-recipes https://github.com/casey/just?tab=readme-ov-file#shebang-rec...
- catlifeonmars 1y agoWhat makes just polyglot? Why not call out /usr/bin/env instead?
- debugnik 1y ago> What makes just polyglot? The link they shared and you didn't open, which is precisely an example of multiple recipes with different #!/usr/bin/env shebang lines, such that a single just file can mix different languages. I'm not sure I like how they handle the shebang on different platforms, though. It makes just files non-portable even when using a language other than a shell.
- catlifeonmars 1y agoI did open the link. I use just in a couple of projects and it’s great. Calling just “polyglot” because it can call another program is nonsensical. I might as well call bash, make, and even VSCode (task runners) polyglot. If the program hosted its own interpreters for multiple scripting languages, then it would make sense to call it polyglot.
- debugnik 1y agoI agree the shebangs are a blunt solution, but I'll give them polyglot for embedding arbitrary languages under the recipe syntax without having to shell out with a heredoc. It's a low bar, but I can't think of any alternative that clears it and I don't think there's any value in hosting the interpreter unless there's some particular API to expose to it. Also, you wrote "Why not call out /usr/bin/env instead?" which is exactly what the example was doing, so I assumed your own proposal would have seemed sufficient to you, had you seen it.
- westurner 1y ago> exposes a unified REPL experience with commands like :help, :lang, and :quit. Those sound similar to "magic commands" in IPython and Jupyter? There is not yet a Jupyter-xeus Rust kernel which would make it really easy to support Rust in JupyterLite in WASM on an .edu Chromebook and in JupyterLab: https://news.ycombinator.com/item?id=43354177 https://news.ycombinator.com/item?id=43354177 > jupyter_console is the IPython REPL for non-ipykernel jupyter kernels. [like evcxr] > This magic command logs IPython REPL input and output to a file: %logstart -o example.log.py https://news.ycombinator.com/item?id=25923123 https://news.ycombinator.com/item?id=25923123 , Here's how to support something like _repr_html_() and IPython.display.display() with evcxr_jupyter: https://github.com/evcxr/evcxr/blob/main/evcxr_jupyter/README.md#custom-output https://github.com/evcxr/evcxr/blob/main/evcxr_jupyter/READM... I'm not sure what the pros and cons of evcxr_repr, jupyter_console + evcxr_jupyter, and Run are?
- davidpfarrell 1y agoNot to be confused with Run: Task runner that helps you easily manage and invoke small scripts and wrappers (weitten in Go) https://github.com/TekWizely/run https://github.com/TekWizely/run
- esubaalew 1y agoTBH my plan was not to replace any of the previous ones and the name polygot is from my idea of many languages in with a single command and simple as run 'code' or run lang code
- esubaalew 1y agohttps://github.com/Esubaalew/run/blob/master/README.md https://github.com/Esubaalew/run/blob/master/README.md read the docs
- esubaalew 1y agoTBH, my plan was not to replace any of the previous ones, and the name polygot is from my idea of many languages in with a single command, and as simple as run 'code' or run lang code
- xk3 1y agoThis lets you read and write variables between different languages, right? Otherwise... what's the point? Can it really compete with something like IPython or yaegi? But if only to learn rust, this is more interesting than building another "todo list" app
- esubaalew 1y agoCool point it is not about comparing run-kit with ipython and they are different things. Ipython is about python and mine is about different languages. And btw I am adding variables between different languages