Is there any way to build a JavaScript REPL in Rust

I do know how to build a node REPL like GitHub - wingchain/wingchain-cli: Wingchain CLI

key code:

const repl = require('repl')
const vm = require('vm')
const c = repl.start({prompt: '> ', eval: customEval}).context

However, this requires the users to install node and npm

Is there any way to build a JavaScript REPL in RUST?

Therefor, I can publish binary to the users.

Well, you'll have to use some kind of JavaScript runtime. It may be Node.js, or Firefox's internal engine, or, for example, deno. I'm not sure whether there is something easily embeddable, however.

1 Like

The pedantically correct, but useless, answer to this is yes. One of the fundamental discoveries of computer science is that essentially all programming languages are equally powerful: Any programming language can be used to write an interpreter for any other; JavaScript and Rust are both programming languages, therefore there is a way.

Whether or not it's easy is a separate question entirely.

A lightweight js runtime that can be easily embedded is QuickJS via the quick-js crate.

However Windows is only supported via the gnu toolchain.


I haven’t used this project, but I recently ran across Duktape a JS engine written in c which claims to be embedable.

There are some existing rust bindings, but a quick glance doesn’t convince me they are well maintained.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.