SQLite on the Edge

Issue #157.January 30, 2023.2 Minute read.
Bytes

Hi friends. In today’s issue we’ve got a React library for theater kids, a broken Marie Kondo, and everything you’ve ever been too afraid to ask about The Edge™.


Eyeballs logo

The Main Thing

Luke after he kisses his sister

Living life on the edge

Turso brings SQLite to the edge

If there’s one thing I learned from those 45-year-old emo dudes I met at Warped Tour back in 2006, it’s that being edgier isn’t always better.

And the same goes for building modern web applications. “The edge”, which is really marketing speak for “running servers as close to your users as possible”, is really only half the picture. Without also putting your data at the edge, it’s kind of like kissing your sibling. It might feel nice in the moment, but at the end of the day, it’s probably doing more harm than good.

So how do we fix this? Talk to a therapist – and put your data on the Edge, too. But that’s easier said than done. Thankfully, the crazy bastards at ChiselStrike were up for the challenge when they built Turso — SQLite* for the edge.

How did they do it? By forking SQLite. They’re crazy, I told you. If you’re not familiar with SQLite, it’s loved because it’s lightweight, serverless, and embeddable — which makes it perfect for the Edge (and a fork) for a few key reasons:

  • You get the full expressive power of SQL with a relational database engine

  • You get the low latency of a local replica near your users

  • It has a small footprint and low memory requirements, which makes it great for resource-constrained systems

How does it work? Turso is built on top of their fork which leverages SQLite’s Write Ahead Log (WAL). Because I know you’ve just used Firebase your whole career… with WAL, writes are made to a separate log file instead of the database file, and then checkpoints the changes back into the database file. This allows multiple transactions to occur simultaneously and makes the database more resilient to crashes and power outages.

Turso is also accessible over HTTP, meaning it works directly from very restricted environments like Cloudflare Workers and Deno Deploy-based environments like Netlify Edge Functions. Among other things, that means with Turso, you can query over HTTP and replicate to many regions around the world.

Bottom Line: Popular meta-frameworks like Next, Remix, and SvelteKit are helping to bring edge functions into the mainstream. But to realize the full promise of an edgy future, we’ll need distributed databases like Turso as well.

        

Sleuth logo

Our Friends
(With Benefits)

Kid holding up fire in front of his teacher

Sleuth teaching us how to do daily deployments

Sleuth’s free ebook shows you how to ship software like Amazon and Atlassian

What would happen if your manager came to your team and said you had to start deploying 100 times a day? Chaos and disbelief? Rebellion and anarchy?

This idea of “Continuous Delivery” can be a scary buzzword, but that’s why Sleuth’s CEO & Co-founder, Dylan Etkin, wrote The Ultimate Guide to Going from 0 to 100 Deploys a Day.

It’s a 60-page ebook that shows how elite teams at Google, Amazon, and Atlassian slowly worked their way up to deploying 100 times a day, and how it dramatically improved both efficiency and developer happiness. The guide also gives an actionable road map for how to apply those same principles to your own team, no matter what size.

“But what does Mr. Fancy CEO Man know about deploying software?” Quite a bit, actually. Before starting Sleuth, Dylan was one of the first 20 employees at Atlassian and the first architect of Jira. So yeah, he knows his stuff.

Check it out — it’s a fantastic free resource.


The Job Board Logo

The Job Board

Senior Full Stack Engineer
Remote friendly
TS
$160-210k

Motion is looking for experienced TypeScript engineers to build the next generation of productivity tools. You'll inform key frontend architectural decisions that help Motion scale the next 2 order of magnitudes, create delightful user-facing features, and improve application performance. We are an ambitious team of 15 people distributed remotely across North America.

Experienced TypeScript + React Developer
Netherlands
On-site
€50k-€75k

Beatgrid is looking for experienced TS + React developers to help build next-gen web apps for clients like Google, Pepsi, and Virgin. We are a Netherlands-based technology scale-up growing exponentially. When working at Beatgrid, you'll have direct impact and ownership of the products you develop. Join the adventure and grow with us!

Have a job you want to fill?
Pop Quiz logo

Pop Quiz

Sponsored by React Data Grid’s MacBook Pro Giveaway

The giveaway is still going on! Just star React Data Grid’s GitHub repo before Friday, and you’ll be entered to win a brand new M2 MacBook Pro 🎉.

Python has a range function that generates a sequence of numbers starting at the first argument, incrementing by the third argument, and stopping at the second argument.

range(0, 5) // [0, 1, 2, 3, 4, 5]
range(3, 9, 3) // [3, 6, 9]
range(10, 50, 10) // [10, 20, 30, 40, 50]

How would you recreate this in JavaScript?


Cool Bits logo

Cool Bits

  1. After we jokingly complained last week that no one has written an article about “What I like about Bytes”, Sam Huckaby took it upon himself to boost our self-esteem by writing an article called What I like about Bytes. Never let anyone tell you that fishing for compliments doesn’t work. We love you too, Sam, in our own parasocial way.

  2. CarbonQA provides QA services for dev teams, so you’ll never have to do it yourself again. They work in your tools, talk with your team on Slack, and let your devs be devs — so you never have to waste engineering time on testing again 🤯. [sponsored]

  3. Yours truly wrote about Protected Routes and Authentication with React Router. Even if you don’t use React Router, protected routes is a great talking point at all social dinners.

  4. The Firefly team (not the one from The Last of Us) created an AI Infrastructure-as-Code Generator. It’s command line tool that uses OpenAI’s API to generate Infrastructure-as-Code templates, configs, and queries. Time to start a software infrastructure biz and see if those OSS VCs are still giving out $3m seed rounds like candy.

  5. The Theatre.js Team just launched Theatric — a pane library for React that lets you easily animate things with Theatre.js. I keep waiting for someone to launch TheatreKid.js, which adds a bunch of overly dramatic animations to your site and makes it randomly play acapella West Side Story songs at inappropriate times.

  6. Nut.js just launched v3 of its desktop automation framework for Node that lets you program your mouse and keyboard with JavaScript. In this case “Nut” stands for “Native UI Toolkit” — and means absolutely nothing else.

  7. SST is a framework that makes it easy to build and deploy full-stack serverless apps. It’s never been easier to call yourself a full-stack developer.

  8. Maxime Heckel wrote an in-depth article about Refraction, dispersion, and other shader light effects with lots of hands-on examples. So now you can make your site feel so pretty.


Spot the Bug logo

Spot the Bug: Solution

Sponsored by React Data Grid’s MacBook Pro Giveaway.
Star their repo to enter.

range(0, 5) // [0, 1, 2, 3, 4, 5]
range(3, 9, 3) // [3, 6, 9]
range(10, 50, 10) // [10, 20, 30, 40, 50]

How would you recreate this in JavaScript?

const range = (start, stop, step=1) => {
  return Array.from(
    { length: (stop - start) / step + 1 },
    (value, i) => start + i * step
  )
}

The function uses Array.from() to generate an array of a specified length and fill it with values generated by the provided function. The length is calculated as (stop - start) / step + 1, which represents the number of elements in the desired range. The function passed to Array.from() generates each element by starting with start, adding an increment of i * step, where i is the index of the current element.