Deno 2.0 with Luca Casonato

18 Dec 2024 · 47 min

Ask about this episode

Ask anything about it. ChatGPT or Claude reads this page and answers with the times it was said.

Connect VO and ask about every podcast you hear, including the moments you saved. Add to ChatGPT · Add to Claude

In short

Podcast Notes: Deno 2.0 with Luca Casonato

Episode Overview Deno 2.0 is a significant update to the Deno JavaScript runtime, focusing on enhanced compatibility with Node.js and addressing developer feedback. Luca Casonato, a software engineer at Deno, discusses the key features of Deno 2.0, the evolution of server-side JavaScript runtimes, and the future of Deno.

Key Takeaways

About Deno

  • Introduction: Deno is a free and open-source JavaScript runtime built on Google's V8 engine, Rust, and Tokio.
  • Goals: Aims to provide a secure and standardized alternative to Node.js with native TypeScript support.

Deno 2.0 Highlights

  • Backwards Compatibility:
  • Supports Node.js modules and `package.json`.
  • Allows usage of existing NPM packages.
  • Stabilized Standard Library: The standard library has been stabilized for better reliability.
  • Built-in Tooling: Deno offers integrated tools such as a linter, formatter, and test runner.

Developer Feedback and Adoption Challenges

  • Previous Issues: Many developers found it challenging to adopt Deno due to lack of Node.js compatibility.
  • Incremental Adoption: Deno 2.0 facilitates gradual migration from Node.js projects to Deno.

Evolution of Server-side JavaScript Runtimes

  • WinterCG: A community group effort aimed at standardizing server-side APIs across different runtimes.
  • Competitiveness: The choice of runtime (Deno, Node, Bun, etc.) depends on factors like tooling stability, library support, and specific use cases.

Deno's Approach to Bundling and Configuration

  • Go and Rust Inspiration: Deno's built-in tooling is inspired by Go and Rust ecosystems, emphasizing a simple developer experience with good defaults.
  • Configuration: Deno aims to minimize configuration hurdles for developers (e.g., no need for `tsconfig` for TypeScript projects).

JSR (JavaScript Registry)

  • Overview: JSR is a new package registry aiming to improve upon NPM by supporting TypeScript natively and offering built-in documentation generation.
  • Community Effort: JSR is designed to be an open-source project governed by the JavaScript community.

Fresh Framework

  • Introduction: Fresh is a new web framework built on top of Deno, utilizing Preact for server-side rendering and offering an islands architecture to reduce client-side JavaScript.
  • Simplicity: It has a straightforward file-based routing system and supports TypeScript out of the box.

Future Directions for Deno

  • Long-term Support: Preparing for the first LTS release post-2.0.
  • Tooling Improvements: Ongoing enhancements to existing tools and potential re-introduction of a bundler.
  • Community Contributions: Encouraging community involvement in documentation and feature development.

Final Thoughts Deno aims to simplify the developer experience in building JavaScript applications while ensuring robust support for existing Node.js projects. The innovation through JSR and tools like Fresh demonstrates Deno's commitment to enhancing the JavaScript ecosystem.

Additional Resources

  • Deno Documentation: [Deno Documentation](https://deno.land/manual)
  • Deno GitHub Repository: [Deno on GitHub](https://github.com/denoland/deno)
  • Fresh Framework: [Fresh GitHub Repository](https://github.com/denoland/fresh)
  • Deno YouTube Channel: [Deno YouTube Channel](https://www.youtube.com/c/DenoLand)

---

This structured summary encapsulates the main discussions from the podcast episode, making it accessible and informative for readers interested in Deno and its updates.

Written by AI. May contain mistakes. Listen to the episode to check what was said.

Hear the part that matters, and keep it.Open this episode in VO. Double tap your headphones to save a moment as you listen.
Get VO free

Transcript

Automatic transcript. May contain errors.

0:00Dino 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 Casanato is a software engineer for Dino, and he spoke about the project on Software Engineering Daily in 2023.

0:38We're excited to have Luca join the show again to talk about the many changes introduced in Dino 2.0. Kevin Ball, or Kate Ball, 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.

1:20Luca, welcome to the show. Hey, thanks for having me. Yeah, absolutely. Excited to have this conversation. Let's maybe start. Do you want to, 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.

1:54And 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 stripped. 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 a 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 like Dino is a pleasure to use and they're really enjoying it.

2:35And it has like 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 like I can't move to use Dino overnight. And that makes sense. So, I mean, we spent the first four years trying to figure out like, where's the ideal? Like, 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 sort of in an incremental way.

3:09And 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, right? 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 that the language server but yeah you can sort of do this on existing projects you don't have to create a new greenfield app to get started with so that's really what you know two 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 two they'll just work Yeah, absolutely.

3:57So 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 you know 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 you know just implements them out of the box now with exactly the same api surfaces node which means that if you have existing libraries that are written against those APIs, you can just use them now.

4:50So that was the first big part. And then the second big part was the ability to understand node modules. So Dino and Dino one has an ability to load external modules, obviously, but it doesn't really use node modules because we consider node modules 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 like a bunch of different lock files, you have like four different package managers you need to choose from, right? It gets very complicated very quickly. So we had our own module solution that is based on web standards, based on like HTTP imports, and more recently on JSR.

5:24But yeah, so in Dnode 2, 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 NodeModules folders on your disk, you can. But by default, we understand those out of the box now. And then the third thing is Dino now has a lot more package management built in. Previously, users may have used import maps to Dino, which is a web standard to help manage dependencies. But now Dino supports package JSON, and it can create your NodeModules folder from your package JSON.

5:59So it has the NPM install functionality baked in. We can read things from your private NPM registries, things like that. So it's really a lot of things that just make it easier to pick 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?

6:37because 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-side 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 Node FS APIs that were designed in 2008, right?

7:19Not 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 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? 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 WinterCG 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.

7:57and 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 of 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've 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.

8:35We'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 or 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.

9:14and 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. 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?

9:56Why would someone choose a Deno versus a Node versus Bun versus WorkerD versus whatever? Yeah, I think part of it is obviously like WorkerD, for example, you can't use WorkerD unless you're running on Cloudflare. Makes it very easy. If you want to develop for Cloudflare, use WorkRD because that's your only option. And if you're not developing for Cloudflare, you don't use WorkRD 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.

10:26Like Dino 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 like not old features, like all the old features, they work perfectly fine at this point they're stable. Another one is tooling, right? Like 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 like compiling to a single executable.

10:59We'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 Bun with, because that was built for that.

11:31But 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 also 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?

12:08Yeah. 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, like 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, 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?

12:43Like 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 like it compiles my code and all that kind of stuff all at once. And that's really what we were going with, with like having all these things in Dino natively. I think the question of like, what do we actually decide to include is what do we think we can do well? Like 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.

13:17In Dino 1, we had a bundle sub command that would like take your JavaScript code or TypeScript code and bundle it into a single file. But we realized that this was like 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.

13:48You can just use them because they work, they're stable. And our bundler 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, 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?

14:23Yeah, 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 tsconfig 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? Like 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.

14:59And like 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. Like 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 like 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 like all the options you should use, not the options you shouldn't use. We've made this decision for you.

15:29Don'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. Like 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. right 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, we'll provide you an escape hatch where they say, we're going to have these defaults for you.

16:33We 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.

17:07But you shouldn't. It's there for like you're migrating an existing project and you like 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 patches 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.

17:46And 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 MISK patch. And at some point, if you decide, OK, 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.

18:28But 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 no 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, okay, this has gotten too complicated.

19:06And I mean, a similar thing happened with NPM. So NPM is obviously Node's package management system where you like 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. Now, 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.

19:46And 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 like link to it. You can tell that there's not been like 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.

20:21They 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. Reminds me a lot of Pika, which I don't know if that project ever went anywhere, but I remember talking with Fred K.

21:03Schott 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, but 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.

21:40The 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 jstr is yeah 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 it's a bit of pr right it's not behind a locked door and you need to become a Microsoft employee first.

22:22Yeah. 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 like through JSR or JSR packages through NPM, but rather they're complementary. And in the way that NPM packages can rely on JSR packages, like 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.

23:01And this is just done through like, you can think of JSR as like 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.

23:46And the export field is just the path of your TypeScript file. And that's it, right? There's no tsconfig to set up. Very importantly, you publish the TypeScript. You don't have to publish like the JavaScript plus d.ts files. No, you publish the TypeScript. so you can like publish a new package in a couple minutes rather than like having to go through and set up the configuration and make sure that it works across cjs and esm and all these things right jssr just handles all that for you so i think a lot of it is like 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.

24:28Dino Deploy, 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 Dino Deploy. And it deploys, and you don't have to deal with configuration. Like 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.

25:00Just stick with the defaults because the defaults are pretty good. Speaking of Dino Deploy, 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.

Read the full transcript

25:39And 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 Dino company fails. JSR is not going anywhere. Not that the Dino 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.

26:12Yeah, 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 is the Dino company itself remain 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.

26:54And 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 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. 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. It's built on the Dino runtime. hosted by us for Netlify.

27:34And 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. They are ways that we can monetize the use of the open source runtime, but not monetize the open source runtime itself. Dino is 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.

28:07And 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 like governance issues within Dino right now that would require, 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.

28:39But 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 licensed, right? If you ever don't like something that we're doing, there's this big button in the top right of all GitHub repos 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.

29:16And we're just going through all of the issues that are being reported after 2.0, right? Major release and people have tried like with 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 of 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.

29:49And 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 linter 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.

30:26So 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.

31:06if you look at our release blog post there's always a section at the bottom of the blog post that's like thanking everyone that's 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. So you have to, I mean, other than that, it's pretty easy. There's a lot of Deno though, that's not written in Rust.

31:41I 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 is sort of lives outside the Dino runtime, but provides a bunch of utilities that any JavaScript project can use, including non-Dino ones. That's written entirely in TypeScript as a Dino project published to JSR.

32:15That'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. I 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.

32:51So actually, first clarification question. So you mentioned, you said Rust, 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 the JavaScript runtime, right? You don't want to have a circular dependency because that means you can't build on new platforms.

33:28But 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.

34:01But 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 because, 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 Rust land versus what's happening in JS slash TS? It's mostly a question of like, do you need Rust to do it as step one? So like native IO talking to the kernel about sockets or files, or I don't know, file watching, all those kinds of things.

34:45You can't implement a JavaScript runtime on top of a JavaScript runtime because something needs to expose like the kernel syscalls 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 TypeScript transpilation, 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.read file, 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.

35:16And like, so you can sort of think of anything that requires native access or requires like 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, right? 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 like when you cross that boundary when you're going back and forth do you have to like copy all of your data over or are you able to you know expose data that's living in javascript language directly to the kernel like how heavy is that that boundary yeah 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 as a blanket statement.

36:23And the reason for this is like 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 end to the other. But 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 forget what I don't know what that's called, whatever. Air quotes? Air quotes. That's right.

36:56Yeah. 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.

37:30I 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 gone 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.

38:06Yeah. Two times is a lot. So you're like removing a copy somewhere or something like that? Pretty much. Yeah. We did some work with Megalia, which is a open source consultancy on upstreaming some changes into V8 that make it, they change how V8 exposes strings to embedders that let us use these strings in a way that is more ideal to us, right? Previously, like 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 and you can just use the string as is while V8 retains ownership of the memory. and this requires a long breath, right? This is work 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 totally worth it.

38:49Talking about this boundary more, I know that Node has this whole Node API standard if you want to build 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. Yeah, yeah. The first way of doing it is to just use NAPI because actually Dino also supports NAPI because otherwise a lot of the node packages wouldn't work. So as I said, Dino 2 needs to work with existing libraries and a lot of existing libraries use NAPI. So Dino influence NAPI. That's step number one.

39:24NAPI 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 like twice as fast as the node library of SQLite that uses an API, just because it's using a different boundary between the two, right? The JavaScript part and the Rust part, and the native part are the same. It's just the call between them that changes. And yeah, that works pretty well.

40:02And it also works really, like our FFI stuff works really well with Rust. I think there's some tools that one of my coworkers has written, which I think is called Dino Bindgen. You write some Rust 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 Rust. It 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.

40:35But 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 could 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.

41:10It 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 like 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 is 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.

41:48Fresh does server-side rendering only, essentially, in the beginning. And then you can opt certain components, so like components one by one, into rendering on the client as well. And we call those islands. So you can think of these as islands of interactivity in a sea of static content that was 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?

42:21You 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 file 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.

42:57There'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 Vue components or Svelte components with Fresh. It's really Preact 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.

43:32So you said file-based routing, similar to how Next at least 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 Preact 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 like the two islands can communicate with each other, which is like a very core part of how to make sort of interactive applications where you have islands across multiple parts of the page.

44:07Supports 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 this no configuration thing keeps sliding in everywhere. But yeah, it uses web APIs for its request and response objects, like integrates very seamlessly with fetch. Works with other runtime frameworks besides Dino? Well, I don't know. Maybe if somebody wants to try. I haven't tried. 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 Preact Compat if you have some library that actually relies on React.

44:51You can just switch it out to use Preact Compat 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. DinoLand slash Fresh on GitHub. We're about to do a 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 Dino, we have a great new tutorial series on YouTube.

45:26If you're interested in learning, published by 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

From the publisher

Deno is a free and open source JavaScript runtime built on Google’s V8 engine, Rust, and Tokio. It’s designed to offer a more secure and standardized alternative to Node.js, with native TypeScript support. Deno 2.0 just released and it’s a significant update, focusing on improved compatibility with Node.js and addressing developer feedback. Some of the

The post Deno 2.0 with Luca Casonato appeared first on Software Engineering Daily.

More from Software Engineering Daily

All 195 episodes
Deno 2.0 with Luca CasonatoSoftware Engineering Daily · 47 min
Listen in VO