Does Deno 2 really uncomplicate JavaScript?
- Views
- 525K
- 524,615
- Outlier
- ×1.7
- Median 316K
- Length
- 8:55
- Published
- Oct 14, 2024
- Monday
- Comments
- 841
- 20.5K likes
Script
How it's written
- Words
- 2,025
- Words a minute
- 226
- Reading time
- 9 min
- Segments
- 6
The hook
0:00–0:25last week the highly anticipated dino2 JavaScript runtime was finally released and they launched it with what is easily the greatest commercial for a JavaScript tool ever made it's funny it's packed with Easter eggs and it hits especially hard if you know the pain of JavaScript development the video has nearly a million views on Twitter but I don't want to spoil it in this video we'll use dino2 to build a rest API and find out if it lives up to its bold claim of uncomplicating JavaScript by comparing
Structure
last week the highly anticipated dino2 JavaScript runtime was finally released and they launched it with what is easily the greatest commercial for a JavaScript tool ever made it's funny it's packed with Easter eggs and it hits especially hard if you know the pain of JavaScript development the video has nearly a million views on Twitter but I don't want to spoil it in this video we'll use dino2 to build a rest API and find out if it lives up to its bold claim of uncomplicating JavaScript by comparing it to node.js and its other rival bun who had threw some subtle shade out with this other Easter egg yeah I'm sure 99.9% of people missed it but it's a brutal roast a bun which cannot fully handle the nextjs app router without no JS is some people say using JavaScript on the server was the greatest mistake ever made by mankind but I disagree JavaScript is actually one of the fastest soy based languages on the back end and its non-blocking event driven architecture generally performs better than languages like python or PHP it won't beat C++ or rust but it's far easier to use than those languages and Dino addresses almost all the problems that have plagued nodejs development nodejs is an awesome tool as well but the ecosystem suffers from bloat to build something you generally have to mix and match a bunch of different tools and those tools are great but it creates a lot of mental boilerplate and Chaos that you just don't have in dino by the end of this video you'll be able to wipe about a dozen different JavaScript tools from your memory forever before we get started though I have a funny story I actually took a rare vacation back in September to the beautiful country of Croatia before leaving Dino provided me with Early Access to triy out version 2
Watch from 0:00they didn't sponsor or pay me but I made a code report and scheduled it in advance which is something I almost never do the expected release for Dino 2 was supposed to be late September however they changed the release date while I was out in the middle of nowhere without Wi-Fi then my video went out as scheduled and totally screwed up their release plan Ryan dll the creator of node.js and Dino had to get on Twitter and do some damage control I hope they're not big mad because I really do like Dino and I'm even considering making a full course about it for fireship pro members if that's something you want to see let me know in the comments because as an elderly developer like myself who's over the age of 24 keeping life simple is the only way to maintain my sanity let's jump into some code and see how Dino does that you'll notice that I currently have Dino version 2.0 installed and one tool you can remove from your brain right away is node version manager because Doo can upgrade itself with the upgrade command where you specify the version you want to use unlike nbm though you can't switch between different versions but in Dino that's typically not necessary because of the way things work in its standard library but more on that later but from there we'll create a new project with Dino and nit that creates a project with a main.ts file in it where everything is already configured with typescript and that means you can remove the TS config from your brain next now you can go into the doo. Json file and customize the typescript compiler there but at least you don't have to spend 2 hours failing to configure it just to get started now you'll also notice a main test file Dino has a built-in test framework in runner which we can use immediately by running Dino test and that means we can remove J Jasmine mocha vest chai and virtually any other JavaScript testing library from our brain space now to be fair no Js also released its own test runner in version 20 but I write perfect code that doesn't
Watch from 1:31need to be tested anyway so it's a moot point let's go ahead and write some perfect code now in the main TS file what we want to build is a rest API for horse tender where you can create a horse in a sqlite database then fetch all the horses or just one individual Horse by its ID we could do that with the node.js HTTP module but 99% of the time people will just use expressjs or pick from one of the other 5,000 different web Frameworks the cool thing about doo2 is that you can still use all of those Frameworks because it now supports everything in npm which was not the case in Dino 1 in fact I'm using hono and Dino to build my own little side project right now but another approach is to just use dinos serve which is an HTTP server that's built into the global runtime one thing that's really nice about it is that it uses standard web apis like request response and fetch that means if you're a web developer you can use abstractions you already know and just release all your memories for node.js specific abstractions now it takes a call back function as an argument and let's go ahead and return a basic response to test it out we can now run this code by opening the terminal and hitting Doo run one thing you'll notice is that it requires us to explicitly Grant permission to different features on the system that can improve security and production and it makes it more difficult for hacked npm packages to mine Bitcoin on your system but in development let's go ahead and bypass it with a capital a flag and then I'm also adding a watch flag on here as well to restart the server whenever our code changes and that eliminates yet another tool from our memory nodemon or no demon which needs to be installed in no. JS to accomplish the same thing pretty cool but what you'll notice here is that my my code is all screwed up because the indentation got screwed up when I copied it from chat PC normally to fix that I
Watch from 3:03would have to set up prettier with a prettier config but in Deno I can just run the format command and now my code is fixed in addition you'll likely also have yes lint in there to make sure that your code doesn't suck but in Doo you can just run the link command now from here we need a sqlite database there are many different sqlite drivers out there and we can import virtually any of them with minimal chaos and most importantly eliminate the complexity of Legacy module formats like commonjs from our brains for for example if there's one you like on npm you can import it with the npm prefix that's cool but you can also import directly from a URL which might look familiar if you've ever used the go programming language but the preferred option is to use jsr which is a package registry built by the team behind Dino it actually works in all the other runtimes like bun and node.js but it's designed for typescript and guarantees you'll get awesome intellisense and type safety for every package you install in this case we'll install Dino sqlite 3 which claims to be the fastest sqlite driver in the JavaScript ecos system and now we're ready to go into a 1980s Montage of me writing some code okay that was pretty lame in the code the first thing I'm doing is creating a database with a table for horses which have a name age and permal Link now moving inside of dinos serve we first grab the URL of the request and then do some conditional logic to f figure out what kind of response we should render like if it's a git request without an ID that means we're going to
Watch from 4:35return all the horses from the database but if it's a get request with an ID then we'll return just one horse and our database query is adjusted accordingly again it's worth pointing out that the apis we're using here are the same apis in the browser which just makes a ton of sense if you're a web developer but now if we go down to the post request where we create a new horse record we're going to hit a problem and that's with this permal link attribute because what we want to do is take the name that the user provides and for form at it in Kebab case so we can use it in a URL now normally to solve that problem I would use a tool like low Dash but in Dino it mostly becomes obsolete because they have a massive standard Library like earlier we actually already looked at STD testing but there's another STD we want to get called text which has a bunch of utilities like two camel case two Kebab case and can even do things like a word similarity sort all these STDs help you solve common problems which means you don't need to fill up a massive dumpster with mpm packages that's pretty huge and now we have a basic where rest API it currently it's just returning Json but what if we want to do some react server side rendering by converting jsx to HTML on the server Doo 2.0 released a new jsx transform and it claims to be blazingly fast at 7 to 20 times faster than the competition and then finally as our project grows in complexity the next thing we might want to do is create a monoo dino also supports this out of the box which we can configure in the dino Json file allowing us to create multiple applications and libraries each with their own dependencies in a single git repo then finally to wrap things up what I want to do is compile my code into an executable binary that I can run either
Watch from 6:05on Mac OS windows or Linux we can easily do that in Dino with the compile command in the future you'll also be able to natively do that in node.js but that feature is currently under active development competition has been dramatically improving serverside JavaScript but what about the other runtime bun well somebody posted that exact question on both the Dino and Bun subreddits as you might imagine everybody in the dino subreddit said Dino and everybody in bun said bun in my opinion if I were starting a new project today I would feel a bit more confident with Dino but the stuff bun is shipping is awesome like this dollar sign feature for Shell scripting or its very own built-in C compiler I have no idea what I would use that for but it's pretty cool that it's there when bun first came out its biggest selling point versus Dino was that it could also support mpm packages but now dino has caught up there the other potential advantage of bun is performance on the website it claims to be faster than Dino but there's been a lot of debate around the benchmarks and Dino has posted its own Benchmark saying it's better and there really needs to be some kind of comprehensive independent Benchmark but in the real world performance very much depends on what you're actually building the most important deciding factor for a JavaScript runtime though is how good is their marketing a while back bun released an awesome product demonstration the number one feature request window support but this latest Dino commercial felt like a Super Bowl ad that blows it out of the water and that's why I'm choosing it for my next failed side project thanks for watching and I will see you in the next one
Watch from 7:35Full transcript
- 0:00
last week the highly anticipated dino2 JavaScript runtime was finally released and they launched it with what is easily the greatest commercial for a JavaScript tool ever made it's funny it's packed with Easter eggs and it hits especially hard if you know the pain of JavaScript development the video has nearly a million views on Twitter but I don't want to spoil it in this video we'll use dino2 to build a rest API and find out
- 0:21
if it lives up to its bold claim of uncomplicating JavaScript by comparing it to node.js and its other rival bun who had threw some subtle shade out with this other Easter egg yeah I'm sure 99.9% of people missed it but it's a brutal roast a bun which cannot fully handle the nextjs app router without no JS is some people say
- 0:43
using JavaScript on the server was the greatest mistake ever made by mankind but I disagree JavaScript is actually one of the fastest soy based languages on the back end and its non-blocking event driven architecture generally performs better than languages like python or PHP it won't beat C++ or rust but it's far easier to use than those languages and Dino addresses almost all the problems that have plagued nodejs
- 1:04
development nodejs is an awesome tool as well but the ecosystem suffers from bloat to build something you generally have to mix and match a bunch of different tools and those tools are great but it creates a lot of mental boilerplate and Chaos that you just don't have in dino by the end of this video you'll be able to wipe about a dozen different JavaScript tools from your memory forever before we get started though I have a funny story I
- 1:24
actually took a rare vacation back in September to the beautiful country of Croatia before leaving Dino provided me with Early Access to triy out version 2 they didn't sponsor or pay me but I made a code report and scheduled it in advance which is something I almost never do the expected release for Dino 2 was supposed to be late September however they changed the release date while I was out in the middle of nowhere without Wi-Fi then my video went out as
- 1:45
scheduled and totally screwed up their release plan Ryan dll the creator of node.js and Dino had to get on Twitter and do some damage control I hope they're not big mad because I really do like Dino and I'm even considering making a full course about it for fireship pro members if that's something you want to see let me know in the comments because as an elderly developer like myself who's over the age of 24 keeping life simple is the only way to maintain my sanity let's jump into some
- 2:06
code and see how Dino does that you'll notice that I currently have Dino version 2.0 installed and one tool you can remove from your brain right away is node version manager because Doo can upgrade itself with the upgrade command where you specify the version you want to use unlike nbm though you can't switch between different versions but in Dino that's typically not necessary because of the way things work in its standard library but more on that later
- 2:27
but from there we'll create a new project with Dino and nit that creates a project with a main.ts file in it where everything is already configured with typescript and that means you can remove the TS config from your brain next now you can go into the doo. Json file and customize the typescript compiler there but at least you don't have to spend 2 hours failing to configure it just to get started now you'll also notice a main test file Dino has a built-in test
- 2:48
framework in runner which we can use immediately by running Dino test and that means we can remove J Jasmine mocha vest chai and virtually any other JavaScript testing library from our brain space now to be fair no Js also released its own test runner in version 20 but I write perfect code that doesn't need to be tested anyway so it's a moot point let's go ahead and write some perfect code now in the main TS file
- 3:08
what we want to build is a rest API for horse tender where you can create a horse in a sqlite database then fetch all the horses or just one individual Horse by its ID we could do that with the node.js HTTP module but 99% of the time people will just use expressjs or pick from one of the other 5,000 different web Frameworks the cool thing about doo2 is that you can still use all of those Frameworks because it now
- 3:29
supports everything in npm which was not the case in Dino 1 in fact I'm using hono and Dino to build my own little side project right now but another approach is to just use dinos serve which is an HTTP server that's built into the global runtime one thing that's really nice about it is that it uses standard web apis like request response and fetch that means if you're a web developer you can use abstractions you
- 3:50
already know and just release all your memories for node.js specific abstractions now it takes a call back function as an argument and let's go ahead and return a basic response to test it out we can now run this code by opening the terminal and hitting Doo run one thing you'll notice is that it requires us to explicitly Grant permission to different features on the system that can improve security and production and it makes it more difficult for hacked npm packages to
- 4:11
mine Bitcoin on your system but in development let's go ahead and bypass it with a capital a flag and then I'm also adding a watch flag on here as well to restart the server whenever our code changes and that eliminates yet another tool from our memory nodemon or no demon which needs to be installed in no. JS to accomplish the same thing pretty cool but what you'll notice here is that my my code is all screwed up because the indentation got screwed up when I copied
- 4:32
it from chat PC normally to fix that I would have to set up prettier with a prettier config but in Deno I can just run the format command and now my code is fixed in addition you'll likely also have yes lint in there to make sure that your code doesn't suck but in Doo you can just run the link command now from here we need a sqlite database there are many different sqlite drivers out there and we can import virtually any of them
- 4:53
with minimal chaos and most importantly eliminate the complexity of Legacy module formats like commonjs from our brains for for example if there's one you like on npm you can import it with the npm prefix that's cool but you can also import directly from a URL which might look familiar if you've ever used the go programming language but the preferred option is to use jsr which is a package registry built by the team
- 5:14
behind Dino it actually works in all the other runtimes like bun and node.js but it's designed for typescript and guarantees you'll get awesome intellisense and type safety for every package you install in this case we'll install Dino sqlite 3 which claims to be the fastest sqlite driver in the JavaScript ecos system and now we're ready to go into a 1980s Montage of me writing some
- 5:45
code okay that was pretty lame in the code the first thing I'm doing is creating a database with a table for horses which have a name age and permal Link now moving inside of dinos serve we first grab the URL of the request and then do some conditional logic to f figure out what kind of response we should render like if it's a git request without an ID that means we're going to return all the horses from the database
- 6:07
but if it's a get request with an ID then we'll return just one horse and our database query is adjusted accordingly again it's worth pointing out that the apis we're using here are the same apis in the browser which just makes a ton of sense if you're a web developer but now if we go down to the post request where we create a new horse record we're going to hit a problem and that's with this permal link attribute because what we want to do is take the name that the
- 6:28
user provides and for form at it in Kebab case so we can use it in a URL now normally to solve that problem I would use a tool like low Dash but in Dino it mostly becomes obsolete because they have a massive standard Library like earlier we actually already looked at STD testing but there's another STD we want to get called text which has a bunch of utilities like two camel case
- 6:48
two Kebab case and can even do things like a word similarity sort all these STDs help you solve common problems which means you don't need to fill up a massive dumpster with mpm packages that's pretty huge and now we have a basic where rest API it currently it's just returning Json but what if we want to do some react server side rendering by converting jsx to HTML on the server Doo 2.0 released a new jsx transform and
- 7:10
it claims to be blazingly fast at 7 to 20 times faster than the competition and then finally as our project grows in complexity the next thing we might want to do is create a monoo dino also supports this out of the box which we can configure in the dino Json file allowing us to create multiple applications and libraries each with their own dependencies in a single git repo then finally to wrap things up what
- 7:31
I want to do is compile my code into an executable binary that I can run either on Mac OS windows or Linux we can easily do that in Dino with the compile command in the future you'll also be able to natively do that in node.js but that feature is currently under active development competition has been dramatically improving serverside JavaScript but what about the other runtime bun well somebody posted that
- 7:51
exact question on both the Dino and Bun subreddits as you might imagine everybody in the dino subreddit said Dino and everybody in bun said bun in my opinion if I were starting a new project today I would feel a bit more confident with Dino but the stuff bun is shipping is awesome like this dollar sign feature for Shell scripting or its very own built-in C compiler I have no idea what I would use that for but it's pretty
- 8:11
cool that it's there when bun first came out its biggest selling point versus Dino was that it could also support mpm packages but now dino has caught up there the other potential advantage of bun is performance on the website it claims to be faster than Dino but there's been a lot of debate around the benchmarks and Dino has posted its own Benchmark saying it's better and there really needs to be some kind of comprehensive independent Benchmark but
- 8:31
in the real world performance very much depends on what you're actually building the most important deciding factor for a JavaScript runtime though is how good is their marketing a while back bun released an awesome product demonstration the number one feature request window support but this latest Dino commercial felt like a Super Bowl ad that blows it out of the water and that's why I'm choosing it for my next failed side project thanks for watching
- 8:53
and I will see you in the next one
Description
Last week, the highly anticipated JavaScript runtime was released, with arguably the greatest launch campaign for a JavaScript tool ever made.
Deno 2 Commercial • Programming Should Be Simple
Original Deno Code Report • Deno 2 is here… will it actually kill Node...
In this video we'll use Deno 2.0 to build a REST API and find out if it lives up to its bold claim of uncomplicating JavaScript...
Learn how to build real-world applications with JavaScript 👉https://fireship.io/courses/js/
More from Beyond Fireship
×6.45:04Subtle, yet Beautiful Scroll Animations
Beyond Fireship2M views
×2.98:33Most overpowered way to build mobile apps?
Beyond Fireship925K views
×2.88:23This UI component library is mind-blowing
Beyond Fireship878K views
×2.76:17Industrial-scale Web Scraping with AI & Proxy Networks
Beyond Fireship854K views
