Dino is a free and open-source JavaScript runtime built on Google's V8 engine, Rust, and Tokyo. It's designed to offer a more secure and standardized alternative to Node.js, with native TypeScript support. Dino 2.0 just released, and it's a significant update, focused on improved compatibility with Node.js and addressing developer feedback. Some of the key features are backwards compatibility with Node.js and NPM, native support for package.json and Node modules, and a stabilized standard library. Luca Castanato is a software engineer for Dino, and he spoke about the project on Software Engineering Daily in 2023.
We're excited to have Luca join the show again to talk about the many changes introduced in Dino 2.0. Kevin Ball, or KBall, is the Vice President of Engineering at Mento and an independent coach for engineers and engineering leaders. He co-founded and served as CTO for two companies, founded the San Diego JavaScript Meetup, and organizes the AI in Action Discussion Group through Latent Space. Check out the show notes to follow KBall on Twitter or LinkedIn, or visit his website, kball.llc. Luca, welcome to the show. Hey, thanks for having me. Yeah, absolutely. Excited to have this conversation. Let's maybe start. I know you've been on the show before, but maybe reintroduce yourself to our listeners, who you are, your background, and what your role is with Dino. Yeah, so I'm Luca Castanato. I work on Dino. I've been at the Dino company for four years, working on all kinds of stuff there. Initially, the website, documentation. Then I moved into working on the open source runtime. I then spent a year and a half leading our Dino deploy team.
That builds our cloud product. And now recently have worked more on JSR and our new JavaScript registry. Well, yeah, not really Dino's project, but something that we've initially worked on. And then, yeah, Dino 2 most recently, getting that release tripped. So let's talk about Dino 2. What's in it? What's in the box? What makes this a major release? Yeah, so Dino 2 is Dino's, like, we're ready for enterprise release. You can use Dino. So Dino's existed for, I don't know, I think we did it 1.04 years ago, if I recall correctly. It was in 2020, May.
19th? I don't remember. But it's been a while. And since then, we got a lot of feedback from people that Dino has a pleasure to use, and they're really enjoying it, and it has a bunch of built-in tooling, which it does. But there was also a lot of feedback that was things along the lines of, oh, I can't use this at work because I have a giant node project that I can't move to use Dino overnight. And that makes sense. So we spent the first four years trying to figure out, where's the ideal? What do we want to go to? How should the ideal JavaScript world look like? And then over the past year and a half, two years, we've been trying to figure out how do we make this work in a way that...
existing users with existing projects and existing frameworks and existing libraries can adopt Dino in an incremental way. And Dino 2 is the release that does that. You can create an XJS app on your computer and run it in Dino, and it works. With no changes needed, it just works. But you still get access to all of Dino's built-in tooling, like the linter and the formatter and the test runner and the coverage reporting and all that kind of stuff, the language server. But yeah, you can do this on existing projects. You don't have to create a new Greenfield app to get started with. So that's really what Dino 2 is all about. Got it. So I know a few of the things that...
were making it a challenge to adopt because I also looked at it back in 2020 and I said, this looks really cool. And also I could never pull this in. But do you want to like maybe spell out what were the pieces that weren't there if you were using it before and that now if you come to Dino 2, they'll just work? Yeah, absolutely. So one of the biggest things that Dino 1 didn't really do is node modules support. So the node modules folder and NPM packages. So Dino has its own API surface that is modeled more after web APIs than after node APIs because web APIs are generally more modern, right? They use promises and async await and like iterators, these kinds of things and not like legacy node streams. And a lot of those things, unfortunately,
are new, and thus there's a lot of old code that can't use them because they're using Node APIs. So one of the things in Dino too is we added support for all the built-in Node modules. So think of like NodeFS, Node Crypto, Node, I don't know, V8, Node VM, Node Inspector, all these things that you can require or import into your code. Dino just implements them out of the box now with exactly the same API surface as Node, which means that if you have existing libraries that are written against those APIs, you can just use them now. So that was the first big part. And then the second big part was the ability to understand Node modules. So Dino in Dino 1 has...
an ability to load external modules, obviously, but it doesn't really use NodeModules because we considered NodeModules to be sort of clunky. You have to set up a package JSON. You have this folder in your repository that you need to deal with. You have a bunch of different lock files. You have four different package managers you need to choose from. It gets very complicated very quickly. So we had our own module solution that is based on web standards, based on HTTP imports, and more recently on JSR. But yeah, so in DDo2, you can now also just import any NPM package. We understand your local NodeModules folder. So if you want to move over to this like...
pure future where you don't have to deal with lock files and node modules folders on your disk you can but by default we understand those out of the box now and then the third thing is you know now has like a lot more package management built in previously users may have used like import maps you know which is a web standard to help manage dependencies but now you know supports package json and it can like create your modules folder from your package json so it like has the npm install functionality baked in we can read things from your private npm registries things like that so it's yeah really a lot of things that just make it easier to pick, you know, up and stick it into your existing project and just have your existing project work. Yeah, it's kind of the plays nice with others release in some ways. Exactly. Yeah. I'd love to dig into a few of those pieces. So one, you mentioned sort of support for some of these built in node modules and node APIs. And I'm curious, like, how do you see the evolution of server side JavaScript runtimes? Like, is there a server side standardization effort? Because browser APIs, everybody's trying to agree on what those look like server side.
What is that story? Yeah, that's a fantastic question. The answer to that is something called WinterCG, which is an effort that Cloudflare and Dino and some folks from Node.js as well, some of the runtimes, joined up to create a community group within WhatWig a couple of, I guess it must have been two years ago at this point, to try to figure out what is the common subset of APIs that all these server runtimes should have. And currently, a lot of this common denominator is Node APIs, but really, in the limit, I don't think the world really wants to continue using, like... node fs apis that were designed in 2008 right like not a great time so we're trying to figure out there two things what web apis are there that should work in servers and how should they work so take like fetch or the web crypto api and then the other thing is what features are there not web apis for that should work in service at runtimes interoperably using modern apis i think for example of tcp sockets or like things how to read your environment variables or arguments past your script things like that right so those are another part that winter cg is trying to figure out like what is a common api that we can use here And we're like an open community group in the W3C that anyone can join. And like sort of, yeah, we have contributors from all over trying to figure this out. And what would you say the sort of state of maturity is there? Like, is this something that all the runtimes are already kind of in line with? Or are we still hashing out and trying to get to some sort of consensus at all? So different parts are different levels of maturity. I think we have collectively agreed, like what the baseline set of APIs is that everyone implements, like everyone implements fetch now, everyone implements response, request, headers, web crypto broadly as well, maybe more obscure APIs like A to B, B to A, sort of things like that. We've collectively agreed on those.
On the APIs that are like novel APIs that are not web APIs, I think there's more work to be done there. We don't have any release standards yet, nor has anybody implemented them. I think the closest thing we have is the Sockets implementation in Cloudflare Workers, which is sort of going in the direction of sort of where we want the WintersCG socket API to go. But yeah, this is still very much something that is going to take a year, maybe longer, to develop into something that can be actually shipped across runtimes. And like a lot of this is not even just designing the API, but it's also like writing tests to make sure that it works interoperably everywhere.
And then obviously like getting user feedback, talking with all the database connection library authors, like think of your PSQL, like Node Postgres or like MySQL or I don't know, those kinds of things to then go and actually adopt them in their libraries, right? That's the step after that. So yeah, more work to be done, but yeah, we're making progress slowly. It's standards after all. Absolutely. Well, and it's a measure of maturity that that working group exists at all. Absolutely. It means that we're more likely, I think, to see evolutions and more people trying to create these runtimes. Where do you see the sort of...
dimensions of competitiveness in runtimes why would someone choose a dino versus a node versus bond versus worker d versus whatever yeah i think part of it is obviously like worker d for example you can't use worker d unless you're running on cloudflare makes it very easy if you want to develop for cloudflare use worker d because that's your only option and if you're not developing for cloudflare you don't use worker d because you can't use it right but between these other ones i think it's a lot more nuanced it's like broadly there's a lot of things that are very similar across them i think one thing that's wildly different at this point is stability like you know and node have been out for a long time we've like the first commit to dino was i think six years ago at this point all the bugs that we get are like things that we've done recently. It's not old features. All the old features, they work perfectly fine at this point. They're stable. Another one is tooling. Node has some tooling within, but it's much less than, let's say, Dino. Dino has a built-in format and a built-in linter. It has benchmarking tooling. It has a built-in language server. It has TypeScript support out of the box. I could go on about this. It has compiling to a single executable. We've had that for nearly four years at this point.
So I think that's a lot of that. And then the other thing is like, are there things around it that would entice you to use one runtime over another? So for example, are there libraries that you would like to use that favor a particular runtime? Or are there frameworks that favor a particular runtime? For example, like if you want to use Fresh, which is a web framework that Dino has been working on, you probably want to use Dino because that's what it was built for. But yeah, conversely, I don't know if you're using Elysia, that may be something you want to use fun with because that was built for that. But yeah, really, I think, I don't know, I'm going to use Dino, but I'm also biased. So everybody make up your own mind, try out things. They're all so easy to use now. Totally. Well, and one of the things that you alluded to there, which is a kind of perpetual question in the JavaScript.
ecosystem is like the extent to which you get everything together in one. Dino bundles a lot of pieces together for you versus are you doing mix and match and are you making your own choices on all those different pieces? I'm kind of curious how Dino approaches this question of what should be bundled with the runtime versus what belongs in user space. Yeah. So the inspiration for why Dino has all these things built in is not the JavaScript ecosystem. Surprise, surprise. It's the Go ecosystem, the Rust ecosystem. These are languages. Go was released, I think, the same year as Node.js. But unlike JavaScript, it has a bunch of built-in tooling in its tool chain when you install Go. It has a built-in formatter. It has a built-in linter. It has a built-in package manager. It has all these things that sort of come right out of the box. And it turns out that people really, really like this. If you ask people what is great about using Rust, one of the top answers is going to be, like, it just works out of the box, right? Like, I can have a GitHub ActionScript that installs Cargo, and then that...
comes with a formatter and a linter and a testing framework and a benchmarking framework and a package manager. And it compiles my code and all that kind of stuff all at once. And that's really what we were going with, with having all these things in Dino natively. I think the question of what do we actually decide to include is, what do we think we can do well? Formatting, we think we can do very fast, very good formatting. So that's something that we built in. We think we can do the same for linting, testing, benchmarking. In Dino 1, we had a bundle subcommand that would take your JavaScript code or TypeScript code and bundle it into a single file. But we realized that this was not
where we wanted it to be. Like bundlers are incredibly complicated and we did not think that we could at this time at least offer a competitive bundler built into Dino. So Dino 2, we removed it because we don't want to ship like something that's sort of half-baked and doesn't really work very well. We want to ship things that like you can rely on them, right? Like you don't have to think about whether you should use them or not. You can just use them because they work, they're stable. And our bundle was not that. So yeah, we removed it. But other than that, I think, yeah, things that we think we can do well, those are things that we'll include. Yeah, things you can do well. And you mentioned a little bit the simplicity piece, which reminded me of, I was looking at, I think it was a release YouTube video you all did where you were really going after Node.
around simplicity. I'm kind of curious, like, as you absorb more and more pieces to be able to be enterprise ready or plug and play, how are you approaching sort of keeping the experience simple? Yeah, I think the biggest part of that is having good defaults, right? Like our defaults are, take, for example, TypeScript. When you set up a TypeScript project in Node, you don't just have to open a file and write some TypeScript code in it. You have to set up a TS config file and you have to make like 18 decisions, right? You have to decide, do I want strict mode on or off? What libs do I use? What version of types Node do I use?
There's an endless amount of configuration that you have to do before you can write the first line of code, which makes things very not simple. Because that means between two projects, even in the same company, you can have wildly different configurations. And before you can start reading code, writing code, you first have to go look at all the config files to see how this project is set up. That is one of the things that Dino completely eliminates. We have a config file that you specify dependencies in if you want to. You don't have to. You can. And other than that, you don't have to have anything in there for a standard project. You don't have to set up your TypeScript config. There's a default TypeScript config that all Dino projects use that is all the options you should use, not the options you shouldn't use.
We've made this decision for you. Don't worry about it. The other part of it is if there's parts of Node that we sort of need to put into Dino for backwards compatibility, we try to shield you from them if they're bad in some way. We don't, for example, encourage you to write CJS code in your project. We encourage you to write TypeScript code with ESM. And that doesn't mean you can't use CJS. You can, but we very actively steer you in the direction of using ESM to sort of adopt modern tooling, use libraries that are actively maintained and not outdated. We have a lot of documentation that tries to guide you to do things in modern ways.
Like all of our documentation on if you look up like how to make an HTTP request from Dino, it's going to show you how to do with fetch, not with node HTTP, because that's the future, right? Using fetch, not using node HTTP. A lot of things like that just make things much simpler. Yeah. You sort of alluded to this when you talked about the TypeScript versus CJS, but I'm curious. So a lot of very opinionated frameworks will provide you an escape patch where they say, we're going to have these defaults for you. We highly recommend you go with it. But if you really have some strong reason to change it, here's how you do that. What does that look like in Dino? Yeah. I mean, we, for many things, have that same option. There's a, like, as I said before, we really want you to write ESM and TypeScript, but you don't have to. You can write a .cjs file and you can write a, like, .
JS file rather than a TS file, if you want, and we'll let you do that. And if you really want to turn off, like, I don't know, trying to think of some obscure TypeScript option, no implicit any, I don't know, you can go into your Dino config file and find the place to turn that off. But you shouldn't. It's therefore like you're migrating an existing project and you temporarily need this for a moment, but stop. Don't do it. Stick with the defaults. Don't do that. Bad. But that is really important for migrating legacy stuff because you never know what you're going to run into there. Yeah, no, absolutely. And I mean, that's really why we've added a lot of these escape hatches in Dino 2. Dino 2, for example, has the ability to work both using a local node modules folder that was created by Dino.
work with local node modules folder that was created with like npm or pnpm or yarn or work with our global node modules folder where you don't see the node modules folder at all because it's like hidden in a cache directory somewhere and the default is to use the global one because that's nice and clean and you don't have to deal with it but sometimes if you're like in a existing project that has a complicated pnpm workspace or like a yarn workspace with yarn resolution plugins or I don't know crazy things right crazy big project with weird configuration Dino will just accept that and it will work with your existing node modules set up node modules folder that was not set up by Dino as a escape hatch and at some point if you decide okay I'm all in on Dino, you can like start making that move, right? You could like switch over from Yarn workspaces to Dino workspaces and then have Dino install your Node modules folder and maybe eventually completely get rid of all your local Node modules folders and just have a global one. But it's not something we force you to do right away. You can sort of adopt it incrementally and then over time move to this nice pristine world of Node modules folders. Can you tell I don't like Node modules folders? I can't. Well, and let's talk a little bit about modules and registries and things like that because another big thing that came out this year was, or at least that I saw an announcement about this year, was JSR. What is that? Why is that? And how does that interact with Dino? Yeah, so...
I mean, the reason Dino was created initially was Ryan Dahl, the creator of Node, came back to Node after 10 years and thought, OK, this has gotten too complicated. And I mean, a similar thing happened with NPM. So NPM is obviously Node's package management system where you publish your packages. And there's been a lot of innovation on the client side, the package manager side of this. We initially had only NPM. We got Yarn. We got PNPM. There's a bunch of other tools that will also let you install NPM packages faster, better, more securely, whatever. But we really didn't have anybody that was pushing NPM the registry. If you look at NPM the registry...
They really haven't changed in 10 years, right? The last major change they did was added a little TS icon in the top left to packages that have type definitions. And that was, what, like three years ago? And then they have a files tab that's been in beta for probably also three years that when you click on a file, it doesn't put the file in the URL, so you can't link to it. You can tell that there's not been a lot of active investment in NPM. So that's what JSR is about. JSR is a new package registry, so the server-side part of the packaging story, where you can publish your packages to.
And JSR natively supports TypeScript. JSR packages can import from NPM. They can be imported by NPM packages. But yeah, they natively support TypeScript. They have built-in documentation generation. They have a much more secure publishing flow that uses OIDC on GitHub Actions to sort of prevent people from accidentally leaking private access tokens, which is, yeah, supply chain security. I'm sure many people are worried about that in the JavaScript space. It's really a head-on attempt to try to fix all the things that NPM hasn't done in the past 10 years. But yeah, doing it in a sort of backwards compatible way where you can import JSR packages from NPM and import NPM packages from JSR.
so that these things can work together and it's not like a stop the world and migrate sort of thing. It reminds me a lot of Pika, which I don't know if that project ever went anywhere, but I remember talking with Fred K. Schott or listening to a podcast with him trying to do this, where at least in that world, part of it was trying to push to being ES modules first. And it sounds like with JSR, similarly, you're pushing for TypeScript first. Yeah, like JSR is very much TypeScript first, JavaScript supported by TypeScript first, and then ESM only. So you cannot publish CJS to JSR, for example. We've made a hard cutoff, like stop CJS development instead, ESM only going forward.
And that allows us to do incredible things that you could never do if you have to do with CJS and ESM and not TypeScript, like documentation generation. The fact that for every package that is published to JSR, we can automatically generate documentation for every symbol, for every export in your package. It's huge. It's like Rust has had this for 10 years, Go has had this for 10 years. And in JavaScript, we've never had this because NPM didn't implement it. And it's not an open source project. So nobody can implement it for them, right? It's like a closed source, private thing that GitHub is keeping alive.
And JSR is different. It's an open source project. It's hosted by the Dino company, but really it's a very open project where you can contribute things. And if you want to have a new tab on the package page that shows you some cool new information, submit PR, right? It's not behind a locked door and you need to become a Microsoft employee first. Yeah. So you mentioned that you can install NPM packages with JSR. How do you deal with NPM packages that were not TypeScript, for example? Are they not installable via JSR or like, how does that work? Yeah, so...
NPM packages, you don't install NPM packages through JSR or JSR packages through NPM, but rather they're complementary in the way that NPM packages can rely on JSR packages. They can depend on JSR packages, and JSR packages can depend on NPM packages. But ultimately, it'll be your package manager, like PNPM or Yarn or even NPM itself, that pulls the JSR packages from JSR and the NPM packages from NPM. And this is just done through, you can think of JSR as a private registry of sorts for NPM if you're using NPM. And that way, you can use all existing NPM packages, whether they're TypeScript or not. But you only get the features, the documentation generation, for example, if you're actually publishing to JSR. So if you're publishing your TypeScript source code to JSR. That makes sense. You mentioned documentation generation. You mentioned some of the supply chain security. Are there other benefits of going to JSR over NPM? Yeah, it's a lot simpler. I mean, at least in my opinion. You can create a package by, like the simplest package is a single TypeScript file and a JSR.json that has a name, a version, and an exports field. And the export field is just the path of your TypeScript file. And that's it, right? There's no TS config to set up.
Very important, you publish the TypeScript. You don't have to publish the JavaScript plus d.ts files. No, you publish the TypeScript. So you can publish a new package in a couple minutes rather than having to go through and set up the configuration and make sure that it works across CJS and ESM and all these things, right? JSR just handles all that for you. So I think a lot of it is really it makes your life a lot easier if you don't have to deal with all this configuration. Kind of a recurring topic. Recurring topic. Well, is that showing up anywhere else that we haven't talked about yet for this? Yeah, sure. DinoDeploy, we can talk about that very briefly, is our cloud hosting product.
Same sort of deal, right? You can write your JavaScript code, put it in a GitHub repository, and just link it to DinoDeploy. And it deploys, and you don't have to dual configuration. A lot of the things that we do at Dino are like this. Our linter is like this. You don't have to configure your linter. You don't have to configure your formatter. You don't have to configure your tests. You don't have to configure your editor. You don't have to configure your package manager. It just works out of the box. And you can tweak it if you want to, but don't. Just stick with the defaults, because the defaults are pretty good. Speaking of DinoDeploy, and I think one of the interesting things that you all have is you have this dual identity as open source.
projects, multiple JSR, Dino, all these different things, but also for-profit company. And I think one of the challenges going back to NPM that they faced is when they started running out of money and then Microsoft absorbed them and then stasis ensues. So how is Dino making itself sustainable here? Yeah, I think the answer is different for different parts of Dino. I'll start with JSR. So with JSR, we don't want JSR to be a Dino product. And really JSR is not a Dino product. It just happens to be developed by a bunch of Dino developers. But that's beside the point. Like really JSR is going to go into a foundation at some point.
We don't have all that settled yet, but it will go into foundation at some point. It's going to be a community project that is owned by the JavaScript community as a whole that does not have a single point of failure, right? The general company fails, JSR is not going anywhere. Not that the general company is going to fail. We're going to do great, but... It's always worth having that escape path, right? Because you never know what will happen. Yeah, exactly. And I think it's also really helpful for a foundational part of the ecosystem, like a package registry, to not be owned by a single entity, but instead be something that can be shared across many different foundation members, right? Something that can be governed in an open way.
But to go back to your original question, like how has the Dino company itself remained sustainable? I think that's also a great question because I think we've seen in many open source projects, like Redis, for example, recently, that this can go wrong really quickly if you're not careful. And I think the way to avoid this is to sort of have a solid idea of how the company is making money versus how the open source runtime is operated. And for the Dino company, we do not make any money off the open source runtime, right? There's no like pay to play features in Dino. There's no like multi-cluster networking mode that you can only enable if you pass a Dino token flag with a...
secret key or something. No, this doesn't exist, right? The Dino runtime is completely open. And then the Dino company makes money through hosting. We do consulting for enterprises, but also we do hosting. And the hosting is, for example, things like Netlify's edge function product is under the hood, all Dino systems, right? It's built on the Dino runtime, hosted by us for Netlify. And there's other companies like Deco CX, which is one of the fastest growing e-commerce platforms in Brazil that are running their entire infrastructure on Dino. And these are the ways we're going to make money and we are making money, right? These are...
different from the open source runtime. There are ways that we can monetize the use of the open source runtime, but not monetize the open source runtime itself. You know, it's not like an, not going to be an open core thing where you have like an open core and a paid sort of set of enterprise features around it. But yeah, you have an open source runtime that is free to use MIT license. You can do whatever you want with it. And then we happen to offer hosting. And with that, we finance the continued development of the open source runtime. Do you see a world in which Dino itself moves into a foundation?
I mean, everything's possible. I don't envision that happening right now. I think the way the model works right now is pretty good. I don't think there's any governance issues within Dino right now that would be solved in any way by moving into a foundation or anything like that. I think we work very well. We ship features on a very regular cadence. Bugs get fixed. I'm not worried about that. But I mean, yeah, it's obviously always a possibility that things change in the future. So maybe, I don't know. But also Dino's open source MIT license, right? If you ever don't like something that we're doing, there's this big button in the top right of all GitHub. It's called Fork. Yeah, absolutely.
What does the future of Dino, the open source runtime look like? What types of features are you working on? What are you excited about? Yeah, so a bunch of stuff. I think initially, the first couple of months, we're going to be preparing for our first long-term support release, which is another thing that we announced with 2.0, which is coming in about a month. And we're just going through all of the issues that are being reported after 2.0, right? Major release, and people have tried with the weirdest node projects that you could possibly imagine, and there's edge cases that we need to fix. So we're going to spend a couple months working on that, but we're also going to be working on new features to Dino itself. I said that we removed the bundler from Dino 1 because we didn't think it was good enough.
We're thinking about how we can add that back in a way that is actually competitive, right? Where it is not like terrible, but it is great. And it's something you can actually use for your systems. And other than that, obviously, we're increasing or improving all of our other tooling all the time. We're looking into how to do plugins for the Lynter right now. We would love to work more on some performance work. Like our HTTP server, for example, is already twice as fast as Node, but we still think there's room to grow. We're looking more into how we can make it easier to adopt, you know, in enterprise environments where you may be using like Kubernetes or something like that, how to integrate it with tracing and telemetry. These are things we're thinking about.
But yeah, I mean, our issue tracker has like 1,800 open issues right now. So yeah, we're not going to run out of work anytime soon. Speaking of that and the fact that it's open source, how much of the development is done in-house versus how much of a sort of community development team is there? Yeah. So I think the majority of the work is done by Dino, by Dino employees. We're a company of, I want to say 25 at this point, where maybe half of them work pretty much exclusively on the open source runtime.
But there's also a lot of people that have been contributing to the Dino Standard Library, which just went 1.0 as part of the Dino 2.0 launch, that have been contributing to the permission system in Dino, that have been contributing to help output to documentation. If you look at our release blog post, there's always a section at the bottom of the blog post that's thanking everyone that's contributed to the release. And yeah, they get longer every time we do a release. So I'm very happy about that. For folks who are interested in getting involved in that, what does the dev environment look like for working on Dino itself? Dino is built in Rust. So it's actually very easy. You just check out the repository and run Cargo Build. Also have to install Rust first.
But I mean, other than that, it's pretty easy. There's a lot of Deno, though, that's not written in Rust. I know Rust can be a bit of a challenge for many people because it's a completely different language to JavaScript. But a lot of Deno is actually written in JavaScript. A lot of our web APIs are implemented in JavaScript. Essentially, anything that's not native IO is implemented in JavaScript. And there's always things to do there in our node compatibility. A lot of things are implemented in JavaScript as well. Our standard library, which lives outside the Deno runtime but provides a bunch of utilities that any JavaScript project can use, including non-Deno ones, that's written entirely in TypeScript as a Deno project published to JSR. That's also something that's super easy to contribute to, but obviously our docs as well.
Always love docs work. We have an example site that you remember what the URL is. I think it's docs.dino.com slash examples, where currently we have a thing where I think you get some free stickers for every example that you write or a shirt. I don't remember. You have to check our Twitter. I think it's announced there somewhere. But yeah. And then also we have a Discord. So if you have questions about contributing, you can always hop on there and ask questions. And there's members of the team that are there to help you and help answer questions. So actually, first clarification question. So you mentioned, you said, Russ, you have...
JavaScript, not TypeScript for some other portions of it, and then TypeScript for the standard library? Yeah, so the standard library is all written in TypeScript. Do you know runtime is written partially in JavaScript, partially in TypeScript, and a lot in Rust. What's the reason for not having it all in TypeScript? Historical reasons, mostly. When we started out, it was, so one of the challenges here is that we don't really want to rely on a JavaScript runtime to build a JavaScript runtime, right? You don't want to have a circular dependency because that means you can't build on new platforms. But that also means that you cannot use TSC to compile your TypeScript because TSC is written in JavaScript. So if you don't have a JavaScript runtime, you can't.
transpile your TypeScript with TSC. And when we started out with Dino, there was not really any good way of transpiling TypeScript to JavaScript that was not TSC. Remember, this is like six years ago. So now, that's no problem. Now we have TypeScript transpilation in Rust, and we can do that all natively, which is why we now have some parts of the code that are written in TypeScript and are being transpiled to JavaScript during the build using Rust. But a lot of the code that was originally written six years ago, four years ago, three years ago, just didn't have the luxury of having a Rust TypeScript compiler yet that we could transpile with. So those had to be written in JavaScript because we just didn't have the ability to transpile as part of the build pipeline.
Yeah, we can't have circular dependencies on the JavaScript runtime, unfortunately. That makes sense. And how do you all decide what's happening in Rustland versus what's happening in JS slash TS? It's mostly a question of like, do you need Rust to do it? That's step one.
native io talking to the kernel about sockets or files or i don't know file watching all those kind of things you can't implement a javascript runtime on top of a javascript runtime because something needs to expose like the kernel sys calls for opening a file or something like that to javascript in the first place right and that's rust that's what rust is for us a lot of our module loading our types of transportation our linter and formatter those are also written in rust on the other hand all of the sort of api surface that you touch so when you write dino.readfile the thing that checks whether the first argument that you pass is a url or a string and then dispatches it accordingly to the kernel that is done in javascript and like So you can sort of think of anything that requires native access or requires very high performance in some way, that's written in Rust. And everything else that's sort of the glue between the user and the native syscall, that's written in JavaScript. Our fetch implementation, for example, is written pretty much entirely in JavaScript, with the exception of the thing that actually sends the network request out. But all the handling around how streams work and how headers work and what a response body is and what a request body is and all those things, those are all implemented in JavaScript or TypeScript. That makes sense. And are there...
When you cross that boundary, when you're going back and forth, do you have to copy all of your data over? Or are you able to expose data that's living in JavaScript language directly to the kernel? How heavy is that boundary? It really depends, honestly. I can go into a lot of detail here, but I think generally it is faster to call between two JavaScript functions or to call between two Rust functions than it is to call from JavaScript to Rust. That's a blanket statement. The reason for this is strings, for example, are represented differently in JavaScript than in Rust. In JavaScript, they're WTF-16. In Rust, they're UTF-8. You need to convert between them when you call from one into the other.
Then there's also certain things like APIs, for example, that only deal with numbers or only deal with Booleans or deal only with certain types of strings. Those are essentially free. You can't see this if you're listening to the podcast, but I just like finger quoted me or I don't know what that's called, whatever. Air quotes? Air quotes. That's right. Yeah. So numerical things are essentially free to cross between JavaScript and Rust. But yeah, strings, objects, those are more expensive. And then when you get into things like array buffers, it really depends on, for example, is it a synchronous call? Is it an asynchronous call? Those have different costs. There's a giant matrix of like...
If you do this, it becomes very slow. If you do this, which is essentially the same thing, but slightly different, it becomes much less slow. So do this thing instead. This is one of the biggest things that our performance team has been working on for a long time is reducing the cost between JavaScript and Rust because we have like 800 different call sites. I think it's 800, yeah, between JavaScript and Rust. And if you can make all of those 1% faster, then pretty much the entire runtime has gotten 1% faster, right? And you've made a code change in one place, which is really cool. So we continuously make changes to, for example, how to transfer strings, how to transfer unit database, all these things. As an example, there's some work that we're currently doing that will make all transfers of strings from JavaScript to Rust essentially two times faster.
Across the entire runtime, every single API that deals with strings will have its overhead reduced by some amount, purely due to a single change in a single place. Two times is a lot. You're removing a copy somewhere or something like that? Pretty much, yeah. We did some work with Megalia, which is an open source consultancy, on upstreaming some changes into V8. They change how V8 exposes strings to embedders. That let us use these strings in a way that is more ideal to us. Previously, you always had to copy a string out of V8. Now, there's a lot of cases where you don't have to copy the string. You can just use the string as is while V8 retains ownership of the memory.
And this requires a long breath, right? This is where we started maybe in March, I want to say, or in February, and it's now showing fruit, but it's going to make everything faster. So it's really worth it. Talking about this boundary more, I know that Node has this whole like Node API standard if you want to build like native plugins or things like that. What does that look like in Rust if you want to connect to some sort of native written library? Or what does that look like in Dino? I guess it doesn't have to be Rust. The first way of doing it is to just use NAPI because actually Dino also supports NAPI because otherwise a lot of our, a lot of the Node packages wouldn't work. So as I said, like Dino 2.
needs to work with existing libraries, and a lot of existing libraries use an API, so Deno implement an API. That's step number one. An API is not ideal, though, in many ways. There's ways to do faster foreign function interfaces between JavaScript and a native API. So there's also Deno FFI, which is a way to do FFI with the standard C FFI interface. And there's some libraries, for example, there's a Deno SQLite library that uses Deno FFI that is twice as fast as the node library of SQLite that uses an API, just because it's using a different product.
boundary between the two, right? The JavaScript part and the REST part, and the native part are the same. It's just the call between them that changes. And yeah, that works pretty well. And it also works really, like our FFI stuff works really well with REST. I think there's some tools that one of my coworkers has written, which I think is called the DinoBindGen, that lets you write some REST code. And then during the compilation, it'll generate a file for you that you can import in Dino and a TypeScript header file that types your entire API essentially from JavaScript. You don't even have to deal with the fact that you're calling it to REST that just makes it feel very native. That is nice. Because I think, yeah, if you're doing a CFFI, you've got to...
make explicit what all those types are, but Rust has types, like should be able to take advantage of it. Yeah. Awesome. What else would you like to talk about today? We've got a few minutes left, but I think I've hit all of my big questions. We can talk about Fresh, which is our web framework. Let's do it. Yeah. So Fresh is a web framework that we've been working on for maybe a year and a half that is sort of slowly been slumbering over the last six months or so while we were working on Dino, but it's coming out of slumber mode and fully into Fresh to release mode. So for those who don't know, Fresh is a web framework that uses Preact under the hood. It looks somewhat similar to maybe like Remix or Next.js, if you're familiar with those.
So it has server-side rendering as a native feature. But what sets it apart from Remix or Next.js is the fact that we don't ship all of your JavaScript to the client. So in Next.js, the way that Next.js works is you do an initial server-side render, and then you send the entirety of all the JavaScript that was required to do that server-side render to the client, and you do the same render again on the client. I mean, that can be inefficient. Yes. The uncanny hydration valley. You run into it. Yes, yes. So Fresh doesn't do that. Fresh does server-side rendering only, essentially, in the beginning. And then you can opt certain components, so components one by one, into...
rendering on the client as well. And we call those islands. So you can think of these like as islands of interactivity and a sea of static content that was sort of server-side generated. And this works really well because it means you can have e-commerce sites that have an interactive cart, have an interactive add to cart button, have an interactive carousel, and everything else is static. You don't need to ship a markdown renderer to the client. There's a bunch of stuff you don't need to ship to the client, right? You get much faster first load performance. You drain your user's battery life much less because they don't have to execute a bunch of JavaScript they didn't need to. And yeah, fresh is like a very ergonomic way of doing this. You can create routes in a false system router.
thing, like routes folder, call a file index.tsx, and it gets rendered when you hit the index of the page, right? And to make something an island, you just put a component into the folder called islands, and now it's an island. It's all very simple. Sounds a lot like Astro. It has a lot of very similar principles to Astro. I think Astro and us sort of both did islands at roughly the same time. There's a couple of things that are different. Fresh is like very, would feel very familiar to people that have used Remix or Next in the past because it like leans very much into JSX, and it doesn't have its own file format. But that also means that you can't use like view components or spell components with Fresh. It's really pre-act only.
But yeah, I mean, all the web frameworks are the same nowadays anyway, so choose whatever you fancy. Yeah, I mean, this idea of sending less JavaScript, I think, has gained a lot of momentum these last couple of years. And so we have different takes on that, islands being one of them. So you said file-based routing, similar to how Next used to roll, though now they have their app router and all of that. You've got islands architecture. It looks like it's kind of signals-based. Is that correct? Yeah, we support pre-act signals out of the box. You can do things like create a signal on the server, pass them to two separate islands, and then when the islands rehydrate, the signals are still attached on the client. So the two islands can communicate with each other.
which is a very core part of how to make interactive applications where you have islands across multiple parts of the page. Supports TypeScript out of the box with no configuration. Obviously, it's a Dino project. There's a little bit of a trend here. Yeah, it's weird how there's no configuration thing. It keeps sliding in everywhere. But yeah, it uses Web APIs for its request and response objects. It integrates very seamlessly with Fetch. Works with other runtime frameworks besides Dino? Well, I don't know. Maybe if somebody wants to try. Fair enough. Nice. Yeah, that looks good.
And then in terms of, so any sort of React-based library that works with Preact should work with Fresh? Yeah, yeah. And you can use PreactCompat if you have some library that actually relies on React. You can just switch it out to use PreactCompat instead, and then it'll continue to work with Preact. Nice. And last question, I assume, like so many of these other things, it's fully open source. Absolutely. Yeah. You know, land slash fresh on GitHub. We're about to do 2.0 release. There's a roadmap. Please try it out and give us your feedback. Awesome. Well, Luca, this has been super fun. I feel like I have a few things to go and try out now, which is great. Anything you would like to leave people with before we say goodbye? If you want to try out, you know, we have a great new tutorial series on YouTube. If you're interested in learning.
Eve does a bunch of cool tech things. Check it out. YouTube.com slash DinoLand. Sounds good. Then we will wrap with that. Everybody try Dino because life is too short to be configuring things. All right. Cheers.