gritzko / swarm

JavaScript replicated model (M of MVC) library
http://swarmdb.net/
MIT License
2.68k stars 97 forks source link

Typescript? #89

Open vestild opened 7 years ago

vestild commented 7 years ago

May be change language to typescript while code base is small?

cblp commented 7 years ago

yes!

gritzko commented 7 years ago

I absolutely like the idea, except I am short of time.

vestild commented 7 years ago

Ok, I will start translation

jhuiting commented 7 years ago

@vestild Any updates on this? Would also be interested to see Swarm being ported to TypeScript, also willing to helping getting this done.

Off topic: really like the idea of swarm, exactly the level of abstraction I was looking for to start using CRDT's.

gritzko commented 7 years ago

Hi @jhuiting ! Here is the core package of the 2.0 version https://github.com/gritzko/swarm-ron Currently, it is ES6. The hourglass-waist interface is RON frames. The next big thing I will try there is possibly migrating it from strings to typed arrays to make those immutable frames cheaper to iterate on (less gc strain). I believe, TypeScript should live higher up the chain, at the API tier (i.e. it is a mapper: RON -> objects). It does not make much sense to introduce TypeScript into the core tier.

Hence, someone should design that TypeScript API package: objects on the outside, RON frames inside and on the wire. Named swarm-api-ts maybe.

gritzko commented 7 years ago

@cblp @vestild @jhuiting @andreypopp So, guys, in case you have any ideas on that RON-to-objects API, please share now. MVC-ish? Redux-ish? GraphQL-ish? What are your personal experiences with those technologies? Physically, you get a bunch of RON frames from the server. Incremental updates will follow up in real time. How would you expose that in your dream API?

jhuiting commented 7 years ago

@gritzko That makes sense, the RON frames and all core seems to be low level indeed so TS wouldn't add much there. I've worked with MVC for quite a while (BackboneJS, and a bunch of server-side frameworks) and have some experience with Redux. I'm not sure if GraphQL fit's here, I would expect that at a different abstraction level (e.g. an endpoint that exposes operations on the objects).

One option that's not mentioned is Mobx, we're using that at Mendix for an extensive, typed SDK that sends deltas over HTTP in the background (Mobx is originally built by a colleague for that purpose). So the end-user is just modifying objects, and everything they do in there is typed. The JS SDK (not the TS sources) are available on NPM if you want to have a quick peek. I'm happy to explain it in more detail if anyone finds it relevant/interesting.