HNHacker News
TopNewBestAskShowJobs

jamesgpearce

2,508 karma · joined March 11, 2009

Hacker, sailor, TinyBase. Previously Engineering Director at Meta: data infra, dev tools, open source, and platforms.

https://x.com/jamespearce https://tripleodeon.com

submissionscomments
jamesgpearce··on TinyBase v2.0: reactive data store for local-first apps
Thank you. I figured that getting/setting/listening are the key primitives, and then the React layer (which is just one of many theoretical UI library bindings) can use hooks and components, or whatever, to simply wrap them. I'm not familiar with Dolt, but seems like I need to become so!
jamesgpearce··on TinyBase v2.0: reactive data store for local-first apps
Honestly, just my personal confidence currently. There's very basic locking and store-wide read-write. I really aspire to some sort of CRDT implementation that can be considered a bit more state-of-the-art and tolerant to the innumerable challenges of that problem.
jamesgpearce··on TinyBase v2.0: reactive data store for local-first apps
Ouch, tough crowd, but fair enough!

I wonder if I should have a font-weight (or -family) toggle alongside the dark mode setting. Would be a shame for people to miss out on reading about the software because of the typography!

jamesgpearce··on TinyBase v2.0: reactive data store for local-first apps
No, there's no _actual_ RDBMS involved. The query engine uses a functional style of query that has similar concepts to SQL, but all the evaluation (and reactivity) is first party, in the library itself.

Of course it would be pretty easy/fun to persist your TinyBase content into a SQLite database, or pull a dataset from it. The demos load up TSV but you could easily do something similar from an actual database somewhere.

jamesgpearce··on TinyBase v2.0: reactive data store for local-first apps
Cool! Please take a look and see if it works out. I should point out that the ui-react library (that provides React bindings) does _not_ depend on ReactDOM, so you can use it just as easily in React Native.

At least, once I got the bundler to be happy about the export format! Please see https://github.com/tinyplex/tinybase/issues/17#issuecomment-...

jamesgpearce··on TinyBase v2.0: reactive data store for local-first apps
thanks! - it's been a labor of love :)
jamesgpearce··on TinyBase v2.0: reactive data store for local-first apps
Author here, if anyone has any thoughts or feedback. Bring it on!
jamesgpearce··on Will Bun JavaScript Take Node's Crown
Agree. But it’s not either/or. I invested easily hundreds of hours in docs before launching TinyBase.org - but I don’t think it made the subsequent community building challenge any easier.
jamesgpearce··on Ask HN: Best dev tool pitches of all time?
Lee Byron on Immutable/React/Flux: https://youtu.be/I7IdS-PbEgI

“I only have a minute left, which is more than enough time to build the undo stack”

jamesgpearce··on TinyBase: A JavaScript library for structured state
Ah no, these aren't transactions in the sense of locking and multiple client access. My glib answer is that there's perk to JavaScript not being multithreaded! But seriously, when persisting/saving a Store, the library doesn't guarantee that you aren't saving over something another browser window might have just written. I would need to think about what that would entail.
jamesgpearce··on TinyBase: A JavaScript library for structured state
Thank you! I added a fun little thing where it charts the results to check for complexity problems. eg:

  Grow store, different table to index with multiple row count, µs per row
  First: 16.3 µs per row
   Last: 3.61 µs per row
    Min: 2.76 µs per row
    Max: 29.89 µs per row
    Avg: 7.33 µs per row

        90.00 ┼───────────────────────────────────────
        84.00 ┤
        78.00 ┤
        72.00 ┤
        66.00 ┤
        60.00 ┤
        54.00 ┤
        48.00 ┤
        42.00 ┤
        36.00 ┤
        30.00 ┤╭╮
        24.00 ┤││     ╭╮
        18.00 ┼╯│     ││         ╭╮
        12.00 ┤ ╰╮   ╭╯│    ╭╮   ││          ╭╮
         6.00 ┼──╰───╯─╰────╯╰───╯╰──────────╯╰╮──╭───
         0.00 ┤                                ╰──╯
jamesgpearce··on TinyBase: A JavaScript library for structured state
Noted! :)
jamesgpearce··on TinyBase: A JavaScript library for structured state
Just for the record, I developed TinyBase on a 12" 2016 1.1GHz MacBook! Constraints are good :) - and it keeps me honest with respect to performance, size, and toolchain.
jamesgpearce··on TinyBase: A JavaScript library for structured state
You can persist the Store to local or session storage (in a browser), to a file (where available) or to a remote server. More on the concept of 'Persisters' is in https://tinybase.org/guides/schemas-and-persistence/persisti...

You can see this in action in the TinyDraw demo: https://tinybase.org/demos/tinydraw - make some changes, refresh the page, even open it up in two windows of the same browser at the same time.

jamesgpearce··on TinyBase: A JavaScript library for structured state
Noted! Need to think about this one.
jamesgpearce··on TinyBase: A JavaScript library for structured state
There are transactions! https://tinybase.org/api/store/interfaces/store/store/method...

This allows you to wrap a batch of mutations together and then the fully reconciled change events are all fired together at the end. Apparently I could do a better job of marketing this secret feature :)

As another commenter has mentioned, there are also 'checkpoints' that let you create a stack of points in history to undo/redo back and forwards through. https://tinybase.org/guides/relationships-and-checkpoints/us...

jamesgpearce··on TinyBase: A JavaScript library for structured state
The definition of a Schema itself is typed of course (https://tinybase.org/api/store/type-aliases/schema/schema/) but I haven't thought of a way to then magically create developer-time definitions of a Schema on a Store. There is also a way to 'programmatically' enforce a Schema (https://tinybase.org/guides/schemas-and-persistence/mutating...) so you could (in theory) implement all sorts of wild and wonderful constraints.

I think for now you'll need to create your own local type definition that models the data you know is in the Store. But let me think a bit more about this.

jamesgpearce··on TinyBase: A JavaScript library for structured state
Yes! Though there is an optional ui-react module, this is not a React library per se. There's nothing to stop a Vue equivalent except... my lack of current knowledge about it. Noted!
jamesgpearce··on TinyBase: A JavaScript library for structured state
> I thought the author had lost his mind

Quite possible. This was a journey! https://tripleodeon.com/2022/01/software-without-compromise/

When I first started thinking about this project, classes still meant a bunch of transpilation overhead (which dates the origin story!). I persuaded myself that plain old objects with TypeScript interfaces would strike a better balance between performance, size, and developer experience.

So I ended up with a pattern like:

  const longMethod1 = () => {...};
  const longMethod2 = () => {...};
  return {longMethod1, longMethod2};
These 'methods' can still call each other by name, and it minifies like a champ.
jamesgpearce··on TinyBase: A JavaScript library for structured state
Haha. That's kind of how this started in the first place :)
jamesgpearce··on TinyBase: A JavaScript library for structured state
I'm pleased with the performance but I stopped short of quoting numbers, because hardware. If you compile and `npm run testPerf` on your own machine you will see a bunch of benchmarks that clock most operations in low µs.

(That also spits out ascii charts to visually make sure there are no complexity explosions. See https://tinybase.org/guides/how-tinybase-is-built/testing/ for example.)

As for maintainability... I have no data yet, since it's a couple of days old ;)

jamesgpearce··on TinyBase: A JavaScript library for structured state
Thanks for the feedback! I'm going to push back on your assertion that it's mature since it's about two days old and I only revved it to v1.0.3 because of some .d.ts resolution issues :)

I agree with your very final point. The same might be true of the undo stack implementation too - at some point the usage patterns might invalidate some of my performance assumptions.

jamesgpearce··on TinyBase: A JavaScript library for structured state
Author here, but I just woke up. AMA!
jamesgpearce··on TinyBase: A reactive JS library for structured state and tabular data
Author here!

One of the interesting things about this project was the reality (and curse) of writing software when you don't have any constraints. I wrote a little bit about the experience here too: https://tripleodeon.com/2022/01/software-without-compromise

jamesgpearce··on Scaling Mercurial at Facebook
We export each of the open source projects out of the monorepo and into separate GitHub projects using a tool called ShipIt (https://code.facebook.com/posts/1715560542066337/automatical...)
jamesgpearce··on Updating Our Open Source Patent Grant
NB that post pre-dates this change.
jamesgpearce··on Notes from Facebook's Developer Infrastructure at Scale F8 Talk
The engineering sessions are in this playlist: https://www.youtube.com/playlist?list=PLb0IAmt7-GS1_7FcSupSJ...
jamesgpearce··on Angular 2: Built on TypeScript
This presentation compares TypeScript & Flow for React: https://www.youtube.com/watch?v=9PTa9-PPVAc&list=PLb0IAmt7-G...
jamesgpearce··on Coming Soon in HHVM
I don't know if you've seen what we're doing with JavaScript :)
jamesgpearce··on Use ReactJS to Build Native Apps
Video of this keynote is now up: https://youtube.com/watch?v=KVZ-P-ZI6W4
← PreviousPage 2 of 4Next →