Does Deno 2 really uncomplicate JavaScript?

Fireship · Intermediate ·📰 AI News & Updates ·1y ago

Key Takeaways

Deno 2.0 is used to build a REST API, evaluating its claim of uncomplicating JavaScript, with a focus on its features and capabilities as a JavaScript runtime.

Full Transcript

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 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 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 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 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 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 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 return 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 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 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

Original 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 https://youtu.be/swXWUfufu2w Original Deno Code Report https://youtu.be/pcC4Dr6Wj2Q 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/
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Beyond Fireship · Beyond Fireship · 39 of 42

1 Social Media Style Number Formatting in JS
Social Media Style Number Formatting in JS
Beyond Fireship
2 I used 3 different File System APIs in Node.js
I used 3 different File System APIs in Node.js
Beyond Fireship
3 Time is Relative, even in JavaScript
Time is Relative, even in JavaScript
Beyond Fireship
4 How to NOT Screw Up Firebase Environment Variables
How to NOT Screw Up Firebase Environment Variables
Beyond Fireship
5 How to make your JavaScript Bundle Smaller
How to make your JavaScript Bundle Smaller
Beyond Fireship
6 Subtle, yet Beautiful Scroll Animations
Subtle, yet Beautiful Scroll Animations
Beyond Fireship
7 Beyond Surreal? A closer look at NewSQL Relational Data
Beyond Surreal? A closer look at NewSQL Relational Data
Beyond Fireship
8 How to Build a Discord Bot
How to Build a Discord Bot
Beyond Fireship
9 How to make Eyeballs that Follow You Around
How to make Eyeballs that Follow You Around
Beyond Fireship
10 Reverse Engineer Google’s NASA Dart Easter Egg with CSS
Reverse Engineer Google’s NASA Dart Easter Egg with CSS
Beyond Fireship
11 Generate Images Programmatically on the Edge
Generate Images Programmatically on the Edge
Beyond Fireship
12 WTF are all these config files for?
WTF are all these config files for?
Beyond Fireship
13 NEW Firebase Features Just Dropped
NEW Firebase Features Just Dropped
Beyond Fireship
14 Next.js 13 - The Basics
Next.js 13 - The Basics
Beyond Fireship
15 Make Crazy Art with the NEW OpenAI Dall-e API
Make Crazy Art with the NEW OpenAI Dall-e API
Beyond Fireship
16 How to Setup Node.js with TypeScript in 2023
How to Setup Node.js with TypeScript in 2023
Beyond Fireship
17 Dramatically improve website speed with Partytown
Dramatically improve website speed with Partytown
Beyond Fireship
18 The easiest realtime app I’ve ever built
The easiest realtime app I’ve ever built
Beyond Fireship
19 10 Rendering Patterns for Web Apps
10 Rendering Patterns for Web Apps
Beyond Fireship
20 You don't need Node to use NPM packages
You don't need Node to use NPM packages
Beyond Fireship
21 Sorting Algorithms Explained Visually
Sorting Algorithms Explained Visually
Beyond Fireship
22 ChatGPT Official API First Look
ChatGPT Official API First Look
Beyond Fireship
23 I built an image search engine
I built an image search engine
Beyond Fireship
24 Industrial-scale Web Scraping with AI & Proxy Networks
Industrial-scale Web Scraping with AI & Proxy Networks
Beyond Fireship
25 Next.js Server Actions...  5 awesome things you can do
Next.js Server Actions... 5 awesome things you can do
Beyond Fireship
26 The ultimate guide to web performance
The ultimate guide to web performance
Beyond Fireship
27 I built a fullstack PaLM AI app in just 2 minutes
I built a fullstack PaLM AI app in just 2 minutes
Beyond Fireship
28 I tried 8 different Postgres ORMs
I tried 8 different Postgres ORMs
Fireship
29 I built a *streaming* AI chat app
I built a *streaming* AI chat app
Fireship
30 React VS Svelte...10 Examples
React VS Svelte...10 Examples
Fireship
31 How GitHub Actions 10x my productivity
How GitHub Actions 10x my productivity
Fireship
32 PROOF JavaScript is a Multi-Threaded language
PROOF JavaScript is a Multi-Threaded language
Fireship
33 Mind-blowing page animations are easy now... View Transitions API first look
Mind-blowing page animations are easy now... View Transitions API first look
Fireship
34 I built an Apple Vision Pro app... visionOS tutorial
I built an Apple Vision Pro app... visionOS tutorial
Fireship
35 This UI component library is mind-blowing
This UI component library is mind-blowing
Fireship
36 How I deploy serverless containers for free
How I deploy serverless containers for free
Fireship
37 GitHub Copilot now controls your command line...
GitHub Copilot now controls your command line...
Fireship
38 Build better payment forms using new “embedded” Stripe Checkout
Build better payment forms using new “embedded” Stripe Checkout
Fireship
Does Deno 2 really uncomplicate JavaScript?
Does Deno 2 really uncomplicate JavaScript?
Fireship
40 JavaScript performance is weird... Write scientifically faster code with benchmarking
JavaScript performance is weird... Write scientifically faster code with benchmarking
Fireship
41 Is Next.js 15 any good? "use cache" API first look
Is Next.js 15 any good? "use cache" API first look
Beyond Fireship
42 I built a DeepSeek R1 powered VS Code extension…
I built a DeepSeek R1 powered VS Code extension…
Fireship

This video evaluates Deno 2.0's claim of uncomplicating JavaScript by building a REST API, covering its features, capabilities, and potential impact on JavaScript development. Learn how to build real-world applications with JavaScript. The video provides a hands-on example of using Deno 2.0 to create a REST API.

Key Takeaways
  1. Install Deno 2.0
  2. Create a new Deno project
  3. Define API endpoints
  4. Implement API routing
  5. Test the API
💡 Deno 2.0 aims to simplify JavaScript development by providing a secure and efficient runtime environment, making it easier to build and deploy JavaScript applications.

Related AI Lessons

Up next
News At 10
Channels Television
Watch →