Hacker News new | ask | show | jobs
by lewisjoe 394 days ago
ELI5: Why not use typescript and an embedded v8 engine or deno to run them? What kind of advantages will I miss if I go for typescript as an embedded language for my application?

Also by using v8, I open up new possiblities via wasm (write in any lang and run it here?)

Will be helpful if somebody enlighten me.

5 comments

Be warned that V8 is a behemoth and adds 100+MB to your binary size, is quite slow to link, and is not practical to compile from source for most projects. If you want a lighter weight JS runtime there's quickjs, if you want WASM there's wasmtime.

Personally I don't think it's a good choice for what it seems Roto is used for (mission critical code that never crashes) since TS doesn't have a sound typesystem and it's still very easy to fuck up without additional tooling around it.

There's also Duktape for just JS minus the WASM (at least I don't think they've implemented WASM yet).

https://duktape.org/

I think QuickJS wins over Duktape for ES5 compliance, though it's been a few years since I was evaluating embedded JS. They're both extremely easy to integrate into an application, in contrast to V8
Fair, I'm not quite as familiar, but always like to bring up alternatives in case they're helpful. My favorite HN comments lead me to new alternatives for programming.
Roto is a very limited scripting language with no loops. You might compare it with the eBPF language used to load filters into the Linux kernel.
You are comparing a general purpose scripting language (TypeScript) to a DSL (Domain Specific Language) essentially. They built theirs with a specific purpose.
Why would I want to bundle an entire JS runtime? And why do you think you need that for WASM?

And personally I will go out of my way to not use TS/JS if I can

sounds like it's not fast enough for their use case. plus, have you ever tried to integrate v8 into a project? Deno is fine for building binaries, but to date doesn't really have good support out of the box for bundling a script into a library, which this application seems like it would need.