Categories


Archives


Recent Posts


Categories


How does Deno Use Rust

astorm

Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

Reddit is not my natural enviornment, but I occasionally hover around its various programming communities. This is a personal archive of an answer to a question about the Deno, the new “run javascript on your own computer” project.


I’m far from an expert in all the real details here, but I’ll give this a go.

Deno has not re-implemented the V8 engine in rust. Deno still uses the C++ code for the V8 javascript engine. A javascript engine in an important part of a system like deno or node, but it’s not the only part of a system like deno or node.

For example — as a javascript programmer, you may think of setTimeout as a part of javascript — but the code that schedules and manages all the different bits of javascript that you’ve asked setTimeout to run is not part of V8.

Another example — if you want your javascript program to open a file, the underlying code that open a file is not a part of V8.

Details on how node itself is built aren’t as abundant as details on how to use node — but this learning-nodejs repo has a decent introduction, and there’s lots of good details in this How Node.js Bootstraps Itself: 2019 Edition talk from Node Interactive 2019. The short version: In addition to V8 Engine — node itself gets a lot of its functionality from a plain C library called libuv, and a lot of C++ glue code maintained by the NodeJS project itself.

Deno’s manual has an architecture section, including a diagram at the bottom. Again, I’m far from an expert here, but based on this document it seems like the deno executable is a rust program. There’s something called libdeno that’s implemented in C++ (although I don’t see any C++ files in the repository, so I’m unsure what this is). Deno also uses the tokio project, which is (roughly) a rust equivalent to libuv. It also looks like the code for “io” (file reading/writing, printing things, etc), TCP Networking, and managing child processes is implemented via rust.

So your question, What Rust has to do with Deno?, is a good one, but it’s also a pretty broad one, and hard to answer succinctly (especially since I’m not a rust programmer) — but I hope this at least helps you get pointed in the right direction.

Copyright © Alana Storm 1975 – 2023 All Rights Reserved

Originally Posted: 8th June 2020

email hidden; JavaScript is required