Want the Fastest JS Apps? How about  using BunJS?

https://slides.com/davidcrowther/bunjs

David Crowther

Sr Web Dev - FHD Latin America Homeland

Jon Summers

Performance/Scalability

What is BunJS?

What is BunJS?

  • A new JavaScript runtime comparable to NodeJS and Deno
  • Beta recently released
  • Much faster and has some nice things built in
  • Not likely ready for you to use for production
  • You might be able to use it to run tasks
  • You may want to consider alternative tools like fnm or pNpm

BunJS Features

BunJS Features

  • Built on JavaScriptCore from WebKit
    • NodeJS and Deno use V8
    • JavaScriptCore is considered faster but more difficult to work with
  • Written in Zig (similar to C or Rust)
  • Has a native bundler (no Webpack)
  • You can write TypeScript (native transpiler)
  • Compatible with NPM modules (loads them very fast)
  • ENV variables load automatically
  • Fast native test runner
  • Includes SQLite

BunJS Features

  • Built on JavaScriptCore from WebKit 
  • Written in Zig (similar to C or Rust)
  • Has a native bundler (no Webpack)
  • You can write TypeScript (native transpiler)
  • Compatible with NPM modules (loads them very fast)
  • ENV variables load automatically
  • Fast native test runner
  • Includes SQLite

BunJS Features

  • Built on JavaScriptCore from WebKit 
  • Written in Zig (similar to C or Rust)
  • Has a native bundler (no Webpack)
  • You can write TypeScript (native transpiler)
  • Compatible with NPM modules (loads them very fast)
  • ENV variables load automatically
  • Fast native test runner
  • Includes SQLite

BunJS Features

  • Built on JavaScriptCore from WebKit 
  • Written in Zig (similar to C or Rust)
  • Has a native bundler (no Webpack)
  • You can write TypeScript (native transpiler)
  • Compatible with NPM modules (loads them very fast)
  • ENV variables load automatically
  • Fast native test runner
  • Includes SQLite

BunJS Features

  • Built on JavaScriptCore from WebKit 
  • Written in Zig (similar to C or Rust)
  • Has a native bundler (no Webpack)
  • You can write TypeScript (native transpiler)
  • Compatible with NPM modules (loads them very fast)
  • ENV variables load automatically
  • Fast native test runner
  • Includes SQLite

BunJS Features

  • Built on JavaScriptCore from WebKit 
  • Written in Zig (similar to C or Rust)
  • Has a native bundler (no Webpack)
  • You can write TypeScript (native transpiler)
  • Compatible with NPM modules (loads them very fast)
  • ENV variables load automatically
  • Fast native test runner
  • Includes SQLite

BunJS Features

  • Built on JavaScriptCore from WebKit 
  • Written in Zig (similar to C or Rust)
  • Has a native bundler (no Webpack)
  • You can write TypeScript (native transpiler)
  • Compatible with NPM modules (loads them very fast)
  • ENV variables load automatically
  • Fast native test runner
  • Includes SQLite

BunJS Features

  • Built on JavaScriptCore from WebKit 
  • Written in Zig (similar to C or Rust)
  • Has a native bundler (no Webpack)
  • You can write TypeScript (native transpiler)
  • Compatible with NPM modules (loads them very fast)
  • ENV variables load automatically
  • Fast native test runner
  • Includes SQLite

https://www.youtube.com/watch?v=FMhScnY0dME (3:15)

How fast is Bun?

https://www.youtube.com/watch?v=O-NWCjC9iRw (0:40-3:26)

https://www.youtube.com/watch?v=X5V6RXJBp8I (7:40-16:20)

Perf Testing Gem

Getting Started With BunJS

https://www.youtube.com/watch?v=X5V6RXJBp8I (5:10-7:40)

Install/Run BunJS

  • https://bun.sh/
  • Install bun with

    • curl https://bun.sh/install | bash
  • Create and run a server
    • touch server.ts
    • export default {
        port: 3000,
        fetch() {
          return new Response("Hello, World!")
        }
      }
    • bun server.ts

Resources...

  1. https://bun.sh/: Install bun with curl https://bun.sh/install | bash
  2. JavaScript just got way faster: https://www.youtube.com/watch?v=FMhScnY0dME (play 0:00-3:14)
  3. What is the Bun JavaScript Runtime?: https://www.youtube.com/watch?v=O-NWCjC9iRw (play 0:40-3:26)
  4. What is Bun?: https://syntax.fm/show/488/what-is-bun-the-new-js-runtime (play 3:31-23:25)
  5. Bun roadmap: https://github.com/oven-sh/Bun/issues/159
  6. Getting started with bun.js web server - performance: https://www.youtube.com/watch?v=X5V6RXJBp8I (play 5:10-22:11
    1. ​Installation
    2. Performance
    3. Comparison of Deno & BunSuggestions:
  7. YouTube search: https://www.youtube.com/results?search_query=bun+js+for+beginners
  8. How to install Bun JS on Ubuntu 22.04 LTS | Linux | Faster JS Runtime | Bun: https://www.youtube.com/watch?v=3S2In1X07G8&list=PLT8tjCYKynKsXBrCf7KiQ6Y-6U304DjXT

Resources...

  1. https://bun.sh/: Install bun with curl https://bun.sh/install | bash
  2. JavaScript just got way faster: https://www.youtube.com/watch?v=FMhScnY0dME (play 0:00-3:14)
  3. What is the Bun JavaScript Runtime?: https://www.youtube.com/watch?v=O-NWCjC9iRw (play 0:40-3:26)
  4. What is Bun?: https://syntax.fm/show/488/what-is-bun-the-new-js-runtime (play 3:31-23:25)
  5. Bun roadmap: https://github.com/oven-sh/Bun/issues/159
  6. Getting started with bun.js web server - performance: https://www.youtube.com/watch?v=X5V6RXJBp8I (play 5:10-22:11
    1. ​Installation
    2. Performance
    3. Comparison of Deno & BunSuggestions:
  7. YouTube search: https://www.youtube.com/results?search_query=bun+js+for+beginners
  8. How to install Bun JS on Ubuntu 22.04 LTS | Linux | Faster JS Runtime | Bun: https://www.youtube.com/watch?v=3S2In1X07G8&list=PLT8tjCYKynKsXBrCf7KiQ6Y-6U304DjXT

What can I do with Bun right now?

Demos

  • David's portfolio site (https://github.com/crowtherdr/drcrowther-webd/tree/react-ts)? Yes
  • Frontier CRA? No
  • CRA? No
  • System test apps? No

Resources...

YouTube playlist: https://www.youtube.com/playlist?list=PLy626RPaflBuyOEJwk3p2yef4bD7fbWg0

  1. Built and ran David's portfolio app with no changes: https://github.com/crowtherdr/drcrowther-webd/tree/react-ts
    • ​​May take multiple install runs because of lockups. Seems to often get hung up on core-js-pure.
    • Bun has a common cache like Pnpm.
    • Speed of install depends on presence of node_modules, ~/.bun/install/cache, and/or bun.lockb
  2. ​Deploy to a production server?
  3. ​What about a Frontier app? Does it just need a 'bunrc' change?
  4. ​Using SQLite: https://github.com/oven-sh/bun#bunsqlite-sqlite3-module

Resources...

YouTube playlist: https://www.youtube.com/playlist?list=PLy626RPaflBuyOEJwk3p2yef4bD7fbWg0

  1. Built and ran my portfolio app with no changes.
    • ​​May take multiple install runs because of lockups. Seems to often get hung up on core-js-pure.
    • Bun has a common cache like Pnpm.
    • Speed of install depends on presence of node_modules, ~/.bun/install/cache, and/or bun.lockb
  2. ​Deploy to a production server?
  3. ​What about a Frontier app? Does it just need a 'bunrc' change?
  4. ​Using SQLite: https://github.com/oven-sh/bun#bunsqlite-sqlite3-module

BunJS-SORT2022

By David Crowther

BunJS-SORT2022

  • 358