Javascript Should Come With Batteries

Rate this content
Bookmark

Setting up JavaScript projects is no fun. Getting started involves installing and configuring node, tsc, prettier, eslint, a testing framework, a database driver, and more. Why is JavaScript not batteries included? In this talk we'll talk about how Deno fixes this, letting you focus on building stuff. We explore what benefits full tooling integration unlocks, and remember how fun it is to program if your tools help you, rather than requiring your babysitting.

This talk has been presented at React Day Berlin 2023, check out the latest edition of this React Conference.

Watch video on a separate page

FAQ

Yes, Deno can run npm packages by using the `npm:` prefix in import statements, and it does not require a `package.json` or `node_modules` folder.

The DenoKV database is a built-in key-value store that is ACID compliant and designed for serverless applications. It requires no setup or import.

The speaker is Luca, a software engineer at the Deno company.

The main topic of the talk is that JavaScript should come with batteries included, meaning it should have an extensive standard library and default tooling.

Deno is a next-generation JavaScript runtime that is secure by default, supports TypeScript and JSX out of the box, and includes built-in tools such as testing, linting, formatting, and more.

The speaker argues that JavaScript is too bare bones because it lacks an extensive standard library and default tooling, requiring developers to manually set up and configure multiple tools and packages for their projects.

Deno offers built-in tools such as testing, linting, formatting, a language server for VS Code, documentation generation, single file executables, and a bundler.

Deno handles permissions for IO operations by being secure by default. It prompts the user for permission when a script tries to perform an IO operation, or the user can pass specific flags to grant permissions.

Deno aims to offer a similar out-of-the-box experience as Rust and Go by providing extensive standard libraries and built-in tools, which reduces the need for configuration and setup.

The speaker mentions that Deno initially focused on different goals than Node and did not emphasize compatibility. However, over the last year, Deno has improved its compatibility with Node and npm packages, which has led to significant growth in its adoption.

Luca Casonato
Luca Casonato
30 min
08 Dec, 2023

Comments

Sign in or register to post your comment.
Video Summary and Transcription
JavaScript Should Come With Batteries: Deno is a next-generation JavaScript runtime that addresses the lack of built-in tooling in JavaScript. It provides a secure and simple way to develop applications with built-in testing, linting, formatting, and a language server for VS Code. Deno is compatible with Node.js and NPM, supports web standard APIs, and allows code portability between frontend and server. It also offers features like a built-in database, a key-value store, and transparent monetization with Deno Deploy.

1. Introduction to JavaScript and Talk Premise

Short description:

Hey, folks. Thank you all for being here. I'm Luca, a software engineer at the Deno company. My talk is JavaScript Should Come With Batteries. JavaScript lacks an extensive standard library and default tooling, requiring developers to configure everything themselves. This includes formatters, linters, testing frameworks, and additional packages for various tasks.

Hey, folks. Thank you all for being here. I know it's very late. You're probably all very tired and want to go home. So I'll tell you something about not React, for once. You've probably had a lot of React talks today because we're at a React conference. But I don't know. I'm going to talk about more JavaScript because, hey, React is really just JavaScript, right? And why don't we talk a little bit about JavaScript?

So my talk is JavaScript Should Come With Batteries. And let me explain... Actually, let me first introduce who I am. That's probably useful. So I'm Luca. I'm a software engineer at the Deno company. Some of you may have heard of Deno. If not, I'll get to that in a second. I work on various things related to Deno. I built a frontend framework for Deno called Fresh, that some of you may have seen. And I do a bunch of standards work at T-SYS39, standardizing the JavaScript language. And at WhatWig and W3C, standardizing things like Fetch, HTML. And I'm a co-chair at Widger CG, which is a community group at the W3C where we try to make server-side JavaScript runtimes more interoperable. So making node.js work better with Deno, and Deno better with CloudFlow Workers, with RUN, with whatever, right?

So about my talk today. I have this premise that I'm going to try to argue, which is that JavaScript is too bare bones and this is bad. And what I mean by this is that JavaScript doesn't really have an extensive standard library or default tooling. But rather, everybody sort of has to pack everything they want in their project together themselves. And this means that if you're setting up a new project, you have to go stare at a table like this and fill in the right-hand side. I need a formatter, so let me choose a formatter. Do I use Dprint, do I use Prettier, do I just use auto-formatting in VS Code, or do I use none? Linting, testing, do I want to use TypeScript or not? If so, now I need to have all of my tools support TypeScript. Maybe I want to set up benchmarking, documentation generation, if I have a library. And then you need to pull in a bunch of packages for things that you're going to need to do. You need to pull in a package to do YAML parsing because you have a config file that's written in YAML that some other team gave you.

2. Challenges with Tooling and Dependencies

Short description:

Or you have some service that you're calling and it fails very frequently, so you want to do that with retries, you need to pull in some library for that. And this ends up with every tool and API that you need, you need to have one more package that you install. So you have this very large package.json folder. And this becomes even more complicated because there's so many different tools out there. When you want to use them together, things become even more complicated.

Or you have some service that you're calling and it fails very frequently, so you want to do that with retries, you need to pull in some library for that. And this ends up with every tool and API that you need, you need to have one more package that you install.

So you have this very large package.json folder. And this becomes even more complicated because there's so many different tools out there. When you want to use them together, things become even more complicated. You can install ESLint. I hope your beer's fine. So when you install ESLint and you want to use that with TypeScript, that doesn't work out of the box. You need to install another tool called TypeScript ESLint. You don't just install one, you install two packages, you add a bunch of stuff to your ESLint config file, you need to have a config file for ESLint also. Same thing with JSX, you need to add plugins for that. ESLint is pretty good about ESM.

One of the standout tools here regarding ESM support still couldn't use config files up until a couple weeks ago, months ago, I don't know. But there are some really bad ones, and I don't mean to hate on the folks building Jest. A lot of this boils down to other projects that they use not supporting tools well, but Jest and TypeScript, getting that set up, not fun. You want to throw JSX into the mix, you need to set up more config. Here, you're not even setting up config for Jest, you're setting up config for Babel? It's like, okay, I guess I'm using Babel now. And ESM, just don't use ESM if you use Jest. If you want to test in ESM, just don't use Jest. And then your node module folder looks like this. You have 100 dependencies in your package.json, and a 300 megabyte node module folder. And you just have a config file, and then you have a project like this, right? And imagine coming to a company and you download the repo, and you want to start working, and you're greeted by this. This is not fun. This is not something you want. You just want to get set up and everything just works. And you want to start a new project, you don't want to have to set this up. You just want to have it work out of the box. So how do we solve this? And as a JavaScript developer, you may be wondering, like, yeah, how do we solve this? But if you sort of float around other language ecosystems sometimes, you can see that some ecosystems solve this really well. Some do it very poorly, but some do it really well. For example, Rust and Go.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Node.js Compatibility in Deno
Node Congress 2022Node Congress 2022
34 min
Node.js Compatibility in Deno
Deno aims to provide Node.js compatibility to make migration smoother and easier. While Deno can run apps and libraries offered for Node.js, not all are supported yet. There are trade-offs to consider, such as incompatible APIs and a less ideal developer experience. Deno is working on improving compatibility and the transition process. Efforts include porting Node.js modules, exploring a superset approach, and transparent package installation from npm.
Deno 2.0
Node Congress 2023Node Congress 2023
36 min
Deno 2.0
Top Content
The Talk discusses forced optimization with Node and Deno, with Deno aiming to pursue the same goals in a more expansive and modern way. Deno has built-in support for NPM and enforces security constraints. It also has a key-value database called Deno KV, which will be a core part of the Deno 2 API. Deno Deploy is a serverless Edge Functions platform powered by FoundationDB, optimized for fast reading and ideal for building eCommerce sites or application servers at the edge. Deno 2.0 is coming soon with more features under development.
Fresh: a new full stack web framework for Deno
Node Congress 2023Node Congress 2023
24 min
Fresh: a new full stack web framework for Deno
Today's Talk introduces Fresh, a full-stack web framework for Deno, and covers its features, such as static files, routes, and data-fetching. It also discusses middleware, error pages, and styling options. The Talk explains the Islands architecture used by Fresh to enable client interactivity. The demo showcases the use of hybrid routes and islands components, and resources for Fresh, Deno, Preact, TypeScript, and web standards are provided.
Bun, Deno, Node.js? Recreating a JavaScript runtime from Scratch - Understand magic behind Node.js
Node Congress 2023Node Congress 2023
29 min
Bun, Deno, Node.js? Recreating a JavaScript runtime from Scratch - Understand magic behind Node.js
The Talk explores the magic behind Node.js and delves into its components, including V8, libuv, and the C++ bridge. It discusses the workflow and execution process, the use of NodeMod, and the understanding of console functions. The Talk also covers Node.js functions and scheduling, the introduction of runtimes, and the collaboration between JavaScript runtimes. It concludes with insights on content production, the choice of Node.js, and the inspiration behind it.
Writing universal modules for Deno, Node, and the browser
TypeScript Congress 2022TypeScript Congress 2022
25 min
Writing universal modules for Deno, Node, and the browser
Deno is a modern runtime for TypeScript and JavaScript that runs out of the box and is secure by default. The Talk covers building a greeting message library with Deno, compiling Deno libraries for Node consumers, setting up the editor and writing code, writing tests and running them with dnotest, code formatting, linting, and publishing, publishing to NPM and running tests, and building and publishing the NPM package. The speaker emphasizes the ease of use and integration of Deno's tooling system.
Experimenting with Deno for Easier Kubernetes Deployments
DevOps.js Conf 2022DevOps.js Conf 2022
31 min
Experimenting with Deno for Easier Kubernetes Deployments
The Talk discusses using Dino and TypeScript to simplify writing and managing Kubernetes YAML configurations. It explores the challenges of working with large YAML files and introduces a unique solution. The Talk also highlights the features and benefits of Deno, such as its secure runtime and powerful typing capabilities. It demonstrates how Deno can be used to create and modify Kubernetes objects, and emphasizes the advantages of using a general-purpose language for configuration. The Talk concludes by discussing the potential applications of this approach beyond Kubernetes deployments.

Workshops on related topic

Building a Hyper Fast Web Server with Deno
JSNation Live 2021JSNation Live 2021
156 min
Building a Hyper Fast Web Server with Deno
WorkshopFree
Matt Landers
Will Johnston
2 authors
Deno 1.9 introduced a new web server API that takes advantage of Hyper, a fast and correct HTTP implementation for Rust. Using this API instead of the std/http implementation increases performance and provides support for HTTP2. In this workshop, learn how to create a web server utilizing Hyper under the hood and boost the performance for your web apps.
Writing Universal Modules for Deno, Node and the Browser
Node Congress 2022Node Congress 2022
57 min
Writing Universal Modules for Deno, Node and the Browser
Workshop
Luca Casonato
Luca Casonato
This workshop will walk you through writing a module in TypeScript that can be consumed users of Deno, Node and the browsers. I will explain how to set up formatting, linting and testing in Deno, and then how to publish your module to deno.land/x and npm. We’ll start out with a quick introduction to what Deno is.