Live data from Hacker News

Show HN: Simperium, a realtime data layer

simperium.com

61–70 of 90 posts

Re: Show HN: Simperium, a realtime data layer

#62
This is interesting. We built something very much like this internally at SeatMe. On the iOS side, it's almost identical. It's how we keep our iPads up to date. Might not of built something internally ourselves a year ago if there was a platform like this.

The biggest difference is that since we are not a general platform, we can make assumptions about the model and how version each release and we can built in some constrains and unique security models.

We took a lot of cues from the OData spec and Microsoft's reference design.

The rest of this comment is mostly targeted at the creators of Simperium.

You made very similar design decisions to us in a lot of ways. A lot problems though that you will face I see with your path here so I have a few tips for you.

* It sucks the iOS client isn't open source. I get scared of linking in third party libs into iOS projects because I have to account for anything you do when I go to Apple to submit my app.

* You really got to brush up on the objective-c naming conventions. Not to be harsh but `-(id)getCustomObjectForKey:(NSString * )key;` makes me cringe.

* Don't require me to have to know about your categories.

* Namespace your categories so you don't smash mine ("something like "SP_encodeBase64WithString" instead of "encodeBase64WithString")

* If you include third party libs, you MUST rename them and prefix with your prefix. I see you use ASIHTTPRequest, DDLogger, SocketIoClient, AsyncSocket, Reachability, and a few others. You will smash everyone else's implementations if they already had them included.

* Don't use ASIHTTPRequest internally (it's old and unmaintained and doesn't play nicely with ARC)

* PREFIX ALL YOUR CODE. We don't have any real name-spacing objective-c. As a framework developer, you have to be aware of that more than anyone else. I shouldn't be seeing DiffMatchPatch and SocketIoClient show up in my symbol list after linking your lib

* Your addDelegate/removeDelegate is funny. After you exhausted the need for one delegate, switch to NSNotificationCenter.

* DON'T USE XIB/NIBs. Interface builder for iOS was an after thought and it's only a 90% solution (unlike with Cocoa where interface builder was a first class product built side by side with AppKit). Especially don't make me have to include your XIBs in my bundle. At the very least give me a bundle with it in it.

* Separate your GIT repo. If I want to include your library as a submodule I have to take all the client libraries as well.

Now when it comes to the actual sync layer and how you generate JSON dictionaries and apply "patches" this is fine code.

Here are some feature requests:

* Instead of having to give you a single NSManagedObjectContext let us register them. We have a few (some use different concurrency types).

* Let us override what gets generated or if we want to ignore a field with userInfo keys in the core data model.

* Let us get an idea of your backend sync processes to be able to suspend and start them when we need and know if anything is pending. Give us a callback that you still have things to queued and when we are done so we can at our leisure set up UIBackgroundTasks on iOS 4+.

On an unrelated note, why not create this as a NSIncrementalStore and just put your code behind the persistent store coordinator instead of monitoring it? We are doing the same as you at the high level because we wrote our code pre iOS 5.0 but iOS 5 gives you an awesome new toy there.

Re: Show HN: Simperium, a realtime data layer

#63

This is interesting. We built something very much like this internally at SeatMe. On the iOS side, it's almost identical. It's how we keep our iPads up to date. Might not of built something internally ourselves a year ago if there was a platform like this. The biggest difference is that since we are not a general platform, we can make assumptions about the model and how version each release and we can built in some c…

"Might not of built something internally ourselves a year ago if there was a platform like this."

A great quote!

There's a lot of good feedback here, particularly regarding playing more nicely with other code. We'll do a pass, thanks.

* You can add overrides in your model's userInfo but this isn't documented yet. We'll do that after cleaning up the naming a bit more.

* The next major release uses NSNotificationCenter for the reason you mentioned.

* We chose a single repo for now since our samples tend to span languages/devices. We'll revisit this eventually. Your point about submodules is a good one.

* We're not currently using NSIncrementalStore for the same reason as you (needed < iOS 5 support).

Re: Show HN: Simperium, a realtime data layer

#64
The website mentions that you are using google-diff-match-patch in the JavaScript client to merge changes, it seems as the API does not require the developer to actually specify things like "the user added an A at this position" as opposed to just "commit the changes to this entire object". Is there a reason other than simplicity for this API (I guess maybe because CoreData doesn't have that abstraction, and I presume your timeline was to start with figuring out how to sync CoreData), and on iOS are you also using google-diff-match-patch (there was not the same explicit mention of it in the documentation there)? (edit: Actually, I guess the comment from zbowling about DiffMatchPatch answers the second half of that. ;P)

BTW, this is generally really awesome: I am (right now, as in I'm sitting there right now ;P) helping teach a class on cloud computing at UCSB that happens to currently be discussing database synchronization and replication; after spending a bunch of time today discussing "how PostgreSQL is implemented and the basis of different isolation levels in the SQL standard and in MVCC" I took the time to tell everyone about Simperium (which probably makes more sense if I mention that I've looked into building something similar before for my projects; I'm glad someone else finally seems to be coming at it from the correct mindset). Everyone here seems to agree: this is going in a great direction.

Re: Show HN: Simperium, a realtime data layer

#66
post #64

The website mentions that you are using google-diff-match-patch in the JavaScript client to merge changes, it seems as the API does not require the developer to actually specify things like "the user added an A at this position" as opposed to just "commit the changes to this entire object". Is there a reason other than simplicity for this API (I guess maybe because CoreData doesn't have that abstraction, and I presum…

Thanks saurik! Yeah that's right, we've tried to make it as easy as we can for developers to use. One of our goals has been to let developers be able to work with data as they do normally if it were just local, while we handle figuring out whats changed.

Re: Show HN: Simperium, a realtime data layer

#67
post #43
post #21

Earlier quoted context omitted.

I'm missing something. This is just MVC style observer pattern. I get that it is well packaged/productized, but this is the kind of thing that developers have been doing for decades, with standard libraries for most of that time. Doing it with a browser is a bit newer, but ever since WebSockets it has been common place. A nice product yes, but I wouldn't expect this changes what developers are going to be able to do.

No, it is much more than that. You should watch the video, it demonstrates the platform solving some very hard problems with very little code. The key here is (I believe) operational transformation ( http://en.wikipedia.org/wiki/Operational_transformation ), the algorithm behind products like Etherpad and Google Wave. The observer pattern only handles the case where you have one client accessing the datastore. OT exp…

I did watch the video, but used poor semantics. :-(

Fair enough that it is multiple observer context and I didn't spell it out. It's essentially locking in an OT consistency model/control algo. I'll give you that sync is a really hard problem, but Etherpad, Wave, Google Docs, etc. are just a few examples of some off the shelf solutions (the Wikipedia page details more and doesn't even cover the whole set of what is out there, particularly if you consider version control systems). The big commercial success for generic document sync was probably Lotus Notes, and they made the sync solution a separate product product.

Again, not knocking the product, it looks like a quality solution and one I might even recommend, but I'm not sure I grok how one sees this as opening up a new set of possibilities.

Re: Show HN: Simperium, a realtime data layer

#70
post #41
post #38

Is every object on a separate timeline for purposes of operational transformation and synchronization? As an example where this would be noticeable, if I make a change to one object, and then a different one, am I guaranteed that everyone will see the first change before the second? Put from the different side, is it possible for me to not have seen changes on one object yet, but end up downloading a fresh copy of a…

Correct, each object is on a separate timeline for purposes of operational transform. If both clients are connected at the time the changes are made, then it shouldnt be possible to see the second change before the first. We keep an ordered history of all changes to all objects, though for efficiency, if a client that wasn't present when changes were initially made syncs, changes to multiple objects may appear in a d…

Ok, with those semantics (and I think I understand the basis implementations that would cause them), do you perform the "resync" step (which has the property that you can at least get the catch-up changes in a single bulk and hopefully fast download for the entire bucket, even with the internal reordering that happened over time) as a single transaction (by locking the persistant store coordinator); and if not, why?

With keeping the objects on separate timelines, do you or can you run into any problems with CoreData inverse relationships? I'd be concerned that my objects would have issues where a change got synced for object A that had it linking to object B, but somehow my application crashed before it got the synchronization for object B sent. I can imagine various reasons why this concern is stupid, including "saurik doesn't understand how CoreData works" (as I only even learned of its existence a couple days ago).

Post reply on HN