From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: "Alejandro R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: Musings on RxAda Date: Thu, 22 Oct 2015 18:41:22 +0200 Organization: A noiseless patient Spider Message-ID: References: <75f38e30-42ba-4e98-8f36-2218b5167209@googlegroups.com> <1wvo1b25eaa4o$.1y03vu1to6vux$.dlg@40tude.net> <18xpt5oxiz5nw$.klh515586pjp.dlg@40tude.net> <3a82a370-2175-4cf6-90e1-64fb19d794ff@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit Injection-Date: Thu, 22 Oct 2015 16:39:13 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="826cc6ce18acb660eb2ad190ef62dc45"; logging-data="11421"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+7iCbmP1fRXZfw5FufWkc+" User-Agent: KNode/4.14.6 Cancel-Lock: sha1:nnWK+NqtVyx6xI8lgGaQ9K/E10Y= Xref: news.eternal-september.org comp.lang.ada:28035 Date: 2015-10-22T18:41:22+02:00 List-Id: Dmitry A. Kazakov wrote: > On Thu, 22 Oct 2015 13:02:46 +0200, Alejandro R. Mosteo wrote: > >> Observable.fromClickEvents(SomeButton) >> .onWorkerThread() -- To ensure we are not blocking the GUI thread >> .count(during => one_second) -- This could be any costly operation >> .onGuiThread() -- Switch back to GUI thread >> .subscribe(count -> SomeTextLabel.setText(count)); > > This looks like a plain active object. On click you simply call its > primitive operation Count, straight from the event handler. The > implementation of Count calls a task-safe SetText which marshals back to > the GUI messages loop. Basically, 2 source code lines. It might be so in this particular made-up example. I guess many cases of observables and filters in the RX framework are indeed active objects. > There is not much use in this anyway. In a real-life GUI it is far more > complicated. When a detached asynchronous operation starts, you normally > need to be able to indicate its progress, to be able to cancel it, have to > deal with MVC mess etc. As an example see how GPS handles the "build" > button clicks. A crude mechanism like Observable would not scale. The GUI was an example, the methodology has no specific purpose. For me, the interest is in how such a thing (the RX framework) could be implemented in Ada resulting in similar effort and clarity for the user as in other languages. Here's a real use example if you're interested: http://techblog.netflix.com/2013/02/rxjava-netflix-api.html It would take someone more proficient on the framework than me to discuss the MVC/scalability issue. >> What I see interesting of this methodology is that it basically hides (in >> theory, of course then you read about nightmare histories) the explicit >> definition of tasks, > > It does not if you have to specify tasks. Active object does. > >> problems with race conditions and data integrity, > > I don't see why and how. It is too low level to judge. Especially > integrity, because you seem ignore GUI elements bound to the detached > execution. A typical problem is when SomeTextLabel gets killed while your > thing keeps on counting... I've left out everything about unsubscribing and error management in my effort to keep things simple. >> The power of the setup comes with the huge number of predefined operators >> that exist in the library. It's the closer to "chaining blocks" in >> something like Simulink I've experienced in code. > > It is a poor analogy because Simulink is 100% synchronous. (We are using > that to make real-time out of the simulated one. In a custom Simulink > block we do "delay until", and here you are, all simulation gets blocked.) I was referring to the user experience connecting blocks, not about the implementation of the blocks that Simulink uses. Sorry if I was unclear. The Lego Mindstorms graphical blocks language would be a similar experience. Perhaps Scratch too.