text
stringlengths
0
2.02k
[524.66 --> 525.58] through rose colored glasses?
[526.12 --> 528.48] I think that's a fair characterization of what happened.
[529.04 --> 529.74] Adam, you were around.
[530.46 --> 530.56] Yeah.
[530.80 --> 535.06] Node was huge immediately. Like maybe not immediately, but like people were very excited about Node,
[535.10 --> 535.30] right?
[535.30 --> 535.66] Yeah.
[535.78 --> 535.90] Yeah.
[536.40 --> 540.92] Well, then there was a lot of things even like with Walmart Labs and Black Friday. This
[540.92 --> 546.04] wasn't back in the 2009 days particularly, but there was a lot of inertia around, you know,
[546.48 --> 552.56] high traffic websites and scalability and, you know, it's enterprise ready. So a lot of different
[552.56 --> 558.14] enterprise teams were happy to move on to something more modern despite these seven flaws as you've
[558.14 --> 562.64] described in your talk, you know, because I think every step forward is a good step forward,
[562.64 --> 567.06] even if it's got some flaws, which software has flaws every single time.
[567.26 --> 573.44] Yeah. So I guess my point is, is that it filled a huge void and it got a huge rush of enthusiasm
[573.44 --> 579.78] and adoption because of that. And then Dino comes out and it doesn't come out into that same moment
[579.78 --> 585.02] in time, right? It comes out later where you have a mature Node ecosystem. You have millions of packages
[585.02 --> 591.36] on NPM. You have people doing this full-time careers and consultant. I mean, there is a thriving
[591.36 --> 598.26] Node ecosystem already. And so into that milieu or that culture, Dino has to set itself apart,
[598.32 --> 603.04] right? And TypeScript was one of the ways that it kind of did that to start. What were the other
[603.04 --> 606.50] big ideas that Dino has that sets it apart from everything else?
[606.94 --> 613.44] First important aspect is that it's written in Rust instead of C++. Node is a very large C++ project.
[614.32 --> 618.98] And I'm not sure how you guys feel about this, but I'm very convinced that I will never start
[618.98 --> 626.44] another C++ project. Rust really solves the C++ problem as it were. And I think that there's many
[626.44 --> 632.96] great things about Rust, but the thing that is most important to me is the ability to have a single
[632.96 --> 640.84] build system. So this cargo system of linking together different Rust crates. In C++, there's no
[640.84 --> 649.96] one defined way of how to take different C++ libraries and smash them together. So Chrome has
[649.96 --> 656.92] this GN project. Node uses this GIP project. There's CMake. There's a lot of different tooling for
[656.92 --> 665.94] kind of compiling together dependencies in C++. And this ends up being a huge, huge complexity in terms of
[665.94 --> 673.26] bringing in external third-party code into a big project. And so, you know, in Node days, when we want
[673.26 --> 680.46] to, you know, we built a web server and like, you know, you have to parse HTTP. And it's such a difficult
[680.46 --> 686.82] problem that we ended up writing our own HTTP parser for this. It's so difficult to bring in external code
[686.82 --> 693.06] that you end up often having to just write the stuff over again because it's so difficult to link.
[693.06 --> 699.84] And this is very different in Rust, right? If I need a YAML parser, if I need an HTTP server,
[700.24 --> 707.44] any sort of third-party stuff, I would do what people are used to doing in JavaScript or Ruby or
[707.44 --> 712.90] Python. You can just kind of include dependencies and have this all compiled together really nicely.
[713.18 --> 721.78] And that's an important aspect for a platform like Deno or Node because, you know, we provide all of
[721.78 --> 730.16] these APIs to do various things, right? You want to open a WebSocket. You want to have an HTTP2 web
[730.16 --> 737.28] server. All these various systems that it talks to need implementations. And it's very nice that we're
[737.28 --> 743.72] able to just link in third-party implementations of all these various systems pretty easily. So
[743.72 --> 751.36] from a maintainer's perspective, rewriting it in Rust is a really killer feature that kind of allows us
[751.36 --> 756.22] to iterate much, much quicker. Yeah. Maybe it kind of a feature that end users don't appreciate
[756.22 --> 762.76] as well as the authors and maintainers, but they will appreciate over time as you are allowed to
[762.76 --> 769.78] continue at a certain pace that, you know, the C++ ecosystem didn't allow with Node. Or maybe
[769.78 --> 774.46] at a certain point, Deno will also get so many lines of code and so much stuff in it that, I mean,
[774.48 --> 779.44] it will slow down. And any project that's mature is move slower than when it's young, but maybe it'll
[779.44 --> 786.18] keep a pace that keeps your users happy. Sure. Just talking about other aspects of Deno kind of
[786.18 --> 793.38] internally that are important is the binding interface, kind of the boundary between JavaScript
[793.38 --> 802.70] and the native language, in this case, Rust, in Node's case, and C++. Node was fairly ad hoc at adding
[802.70 --> 809.02] bindings. We just kind of added them all over the place. There was no set system for calling from
[809.02 --> 815.48] JavaScript into C++ and vice versa. And in Deno, there's a system for this. We call them ops.
[815.48 --> 822.08] And so this kind of organizes all of the various bindings that you have to the system facilities
[822.08 --> 829.38] really nicely. And in particular, organizes all of the async calls that you might make. So ops in our
[829.38 --> 833.96] system are either a synchronous function, like a function you call into Rust and it returns a value
[833.96 --> 840.68] immediately, or it's an async function, which returns a promise that eventually resolves to a value. And so
[840.68 --> 846.24] one of the really nice aspects in Deno is that everything is organized as promises. It's kind of
[846.24 --> 851.32] promises all the way down. There's not kind of random callbacks that happen throughout the system.
[852.00 --> 857.26] This was actually a pretty big design mistake. I forget if I did discuss this or how much I discussed
[857.26 --> 862.92] this in the talk, but WebSockets are on my mind right now because we're doing a lot with WebSockets.
[863.58 --> 866.98] WebSockets have this on-message callback, right?
[866.98 --> 873.98] And one of the problems with this is that you can't really stop the system from giving you new
[873.98 --> 879.30] messages. You can just get flooded with these callbacks. There's no way to kind of throttle
[879.30 --> 886.38] this incoming stuff. And so because of the inability to stop these new messages coming in through this
[886.38 --> 891.96] WebSocket, you can get into really bad situations where you're always handling the newest WebSocket
[891.96 --> 896.82] message because you're getting flooded from this one socket, say. And this is not
[896.82 --> 901.56] specific to WebSockets. This happens in different parts of the system. That's quite bad.
[902.64 --> 910.58] This actually causes pretty, this manifests itself in kind of bad tail latency situations where,
[910.78 --> 916.78] you know, usually the system is fine, except under pressure when like suddenly, like, you know,
[917.06 --> 921.42] one part of the system is getting flooded with these callbacks. And so you start getting really
[921.42 --> 927.06] bad latencies. WebSockets in particular have, there's a new standard out called WebSocket
[927.06 --> 933.44] streams, which addresses this, allowing you to create some back pressure that is to not accept
[933.44 --> 939.54] the newest message if you're not ready to handle it. And in general, this async await paradigm syntax
[939.54 --> 945.14] and the usage of promises everywhere generally kind of solves this problem. Because as long as you're
[945.14 --> 949.72] always getting these promises and you're awaiting them, you're kind of stopped at a certain line.
[949.72 --> 956.04] You're not kind of unboundedly accepting new callbacks from the system. Anyway, that's all
[956.04 --> 961.86] to say that Dino is promises all the way down. And so kind of from the fundamental layer, we've tried
[961.86 --> 969.46] to deal with this back pressure problem. Another big differentiator is the package management story,
[969.72 --> 975.02] right? That's right. Tell us about how Dino sees the world of packages. So yeah, I mean,
[975.02 --> 981.30] I would bring this back to in general, Dino is trying to use web APIs, we try not to introduce
[981.30 --> 988.98] invented APIs, like I had to do in 2009. When I started node, there's just a lot of APIs that were,
[989.16 --> 996.08] you know, there was no module system. And so we invented this require syntax to link to JavaScript
[996.08 --> 1002.94] files together. Yes, modules, ECMAScript modules is a standard. Now, this is part of the new JavaScript
[1002.94 --> 1009.86] standard, which defines import and export, I'm sure you guys are familiar with it. And this works in
[1009.86 --> 1016.92] web browsers these days, these imports and exports and ways to link different files together. And the
[1016.92 --> 1023.88] way that this works on the web is you can actually do import a URL from not just a relative URL, but a
[1023.88 --> 1030.70] absolute URL that exists on a different server. And so you can actually pull in code, you know, if you
[1030.70 --> 1037.94] think of like a HTML page and scripts tags, you know, you can script source, have a link to
[1037.94 --> 1044.42] hgpsjquery.org slash jquery version 1.2.js. That's how we used to do it back in the day,
[1044.44 --> 1049.08] we just have our script sources, and you just have your list of sources and everything was so simple,
[1049.40 --> 1056.58] which is quite nice, right? I mean, it's really nice to have a HTML file and just drop in a link to
[1056.58 --> 1064.60] the jquery CDN and suddenly have that available without having to do a whole thing.
[1064.82 --> 1065.48] Yeah, totally.
[1065.64 --> 1070.86] A whole installation procedure, right? Anyway, Dino is built around the idea that we think this is
[1070.86 --> 1077.26] sufficient actually to link remote code together. I mean, the problem is really, I've got code that
[1077.26 --> 1084.66] I'm developing locally. And I really want to include some third party library. How do I do that?
[1084.66 --> 1091.12] In the node system, you would download that third party code into a node modules folder.
[1091.68 --> 1098.22] And this require system and knows how to look into this node modules folder. So when you do require
[1098.22 --> 1104.20] express, it looks in the local directory node modules, and then looks for the express folder.
[1104.94 --> 1108.90] And, you know, it has some special knowledge about looking up package JSON,
[1108.90 --> 1117.16] and looking up index.js has kind of this algorithm of how to find what module you're referring to there.