News for hackers. Stuff that matters.
Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by coffeemug on Tuesday May 17, 2016 @02:02PM (#11715821)
Hey guys, Slava @ Rethink here. The team is really excited to launch Horizon -- it's based on a lot of feedback from users of very different backgrounds, and we think it will make web development dramatically easier.

I've been up for about twenty-four hours, but I'll be around to answer any questions for the rest of the day.

Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by usaphp on Tuesday May 17, 2016 @03:47PM (#11716741)
> I've been up for about twenty-four hours, but I'll be around to answer any questions for the rest of the day

Make sure you don't regret about your answers later :) Answering questions on HN after being 24 hours awake is generally not a good idea :)

Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by akanet on Tuesday May 17, 2016 @03:49PM (#11716751)
Hey Slava. Interesting stuff - two questions:

1. Do you have something analogous to https://www.firebase.com/docs/web/api/ondisconnect? Real-time apps often have some manner of presence indicator. Firebase allows you to say "when this client disconnects, set the value of this key to $BLAH". I noticed that Horizon has http://horizon.io/api/horizon/#ondisconnected, but this is just a client-side indication of when you've disconnected.

2. What are Horizon's transaction properties? How about ordering of appends to a collection?

Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by coffeemug on Tuesday May 17, 2016 @03:55PM (#11716818)
There is currently no "disconnect-and-set" functionality, but it's on the roadmap and will happen soon. It just didn't land into v1.

Since Horizon is backed by RethinkDB, it's transaction properties are the same as that of RethinkDB. Check out this document for the specifics -- http://rethinkdb.com/docs/consistency/.

Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by akanet on Tuesday May 17, 2016 @04:07PM (#11716941)
Thanks for that. Can you clarify disconnect behavior in general? Do subscribed changesets resume if your internet blips?

Also, there doesn't seem to be a callback arg in Collection#store: http://horizon.io/api/collection/#store. This is worrying. How do I know if a write succeeded?

Edit: found http://horizon.io/api/collection/#subscribe - you chain subscribe to writes when you care about their success

Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by arcticfox on Tuesday May 17, 2016 @02:11PM (#11715893)
Hi Slava!

What do you guys think about the approach taken here, and what are the major differences in approach theat you took with Horizon?

https://github.com/mikemintz/react-rethinkdb

I've had really good luck with that whitelisting approach, so I'm wondering what the biggest wins would be from potentially switching to Horizon.

Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by coffeemug on Tuesday May 17, 2016 @02:33PM (#11716082)
Mike's `react-rethinkdb` project is really cool, but it's based on exposing the entire ReQL language to the browser. We thought this approach wouldn't work well as an industrial-strength product -- ReQL is designed to be accessed from the backend, and exposing a full query language to the browser introduces a number of challenges. Security is really hard, learning curve is steep, there are DoS challenges, the protocol is too complex to write platform-specific extensions, etc.

On the other hand, Horizon exposes a simple API/protocol that's easy to learn and easy to secure. If you need more functionality, you can import Horizon as a Node.js module and start writing backend code that accesses RethinkDB directly. The learning curve is much easier, it provides an upgrade path for sophisticated apps, and feels like a more robust product.

(I don't mean to disparage `react-rethinkdb`, I think the project is awesome, it's just a philosophical difference in approach)

Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by ChristianBundy on Tuesday May 17, 2016 @02:14PM (#11715931)
Thanks for your time!

Could you give me a quick comparison of Horizon and Meteor? I've used Meteor in the past (and loved it), and it looks like Horizon might be fun to learn.

Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by extrapickles on Tuesday May 17, 2016 @04:40PM (#11717226)
It looks to me like Horizon and Meteor are solving problems in different scopes of the application stack.

Horizon looks to be more like the Minimongo/DDP/Accounts parts of Meteor, and doesn't help with any more of the stack like Meteor does (eg: In Horizon its more up to you to wire it into Angular/React/etc). Meteor is more of a platform and Horizon is more of a real-time client DB and account framework.

If I had to choose between the two, Horizon would be good for if you had a strong opinion/technical need for very specific coupling between UI and DB, and Meteor for when you don't or need to get something out very quickly (eg: this weeks internal CRUD app for a few dozen users).

Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by cjbprime on Tuesday May 17, 2016 @02:17PM (#11715956)
There's one on the website:

http://horizon.io/faq/

Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by ben_jones on Tuesday May 17, 2016 @03:34PM (#11716620)
IMO it hand waves Meteor away without acknowledging (perhaps out of ignorance) some of it's other strengths.

I'll watch Horizon but I'm taking it all with a grain of salt. Standard new javascript framework protocol people.

Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by SomeCallMeTim on Tuesday May 17, 2016 @04:38PM (#11717209)
The FAQ repeats some things I've heard about Meteor -- specifically that its architecture doesn't scale.

But Meteor isn't completely prescriptive. There are several pieces that can be swapped out: You can use Angular, React, or Blaze on the client, for instance.

From what I've read, it doesn't look like Horizon is a complete framework, just a database client/server component that can be used with any framework.

Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by ben_jones on Tuesday May 17, 2016 @05:08PM (#11717434)
We have a short-burst, write-heavy, mostly cpu-bound, work-load, which according to the various financially incentivized critics would completely knee-cap us for our use of Meteor.

Except we:

1) optimized our database operations

2) relegated cpu-bound work to micro-services that could process work from a queue at their own pace

3) Leveraged the ecosystem to writer smarter and more concise code

Know your enemy and know yourself and you need not fear the result of a thousand battles (Sun Tzu). Meteor is an amazingly productive ecosystem for writing real-time applications. No it will not solve every problem you throw at it.

Just to be clear I'm not hating on Horizon. I definitely will try it in the future.

Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by SomeCallMeTim on Tuesday May 17, 2016 @08:03PM (#11718659)
OK, glad to hear that it does work for you. Sounds like you have a robust architecture.

I don't actually know what is supposed to "not scale" about Meteor. I've just read it multiple times. But because of the nature of Meteor (Really easy for anyone to set up! Anyone can create a real time app in ten minutes or less!), it probably attracts a lot of junior developers. It therefore should have occurred to me to translate "It doesn't scale!" to "I don't know how to scale it and my app is slow!!!". :)

Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by gchpaco on Tuesday May 17, 2016 @08:36PM (#11718828)
There are two major issues that crop up in my experience.

* Node as a runtime is deeply mediocre, in my experience. You can usually solve this by throwing more (usually virtualized) hardware at the problem.

* Meteor's architecture is (at present) tied into MongoDB's oplog tailing. You can scale it up through sharding, through alternate libraries, and DDP itself is not tied to MongoDB at all. IIRC fixing this was a goal for Meteor 2.0.

Both of these can be worked around. If nothing else, the Meteor web side will talk to anything doing DDP, and DDP is not that hard to deal with.

Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by ben_jones on Tuesday May 17, 2016 @10:16PM (#11719263)
It comes up because Meteor gets slow faster then most other solutions will get slow. It kind of reminds me in Django how a common mis-step for beginners is using an O(n^2) algorithm on the Django ORM. Meteor is the same way if you aren't using proper indices, or are trying do something that SEEMS doable to the uninitiated (like say pushing ~n thousand JSON objects into a MongoDB set), it's going to give you a bad time.
Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by qaq on Tuesday May 17, 2016 @09:13PM (#11718994)
"2) relegated cpu-bound work to micro-services that could process work from a queue at their own pace" doesn't this defeat the primary selling point of meteor?
Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by ben_jones on Tuesday May 17, 2016 @10:11PM (#11719240)
The three key features we derive from Meteor are:

1) real-time view layer

2) diverse and highly integrated ecosystem (libs are written just for meteor)

3) productive development environment (es2015 modules on client/server, no fuss build pipline for sass, jade, angular-templates, angular dependency injection)

There are a ton of secondary benefits, but thats the crux of it. Yes we do sacrifice some of the benefits of Meteor as a monolithic (homogenous?) full-stack solution, but I would argue that they are in fact small, and if you dive into Meteor you'll find it to be pretty modular.

Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by amelius on Tuesday May 17, 2016 @02:48PM (#11716221)
Are the transactions optimistic? How does the logic that concurrently applies/rolls-back these transactions over multiple clients work? I'm very interested in this, do you have some internal documentation on it?
Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by coffeemug on Tuesday May 17, 2016 @02:53PM (#11716267)
Take a look at this comment: https://news.ycombinator.com/item?id=11716145. TL;DR: currently not optimistic but will be soon; it's fairly simple to do because RethinkDB core has built in support for it. Once the feature lands we'll talk about the implementation in detail.
Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by amelius on Tuesday May 17, 2016 @03:56PM (#11716823)
Okay I can wait :)

But without optimistic transactions, what sets Horizon apart from just running the transaction-code on the server? If I understand it correctly, the latency will be the same in both cases, i.e., one network round-trip.

Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by coffeemug on Tuesday May 17, 2016 @04:16PM (#11717022)
Ease of use.

Lack of optimistic updates is a temporary state, though. The vision for Horizon definitely includes this functionality, and we'll make sure it lands ASAP.

Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by tejasv on Tuesday May 17, 2016 @07:34PM (#11718509)
Once you guys made it big, you should rename yourselves to RethoughtDB :)
Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by jlu on Tuesday May 17, 2016 @08:27PM (#11718786)
Does it handle conflict resolution, ike when two people modified the same field at almost the same time?
Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by danielmewes on Tuesday May 17, 2016 @09:39PM (#11719126)
Edit: While Horizon assigns versions internally, it looks like they are not currently used for catching concurrent client-side modifications by different users. (I previously wrote that they would cause the "losing" write to fail if it was based on an outdated version of the data, but that doesn't seem to be the case yet.)

I opened an issue against our docs to add information on this, as I'm a bit fuzzy on the detailed behavior myself: https://github.com/rethinkdb/horizon-docs/issues/50

Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by lux on Tuesday May 17, 2016 @02:20PM (#11715972)
Congrats on the release! I've only hada little time to play with it so far as a beta user, but was super impressed and can't wait to use it on a real project soon. Cheers!
Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by android521 on Tuesday May 17, 2016 @11:30PM (#11719523)
Hi, Slava, I was a web developer and now I am a mobile developer. Nobody is developing web applications anymore (at least in developing countries). We are all mobile first. How does android or ios developers take advantage of Horizon ? Can you give a few examples? How does horizon make mobile (native) developers life easier ? web development is slowing down and mobile development is on the rise. Mobile developers don't want to deal with backend development. But it seems like web development is your main focus and mobile is a second thought. Please make it the focus of your work. Meteor is useless to us because it is optimized for web client. I hope Horizon won't fall for this trap. Your bigger audience and potential users are android or IOS developers. Please optimize for them and provide lots of examples to show them how their life can be easier. Thanks.
Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by pablasso on Wednesday May 18, 2016 @12:49AM (#11719823)
I'm from a developing country too and that is such an exaggeration. Maybe your career has been focused on mobile, but no way there's overall more native development than web.
Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by shadow68 on Wednesday May 18, 2016 @07:59AM (#11721271)
Web developer here. Some of the most complicated application are being built for web vs mobile. Within the enterprise web applications, I fail to see how mobile is anywhere near web's presence especially for data intensive apps.
Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by izolate on Wednesday May 18, 2016 @02:26AM (#11720150)
So what does your dumb mobile client connect to? If it's any good, probably a web backend.
Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by jaxondu on Wednesday May 18, 2016 @04:36PM (#11725694)
In the FAQ page http://horizon.io/faq/

Can I use Horizon on mobile devices?

Horizon ships with a JavaScript client library that can be used for building web and mobile apps with frameworks like React, Angular, or React Native. We’re also working on specific platform client libraries that support the Horizon protocol. Client libraries for iOS and Android are coming soon.

Re:Horizon 1.0: a realtime, open-source JavaScript back end ... by frostymarvelous on Wednesday May 18, 2016 @12:16AM (#11719690)
Very fitting handle.

Im really stoked for this and thanks a lot for your hard work.