Bring it on, coward

Issue #32.January 25, 2021.2 Minute read.
Bytes

Hopefully this brings you as much joy as Gamestock and BlackBerry share holders got today. thisisfine.gif

Brave browser wants to decentralize the web with a new protocol

Mel Gibson

Brave heart(s) freedom

“They may take our lives… but they’ll never take away our free-and-open internet.” At least, not if Brave’s CEO Brendan Eich has anything to say about it (yes, that Brendan Eich). That’s because last week, Brave became the first browser to offer native integration with IPFS — a peer-to-peer hypermedia protocol that says it wants to “surpass HTTP in order to build a better web for all of us.”

Welcome to the revolution, comrades.

How IPFS works: Instead of browsers accessing information on central servers like they do now with HTTP, IPFS accesses it on a network of “distributed nodes” — AKA users who can both receive and host content. Kinda like BitTorrent, but for the entire web.

IPFS benefits:

  • Faster & cheaper — Since there’s no specified location for content, IPFS can download pieces of files from multiple computers simultaneously, which saves big on download time, bandwidth, and server costs for the original publishers.

  • Less centralized — Eliminating the need for centralized servers makes it significantly harder for governments or tech giants to censor web content. You can already use Brave & IPFS to view thousands of websites that are banned by various governments around the world.

The Bottom Line

You probably don’t need to throw your AWS Certification in the trash just yet, since this is still the early days. But both Brave and IPFS stand to gain a lot with this partnership:

  • IPFS gets primo access to Brave’s 24 million users (more users = more powerful network)
  • Brave is undoubtedly hoping that IPFS will help entice more privacy-focused users onto its browser, so it can get some of that sweet hockeystick-growth juice that DuckDuckGo’s been sipping on

The company behind IPFS is also behind FileCoin, the cryptocurrency with a $1B market cap (+/- $500m depending on which day you read this). So I guess they’re doing alright.


JavaScript + Rust = Boa?

Going to flavor town

Get in, we’re going to low-level JS FlavorTown

What happens when a TC39 delegate gets a wandering eye for a new programming language? Turns out, they aren’t actually brought before the committee, forced to turn in their badge and their gun, and violently exiled from JavaScript-land forever (kind of a letdown, tbh).

In Jason Williams’ case, he simply figured out a way to marry his first and second loves by using Rust to build a JavaScript engine named Boa. As he started falling for Rust, he (like others in recent years) saw the benefits of bringing Rust to the JavaScript ecosystem and vice versa.

Last week, Boa took a big step towards that goal when it released v0.11 — it’s biggest release yet.

Boa describes itself as an “experimental Javascript lexer, parser, and compiler” (AKA all the things that JavaScript engines do). It still isn’t fully conformant (nice word, right?) to the JavaScript Spec, but this v0.11 release took Spec conformance from 18% (back in October) up to 31% last week. A solid jump in 3 months. Boa is also seeing almost 6x faster execution after it switched to using to the regress engine for regular expressions.

Faster execution and greater conformance are the name of the game if Boa ever wants more mainstream adoption, so these are both positive signals.

Who’s ever gonna use this?

  • Rust devs who want to include an embeddable JavaScript implementation in their Rust code
  • JavaScript devs who are curious about the Rust and WASM’s hype and want an excuse to bring it into the browser
  • Your obnoxious co-worker who always wants to flex about using bleeding edge tech

But now that you’ve read this, you can start messing around on the Boa Playground for a few minutes, and you could become that obnoxious co-worker. You’re welcome.


Spot the Bug (Answer Below)

function Animal (name, energy) {
  let animal = {}
  animal.name = name
  animal.energy = energy

  return animal
}

Animal.prototype.eat = function (amount) {
  console.log(`${this.name} is eating.`)
  this.energy += amount
}

const leo = Animal('Leo', 7)
leo.eat(5)

Cool Bits

  1. AnimXYZ is a composable CSS animation toolkit that’s powered by CSS variables and built for Vue, React, and SCSS. Not to be confused with “AnimeXYZ”, which would be a great name for an animation library that makes a tiny Naruto run across the bottom of your screen every time a new page loads.

  2. Fayaz compiled an interesting list of actually useful no-code tools for developers that aren’t site builders.

  3. You know how 50% of blog posts could have just been tweets? Well, Alex Kondov wrote a blog post so in-depth that it probably should’ve been a book. We present to you — The Tao of React: Software Design, Architecture & Best Practices. Just call it an e-book and charge $10 for it, Alex (and pay us 15% for being your e-publisher).

  4. If you’re looking for a good waste of time (who isn’t?), you may want to check out <SpeedTyper /> - a type racing application for programmers that will definitely activate all of your repressed Mavis Beacon trauma from the elementary school computer lab. I’m currently sitting comfortably at #5. Bring it on, coward.

  5. Razvan wrote about how he almost got fired for choosing React for his team’s enterprise app. (TL;DR — don’t outsource your React enterprise app to .NET developers, lol.)

  6. Jack Franklin from Google wrote about migrating Puppeteer to TypeScript. Word on the street is Geppetto is also migrating to TypeScript.

  7. Aleksandr also wrote a looong article on how to code SVG icons by hand that makes me think I should probably just keep using other people’s libraries. (Shout out to people named Alex going above and beyond with these blog posts this week.)

  8. Adrian Twarog made a video demonstrating 10 examples of “clean” JavaScript code. Did he miss a great opportunity to sing the OutKast classic, “So fresh and so clean” at some point during the video? 100% yes. But will we hold that against him forever? Also 100% yes.


Spot the Bug - Answer

Our call to leo.eat is going to fail. The reason for this is because the object returned from Animal isn’t delegating to Animal.prototype so leo.eat will be undefined.

To fix this, we can use Object.create or a combination of the this keyword with new.

function Animal (name, energy) {
  let animal = Object.create(Animal.prototype)
  animal.name = name
  animal.energy = energy

  return animal
}

// or

function Animal (name, energy) {
  this.name = name
  this.energy = energy
}

const leo = new Animal('Leo', 7)

For more details, check out A Beginner’s Guide to JavaScript’s Prototype.