Money and fame

Issue #42.April 5, 2021.2 Minute read.
Bytes

That’s Deno-the-Company, to you

Two dinosaurs

Is that you, Mama?

What’s $4.9 mil to a runtime like me, can you please remind me?

We know Ryan Dahl’s been singing that to himself all weekend, after raising fat stacks of cash and announcing that Deno is a company now.

What does that mean? Deno is the free-and-open-source, secure JavaScript/TypeScript runtime that’s wants to be the spiritual successor to Node.js (also created by Ryan Dahl). Thankfully, that “free-and-open-source” part isn’t changing with the formation of Deno Corp™.

There won’t be a freemium or “open core” model where users get some Deno features but have to pay for others. Instead, Ryan says that “this funding round will secure my family’s financial independence for generations to come.” OK that’s a joke but he did say the Deno business “will build on the open source project, not attempt to monetize it directly.”

It’s already doing this with Deno Deploy — a new Distributed VM for running JavaScript, TypeScript, and WebAssembly at the edge.

At first glance the deployment platform looks pretty cool: it deeply integrates with Daphne V8 and is built on Rust (so it’s fast), it lets you develop locally and deploy globally, it has a “permissively licensed CLI” that lets you use any cloud services you want (or self host), and the landing page has really cute dinosaur illustrations.

Why’s Deno going this route? 2 big reasons:

  1. Money and fame.

  2. In the announcement post, Ryan explains that server-side JavaScript has failed to keep up with the innovation that we’ve seen in the browser. He takes a few shots at Node.js (lol) and lays out Deno’s vision for “breathing new life into the ecosystem” by creating a set of technologies that can be repurposed to create custom runtimes for different applications. The $4.9m will let Deno hire a full-time staff of engineers leaving the remaining $4 million to spare on a DOPE post-covid SOMA office space and billboards all along the 101 making fun of Node.

The Bottom Line

We’ve written before about the potential dangers of mixing OSS with venture capital. TL;DR — the “grow fast or die trying” ethos of VC doesn’t always provide a stable ecosystem for the developers who rely on these open source technologies.

However, this time feels different. Deno has a uniquely ambitious mission that no one else is working on, and it’s not unreasonable to think they need money for it… and who knows? Maybe it wouldn’t have taken the React team 3 years and counting to ship Suspense if they had a runway. Happy Anni, btw.


Cloudflare’s Durable Objects

Twinkies

The original “durable object”

Cloudflare has announced the open beta for Durable Objects, their new stateful serverless database, which puts one more nail in the coffin for long-running servers. Viva la Serverless!

How did we get here? Cloudflare’s primary product is a worldwide CDN and DDOS protection, with over 25 million websites using their product. In 2017, they released a serverless platform called Cloudflare Workers that 0ms cold starts (take that, AWS Lambda).

In September, Cloudflare announced the closed beta for Durable Objects, the very cleverly named storage solution that gives Workers stateful superpowers. See, old-school serverless can’t hold onto any data or context like an old-old-school server can. Once the function is complete, the “server” that runs the serverless code disappears. Durable Objects, on the other hand, are… well… durable.

  • Durable Objects are defined with classes, usually written in JavaScript. The class defines methods and properties for the object, and then Cloudflare instantiates objects with the class.

  • Durable Objects retain their state, even when they aren’t active. It’s like a super-fast, private database for each object.

  • Each Durable Object is unique, meaning there’s only one of them in the entire world, so they can send messages to each other.

Say you have a chat room Durable Object. It can keep track of the WebSockets connected to it and whenever a user sends a message, it broadcasts that message to all of the connected clients. Plus, with that private database, it can store the chat room history for when visitors first connect. Since it’s serverless, it can scale to an absurdly high number of unique rooms and users, all without the developer needing to configure anything.

Also, Durable Objects live on the Edge, close to where requests come from; users requesting data from their own Durable Objects will get wicked fast response times! It pays to live life on the Edge.

The Bottom Line

The pipe-dream series-of-tubes-dream of real-time serverless just became a reality. Watch out for AWS to copy it super-fast, real-time apps.


JS Tip

Have you ever used Array’s fill method? Probably not. Defined, fill “fills all the elements of an array from a start index to an end index with a static value”. It sounds pretty useless, but I’ve found one scenario where it’s actually pretty helpful.

As you start to make your code more functional, you naturally start to avoid using regular for loops in favor of .map, .reduce, etc. Let’s say our use case was we wanted to execute a function an arbitrary amount of times, say 10. How could we do this and avoid using a for loop? Your first intuition might be to use an Array constructor with .map.

Array(10).map(() => {
  return doThing()
})

You’ll notice if you run that code it won’t work. When you do Array(10), you’re creating an array of 10 unset or “empty” values. Unfortunately, when you use any of the array methods, they won’t work on an array with empty values.

This is where .fill comes into play. If you do Array(10).fill(), you’ll then get an array with 10 undefined, not empty elements.

Array(10).fill().map(() => {
  return doThing()
})

Not super useful, but good to know it exists if you need it.


One Very Long Cool Bit

  1. The United States’ Supreme Court officially ruled that it was OK for Google to copy the Java API (which is owned by Oracle) to create the Android OS. It’s being called “one of the most important legal decisions in the history of software” because it basically establishes APIs as “fair use,” making them like the Dewey Decimal System or a QWERTY keyboard from a legal perspective (AKA you can’t copywrite them). Charles Duan wrote a great Tweet thread about it all.

    It’s hard to cheer for either side in a Google vs. Oracle lawsuit (gross), but in this case we were happy to cheer for Google since this ruling fundamentally allows open source software to continue being actually open.

The Other Seven Cool Bits

  1. Amelia Wattenberger wrote an awesome article on using React with D3.js that will help you trick your co-workers into thinking you’re way better at data viz than you actually are. It’ll also help you learn D3, which is almost as valuable.

  2. Hagop created node-express-boilerplate to make it easier to build production-ready REST APIs with Node.js, Express, and Mongoose. If your API is good enough, you can look forward to Google copying it with impunity since the Supreme Court is cool with that I guess. (Wait, what?)

  3. Eric wrote a five-part tutorial series called DIV and Backend again, A TypeScript Tale that was great, but didn’t contain nearly enough Tolkein references. We could’ve used a lot more Tom Bombadil and Elvish poetry, Eric.

  4. James Sinclair wrote about rethinking the JavaScript ternary operator. And since his initials are JS, we are all bound by The Unwritten Rules of the Script to take all of his words as Gospel, since he is the chosen vessel of JS knowledge.

  5. Tomorrow marks the one-year anniversary since we got the React Router v6 preview.

  6. Charles wrote about replacing let with const, even when it feels impossible. Because we know you can’t wait to read another article on this topic.

  7. The React Team launched React Labs — a new video series of technical deep dives in React. If you enjoy the videos, please be sure to call Mark Zuckerberg to thank him personally.