Live data from Hacker News

Running JavaScript in Rust with Deno: Experimenting with Deno's Rust Crates

austinpoor.com

11–20 of 22 posts

Re: Running JavaScript in Rust with Deno: Experimenting with Deno's Rust Crates

#11

Being able to allow custom behaviour via JS/TS in Rust is definitely something that I wanted to explore too. If you haven’t already you should check out these two articles from the Deno blog website which go a bit further: https://deno.com/blog/roll-your-own-javascript-runtime https://deno.com/blog/roll-your-own-javascript-runtime-pt2

I wasn't aware of a pt2, thanks for the link.

[deleted]

Re: Running JavaScript in Rust with Deno: Experimenting with Deno's Rust Crates

#12
post #3

Being able to allow custom behaviour via JS/TS in Rust is definitely something that I wanted to explore too. If you haven’t already you should check out these two articles from the Deno blog website which go a bit further: https://deno.com/blog/roll-your-own-javascript-runtime https://deno.com/blog/roll-your-own-javascript-runtime-pt2

> Being able to allow custom behaviour via JS/TS in Rust I understanding wanting to call out to Rust from JS/TS, but I don't think I understand wanting the reverse. Isn't a major goal of Rust not to have "custom behavior" that is invisible to the compiler?

I'm trying to build a view rendering engine / perform SSR straight on Rust with that

Re: Running JavaScript in Rust with Deno: Experimenting with Deno's Rust Crates

#13
post #12
post #3

Earlier quoted context omitted.

> Being able to allow custom behaviour via JS/TS in Rust I understanding wanting to call out to Rust from JS/TS, but I don't think I understand wanting the reverse. Isn't a major goal of Rust not to have "custom behavior" that is invisible to the compiler?

I'm trying to build a view rendering engine / perform SSR straight on Rust with that

Why not transpile Rust to WebAssembly directly?

Re: Running JavaScript in Rust with Deno: Experimenting with Deno's Rust Crates

#14
post #3

Being able to allow custom behaviour via JS/TS in Rust is definitely something that I wanted to explore too. If you haven’t already you should check out these two articles from the Deno blog website which go a bit further: https://deno.com/blog/roll-your-own-javascript-runtime https://deno.com/blog/roll-your-own-javascript-runtime-pt2

> Being able to allow custom behaviour via JS/TS in Rust I understanding wanting to call out to Rust from JS/TS, but I don't think I understand wanting the reverse. Isn't a major goal of Rust not to have "custom behavior" that is invisible to the compiler?

Some applications use Lua for configuration: neovim, conky, awesome, etc.

I haven't looked into the details of this so I'm not sure if its a suitable replacement for embedding lua (binary size would be my first concern..does this embed v8?) But I would much prefer TypeScript as a configuration language than Lua.

Re: Running JavaScript in Rust with Deno: Experimenting with Deno's Rust Crates

#15
> Data pipelines (eg Apache Airflow) where the orchestration is handled by Rust but the high-level business logic is defined using JavaScript

That is ... exactly what windmill is https://github.com/windmill-labs/windmill

The orchestrator is built from scratch in rust using postgresql to store the state. The steps when in typescript are run in deno: https://github.com/windmill-labs/windmill/blob/main/backend/... and the transforms between the steps (piping outputs of any node to the input of any node) are actually javascript expressions run by deno JsRuntimes: https://github.com/windmill-labs/windmill/blob/f3ec9ca09dc37...

Re: Running JavaScript in Rust with Deno: Experimenting with Deno's Rust Crates

#16
post #7
post #4

Earlier quoted context omitted.

Imagine you are building a game in Rust where players can write mods. Those mods could be written in JS/TS while the game is written in Rust.

It of course doesn't need to be a game. VBA macros in Office and AutoLISP in AutoCAD are two examples of scripting environments on large compiled applications that allows users to customize and automate behavior, outside of gaming. Hell, you can point at Emacs and vim as examples too.

I wonder about Helix plugins.

Re: Running JavaScript in Rust with Deno: Experimenting with Deno's Rust Crates

#17
post #13
post #12

Earlier quoted context omitted.

I'm trying to build a view rendering engine / perform SSR straight on Rust with that

Why not transpile Rust to WebAssembly directly?

SSR is the process of generating the HTML and CSS necessary to render a web page on the server side before it's sent down the wire. You can't just pipe wasm to the client to get the same effect. Besides being less efficient than JS at manipulating the DOM, the idea is that everything is already available and streamed to the client for optimal render speed.

Re: Running JavaScript in Rust with Deno: Experimenting with Deno's Rust Crates

#18
post #3

Being able to allow custom behaviour via JS/TS in Rust is definitely something that I wanted to explore too. If you haven’t already you should check out these two articles from the Deno blog website which go a bit further: https://deno.com/blog/roll-your-own-javascript-runtime https://deno.com/blog/roll-your-own-javascript-runtime-pt2

> Being able to allow custom behaviour via JS/TS in Rust I understanding wanting to call out to Rust from JS/TS, but I don't think I understand wanting the reverse. Isn't a major goal of Rust not to have "custom behavior" that is invisible to the compiler?

Business apps can sometimes be so complicated that the decision is between having a giant settings page, where you try to anticipate everything users will want to do, or you let them write little snippets of code that you interpret on the fly. I like the latter approach a lot, because even if I have to help write the snippets, it’s easier than shoving special-case code into the project, yet again, and deploying.

Re: Running JavaScript in Rust with Deno: Experimenting with Deno's Rust Crates

#19
> the release build of js-in-rs is 54 MB, grep is 179 KB, and a basic hello world JS application compiled using Deno is 103 MB.

OMG. That's ridiculous.

Write the code in C or Zig, and use Lua for scripting, and you're down to under 1MB for the final binary.

Post reply on HN