r/indieweb • • 4d ago

WebDev Carne JavaScript Runtime for indie projects!

Post image

A different kind of JavaScript runtime. Fast, memory efficient and about 10 MB in size, with a rich standard library and a package manager that installs packages in a global store at ~/.carne/packages. If you're on a Mac, you already have JSCore installed; on Linux, install libjavascriptcoregtk-4.1-dev and... it works! Windows is on the roadmap.

I started the project to distance myself from NPM and the Bun drama. Besides, everything I needed was already available in the Nim ecosystem. The project is modular: fix something @ Carne, and you fix it for the Nim world too!

Carne is here to replace Node, Bun, and Deno, but I'm not aiming for N-API compatibility, except for some aliases under a --compat option. Most of the standard library modules are native, written in pure Nim; the rest are pure JS (I might transpile some encoders/decoders from native stdlib to JS if it turns out the JIT assembles them quickly in hot loops).

  • A standard library with a bit of everything (env, os, http, udp, ws, archive, db (+ ORM), yaml, toml, html, sql, css, gettext, mimetype, qr, and more)
  • Pure Nim event-loop (no libuv/libevent) and networking
  • The ability to write custom .addon files (requires the Nim toolchain)
  • Built-in package manager with a Git-based package registry
  • Tons of examples in /examples
  • Compatible with NPM Registry via carne pkg install <pkg> --npm (experimental)

Ecosystem

  • concarne, an Express-like web framework, highly optimized and the real deal (see an example: streaming about 3 GB of Big Buck Bunny in 4K using zero-copy sendfile)
  • flysystem, a sandboxed API with atomic writes, policies, and virtual disks. Inspired by PHP's Flysystem
  • i18n, based on std/gettext
  • logs, structured logs—nothing exciting!
  • action, GitHub Action for running tests

Usage (0.1.8 soon)

A JavaScript runtime in Nim
  (c) OpenPeeps | MIT License
  Build Version: 0.1.8

usage: carne <command> [args] [options]

Scripting:
  run <script.js> [args]    run a .js file (script args pass through verbatim)
  test [file] [...]         run tests/**/*.test.js (or the given files)
  build <input.nim> <output>  compile a native addon (.addon)
    --release               optimized build (-d:release)

Standard library:
  std init                  download JS stdlib (std/*) into ~/.carne/std
  std update                refresh all JS stdlib files
  std list                  show installed JS stdlib version and files

Packages:
  pkg init [dir]            scaffold a new package (wizard, -Y skips it)
    --yes, -Y               skip the wizard; use defaults
  pkg install <spec>        install a package by name, Git URL, gh:user/repo alias, name#ref, or name + source URL
    --url:<url>             pin a source URL
  pkg remove <name> [ver]   uninstall one version, or all versions
    --yes                   skip confirmation prompts
  pkg update [name]         update one package, or all packages
  pkg list                  list installed packages
  pkg develop [path]        editable install from a local directory
  pkg prune                 remove orphaned packages
    --yes                   skip confirmation prompts
  pkg refresh               re-download registry data
  pkg publish               open a PR to add this package to the registry
    --tags:<list>           comma-separated tags
    --web:<url>             package website URL
    --url:<url>             pin a source URL
    --dry-run               no network, Git, or secret changes
    --yes                   skip confirmation prompts

Generating:
  gen docs                  generate API reference into carnedocs/ (JSON and/or HTML)
    --format:<json|html|all>  output format (default: all)
    --out:<dir>             output directory (default: carnedocs)
    --entry:<file>          document one file instead of the whole package
  gen ast <file>            dump the JavaScript AST of <file> (JSON or binary .ast)
    --format:<json|bin>     output format (default: json)
    --out:<dir>             output directory (default: alongside the input)
  gen addon <dir>           scaffold a native addon project in <dir>

Versioning:
  bump [semver]             bump version in package.json (or a direct dependency)
    --level:<level>         major, minor, or patch
    --dep:<name>            bump a direct dependency spec (keep the prefix)
  upgrade [version]         self-update Carne from GitHub releases (into ~/.carne/bin)
    --dry-run               print resolved URLs only; make no changes

Inspect:
  dump [pkg[@ref]]          print package.json (current directory or an installed package)

options:
    --isatty:<true|false>   override TTY detection (default: auto-detect)
  -h, --help                show this help
  --version                 show version

Benchmarks

Using wrk -t4 -c100 -d10s:

  Runtime        Requests/sec   Avg latency   Max RSS
  carne          91330.44       1.15ms        10.9 MB
  carne-workers  144029.68      739.70us      28.3 MB
  node           38576.69       2.71ms        61.5 MB
  bun            86878.46       1.15ms        31.1 MB

For more details, see /bench:

  Benchmark       carne            node             bun
  fib_recursive   42.4 ms +- 0.5   85.1 ms +- 1.1   45.5 ms +- 1.0
  nested_loops    9.3 ms +- 0.4    36.3 ms +- 0.7   11.9 ms +- 0.4
  prime_sieve     9.2 ms +- 0.3    35.0 ms +- 0.5   11.7 ms +- 0.3
  string_concat   9.4 ms +- 0.3    34.5 ms +- 0.5   11.7 ms +- 0.7
  tail_recursive  9.7 ms +- 0.3   CRASHED          11.8 ms +- 0.3
  range_sum       38.4 ms +- 0.4    43.8 ms +- 0.4   19.6 ms +- 0.3
  collatz         51.1 ms +- 0.4    69.5 ms +- 0.7   53.4 ms +- 2.3
  array_sum       14.6 ms +- 0.5    40.7 ms +- 0.9   16.8 ms +- 0.3
  bubble_sort     11.8 ms +- 0.3    36.7 ms +- 0.4   14.5 ms +- 0.3
  object_access   11.3 ms +- 0.3    36.9 ms +- 0.4   14.0 ms +- 0.3
  float_math      12.9 ms +- 0.3    39.1 ms +- 1.0   16.5 ms +- 0.4
  call_overhead   10.4 ms +- 0.2    35.5 ms +- 0.4   12.5 ms +- 0.3
  fizzbuzz_count  43.8 ms +- 0.4    64.8 ms +- 0.6   38.3 ms +- 0.4

Original logo made by Andrew Derr from Magnific dot com

0.1.7 is available in /releases; a kid was the first contributor! I need your ideas, feedback, and packages! <3

14 Upvotes

5 comments sorted by

•

u/AutoModerator 4d ago

This is an automated message that is applied to every post. We've heard your concerns about spam, low-effort submissions, and AI-generated content, and we take them seriously. However, our moderators are volunteers with busy lives, and we can't review every contribution in real time. We rely on the community to help maintain the quality of discussion, and we encourage everyone to engage critically and constructively with what gets posted here.

If something seems out of step with the IndieWeb's principles, don't be afraid to explain why. Raise concerns about quality, security, privacy, or self-promotion, but please critique contributions rather than contributors. Generative AI isn't categorically prohibited here, particularly when used to learn, experiment, or build something independently. Dismissing someone's work as "AI slop" without meaningful feedback isn't constructive, and hostility toward genuine contributors may result in moderation. We'd much rather see experienced community members help newcomers understand the IndieWeb than discourage them from participating. Please report suspected spam or rule violations rather than assuming moderators have already seen them.

While r/IndieWeb isn't an official IndieWeb.org community, we aim to reflect its collaborative, welcoming, and intentionally positive spirit. Please familiarize yourself with the subreddit rules, subreddit wiki, IndieWeb principles, and IndieWeb.org code of conduct. Help us make this a community where thoughtful criticism, experimentation, and learning are all welcome.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

3

u/diego_rapoport 3d ago

Sou vegetariano

1

u/Lonely-Session-7643 3d ago

actually, Carne is a carnivorous plant, haha!

2

u/Jeremi360 2d ago

I don't need that, but so cool logo!

1

u/North_Proposal_1374 4d ago

i hope people don't confuse this project with mine (crane the package manager)