top | item 45475528

Show HN: Run – a CLI universal code runner I built while learning Rust

96 points| esubaalew | 4 months ago |github.com

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

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.

39 comments

order

Surac|4 months ago

I 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|4 months ago

Isn't the whole point of a shebang line that scripts can identify for themselves what language/runner they want to be executed via?

esubaalew|4 months ago

The idea is similar to IPython, which provides an interactive interface for programming languages. The motivation isn't about building a massive CLI tool—it's about questioning why we need a separate REPL for each language when we could use a single command-line interface that lets us switch between languages on the fly.

westurner|4 months 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

> 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 ,

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/READM...

I'm not sure what the pros and cons of evcxr_repr, jupyter_console + evcxr_jupyter, and Run are?

garganzol|4 months ago

If 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-rec...

HumanOstrich|4 months ago

By this logic, Bash is a "polyglot task runner" too. With a shebang and executable permissions, I can run `./task1.py` or `./task2.js` or `./task3.sh`. I can also run inline tasks in various languages within a Bash script by piping the source into the appropriate interpreter.

I like and use `just`, but I think the project author's claims around it being "polyglot" are misusing the term.

catlifeonmars|4 months ago

What makes just polyglot? Why not call out /usr/bin/env instead?

brandonasuncion|4 months ago

As 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|4 months ago

It'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?

esubaalew|4 months ago

You'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.

esubaalew|4 months ago

TBH, 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

not--felix|4 months ago

This is great! How hard is it to add more languages?

nick__m|4 months ago

Looking 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|4 months ago

It's simple. It was made by someone who's just starting out with Rust.

xk3|4 months ago

This 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|4 months ago

Cool 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

davidpfarrell|4 months ago

Not 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

esubaalew|4 months ago

TBH 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