Slashdot Mirror


Can Reactive Programming Handle Complexity?

Nerval's Lobster writes "A recent article on Reactive Programming, which suggested that five lines of Reactive could solve a problem that required 500 lines using Java or 200 lines using triggers, led many readers to question (passionately) whether Reactive enables you to address not just typical problems, but complex ones as well. In a follow-up column, Espresso Logic CTO Val Huber argues that, while it certainly can't solve all use cases, Reactive Programming is very capable of addressing many complex problems, and can address all other scenarios via a transparent integration with procedural languages. He shows how Reactive can handle complexity using two different scenarios: a classically complicated database application (a bill of materials price rollup) and procedural integration (to address external systems such as email and transactions not limited by a database update). Take a look at his work; do you agree?"

37 of 149 comments (clear)

  1. Also by oldhack · · Score: 2, Insightful

    Can bullshit walk?

    --
    Fuck systemd. Fuck Redhat. Fuck Soylent, too. Wait, scratch the last one.
    1. Re:Also by logjon · · Score: 3, Funny

      Don't know about walking, but it can clearly get posted to Slashdot.

      --
      The stories and info posted here are artistic works of fiction and falsehood.
      Only fools would take it as fact.
  2. A few problems... by Ckwop · · Score: 5, Insightful

    A few problems:

    - What about circular reactions?
    - Is SQL really that right language for encoding business logic?
    - Triggers are kind of an anti-pattern.
    - What about atomicity? What if I need the whole reaction chain to work or none of it.

    I'm afraid there more questions than answers with this proposed pattern.

    1. Re:A few problems... by Anonymous Coward · · Score: 2, Interesting

      It's the third (at least) Slashvertisement for this useless new ... whatever it is they are trying to sell.

      It has potential to get management buy-in because it works exactly the same as Excel. However, it will not get acceptance in the IT departments because it works like Excel but with no explicit statement about the questions you have raised and likely more as well.

      There are situations where tables & triggers* are the best way to sort out a problem. There are places where dedicated matrix algebra would solve the problem most efficiently. You can either learn what tools are available and use the one that seems like the best fit, or you can master one tool and apply it to everything, both work because in the end you're still translating a vague idea into something that can become distinct instructions for the same computers.

      *I think I just started development on the 3rd worst D20 product.

    2. Re:A few problems... by LoRdTAW · · Score: 2

      Is SQL really that right language for encoding business logic?

      Probably not. And especially not if you would like your DB to be portable between various DB's.

    3. Re:A few problems... by lgw · · Score: 5, Insightful

      - Triggers are kind of an anti-pattern.

      Well, sort of the point of this style is to embrace triggers as a powerful and underused tool. I'm a big fan of powerful and underused tools, but generally there's a reason they're underused.

      Pick the right tool for the job. Reactive programming seems like it makes life wonderfully easier for this very narrow set of problems. That's neat. But both trying to us it for everything and insisting that it's useless because it doesn't work for everything are mistakes. Like a power screwdriver with a U-joint attachment, some tools go from pointlessly awkward to awesomely helpful when faced with a particularly-shaped niche.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    4. Re:A few problems... by Qzukk · · Score: 5, Funny

      I think I just started development on the 3rd worst D20 product

      *rolls a 1*

      Your fingers fumble over the keyboard, striking keys almost under their own accord.

      UPDATE customer SET lastname='Jones'

      *rolls save vs. WHERE clause... 3*

      ;

      With horror you look on as you strike a glancing blow to the enter key.

      --
      If I have been able to see further than others, it is because I bought a pair of binoculars.
    5. Re:A few problems... by Ziggitz · · Score: 2

      It is taking away exactly the key features that languages like Java have that make them ideal for business logic. It takes away the generalist properties and ties each line of code into a database process, removing the separation of logic from implementation. It encapsulates functionality without giving access to it by tying procedural code to relationship statements rather than to actual calls, making it extremely vulnerable to the law of leaky algorithms, making it more difficult to both debug and optimize. There's no way this could actually produce scalable, stable codebase that you could use to provide a large scale solution to any business problem.

      --
      There is no memory shortage. yes I have heard of XFCE. Go away.
    6. Re:A few problems... by leandrod · · Score: 2

      Is SQL really that right language for encoding business logic?

      Yes, SQL is quite adequate, more so than most due to being declarative. The issue is not SQL per se, but poor support for it in everything but PostgreSQL and IBM DB2. The advantages of procedural languages (including OO and functional ones) are more in standardisation than in the language per se.

      --
      Leandro Guimarães Faria Corcete DUTRA
      DA, DBA, SysAdmin, Data Modeller
      GNU Project, Debian GNU/Lin
    7. Re:A few problems... by ZahrGnosis · · Score: 3, Insightful

      I don't know about "anti-pattern", but they cause trouble because they cause other code to be non-deterministic and it's very difficult to create patterns around that sort of behavior. They're practically the logical equivalent of the "COME FROM" in Intercal, which was originally a joke for goodness sake. I was flabbergasted when I found out people are vaunting code that actually works this way. It's particularly painful in implementations where the "reactions" can override program flow with errors or silent rejection or just running off and doing whatever they want. It's nearly impossible to debug since reactions (triggers) are almost always coded in a language or paradigm separate from some procedural language used to provide the UI or whatever other layer is being reacted TO.

      I just don't like it! But that's just me.

    8. Re:A few problems... by SQLGuru · · Score: 2

      Purely bogus argument. The counter is "put it in the database because it allows you to change out the front end". Both are stupid arguments because when you get around to rewriting anything, you're going to rewrite both layers. [Caveat for a company that sells their software -- having all of the code in one layer allows you to sell to more clients.]

      Put the code in the right place. For large / massive data processing updates or crunching reports, the database is much more performant than doing it in the front-end code. For CRUD actions, having the work be performed in the front end makes the app more responsive.

      I'm an application developer who has extensive experience as a database developer (not a DBA). I'm in favor of implementing keys and relationships to ensure that your data remains pure (bad data is one of the biggest reasons that analytics is "hard"). I'm also in favor of triggers and stored procedures if it makes sense in the context of the application. But I'm not opposed to reading a set of data into memory and looping over it when it makes sense as well.

    9. Re:A few problems... by Chrisq · · Score: 2

      A few problems: - What about circular reactions? - Is SQL really that right language for encoding business logic? - Triggers are kind of an anti-pattern. - What about atomicity? What if I need the whole reaction chain to work or none of it. I'm afraid there more questions than answers with this proposed pattern.

      Yes, TFA is a bit like saying "a hammer is better than a screwdriver because it was quicker at getting a nail in"

  3. No silver bullet by Rumagent · · Score: 4, Insightful

    It is a tool. Like any other tool you apply it when your skill and experience tells you to. I belive the term commonly associated with this is "professional".

    1. Re:No silver bullet by jythie · · Score: 2

      Yeah, but there is money to be made in claiming your tool is appropriate far beyond its domain.

  4. Problem as I see it... by Anonymous Coward · · Score: 2, Interesting

    It appears that reactive programming would require an incredibly bloated and powerful backend. In effect, it moves most of the logic to the framework and allows the programmer to just hook a few pieces together. I can't imagine it scaling well with all the extra event notifications one would introduce. It looks like it would change from one event causing the execution of a chunk of code to multiple chained events triggering a conditional series of smaller chunks of code.

    The problem lies in the overhead of notifications.

    It might be "fewer lines of code" to write, but there's just no way in hell it could be as run-time efficient.

    1. Re:Problem as I see it... by serviscope_minor · · Score: 2

      It appears that reactive programming would require an incredibly bloated and powerful backend. In effect, it moves most of the logic to the framework and allows the programmer to just hook a few pieces together.

      In the last thread on this, some slashdotter answered my question and pointed out that VHDL is a reactive language, since x=y means x is connected to y, so y will propagate to x on the next clock pulse and so on throughout the entire circuit.

      This fits the model for FPGAs pretty well.

      It's fair to say that it does move most of the logic to the FPGA iteslf :)

      So, it can scale well and do all the things well, if it has dedicated hardware to run it on. Fortunately, such things exist, are quite common and are showing no sign of dieing out.

      --
      SJW n. One who posts facts.
    2. Re:Problem as I see it... by TechyImmigrant · · Score: 2

      >VHDL is a reactive language, since x=y means x is connected to y, so y will propagate to x on the next clock pulse and so on throughout the entire circuit.

      And VHDL, as typically used, is completely static. that's because hardware is completely static. You can't just instantiate a new flop in your CPU. They're stuck there where you built them.

      In it's various forms, this is known as CSP, Actors, Dataflow Programming, SISAL (Remember that?) and Excel. There are many others. Any producer-consumer message-as-event passing system.

      --
      I should use this sig to advertise my book ISBN-13 : 978-1501515132.
  5. of course it can by istartedi · · Score: 5, Insightful

    x = new WonderfulObject();
    x.Invoke("5000 lines of C that somebody wrote");

    --
    For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
    1. Re:of course it can by istartedi · · Score: 5, Insightful

      But if developers are constantly writing slight variations on the same 500 lines of C, why not encapsulate it?

      Sure, no problem with that. After all I just typed that into a text area in a web browser and hit send. There were probably *millions* of lines of encapsulated code in that one instant. The difference is that I'm not pretending that hitting "Submit" is the same as writing a web browser, a network stack, router firmware, etc. I didn't solve any problems. Those guys did.

      --
      For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
    2. Re:of course it can by phantomfive · · Score: 4, Informative
      Your comment made me laugh, but then I read the article, and that's exactly what the author said. From the article:

      "Reactive Programming is very capable of addressing many complex problems, and can address all other scenarios via a transparent integration with procedural languages."

      --
      "First they came for the slanderers and i said nothing."
    3. Re:of course it can by maxwell+demon · · Score: 2

      That way I also can easily write a very powerful build environment:

      #include <stdlib.h>
       
      int main()
      {
        return system("make");
      }

      I leave obvious improvements to the reader. ;-)

      --
      The Tao of math: The numbers you can count are not the real numbers.
  6. Yes by i+kan+reed · · Score: 2

    I concur.

  7. 5 lines and i don't know what they do by shadowrat · · Score: 4, Insightful

    I don't know what the 500 lines of java code are, but i guess they are grabbing input and cleaning it and opening database connections and whatnot. assuming that he's counting import statements and puts curly brackets on their own lines. sure 500 lines.

    I don't know much about this Reactive stuff, but i don't see anything in this sample code that tells me where the input is coming from or where it is going to or if it's being cleaned in the process. Somehow Reactive also creates an environment in which nothing unexpected ever gets entered?

  8. The usual consulting snake oil by engineerErrant · · Score: 5, Insightful

    As background, I am the director of engineering in a small Java/Postgres-based shop. We run a cloud backend for our mobile apps.

    This "methodology" reads from the first sentence like an extended infomercial for a consulting shop, or a company trying to create the aura of "thought leadership" to get more investment cash. The formula is simple and time-honored: (1) arbitrarily single out a well-worn software practice to receive a snappy marketing name and be held above all other practices, (2) claim it's new, and (3) offer to implement this bleeding-edge buzzword to clueless executives. For a small fee, of course. It's the same formula that gave us Agile.

    In my opinion, what they've described here is a large step *backward.* Not only is this a relatively trivial use of the GoF Observer pattern, but bizarrely, it's done in SQL using triggers, causing immediate database vendor lock-in and creating a maintainability nightmare. It's how software was made back in the 90s when Enterprise SQL database vendors ruled the land. Sprinkling business logic around in the SQL instead of centralizing it in a much more suitable language for logic like Java is a completely terrible idea, unless you're an Oracle sales rep.

    This one is safely ignored.

    1. Re:The usual consulting snake oil by engineerErrant · · Score: 3, Insightful

      That's certainly valid that proper organization is far more the key to good code than the use of any language - my comments should not be taken as an ad for Java or any other specific technology.

      That said, certain language features lend themselves to good organization much better than others. Where SQL faces challenges is that (1) it's mostly a declarative language using set calculus, which (again, in my opinion) makes it ill-suited for non-trivial business logic, (2) because of the aforementioned, it can't be hooked up to a debugger in any normal sense, making maintenance and troubleshooting that much harder, (3) it's a separate "codebase" and technical competency than the "main" codebase (whether it's in Java, C#, Ruby or whatever), thus creating a competency barrier that must be crossed every time work needs to be done on that code, (4) it's not stored with the main codebase, but as a form of data, raising the issue of out-of-sync deployments with the app servers, and (5) far fewer developers know it well enough for complex uses than typical app-server languages, making staffing difficult.

      Finally, I have personally always found large codebases much more manageable when written in a statically typed language (which SQL is obviously not). Not wanting to spark a flame war with Ruby or PHP fans, though, I will caveat my statement that those languages are also much better suited for business logic than SQL's declarative style is.

    2. Re:The usual consulting snake oil by munch117 · · Score: 2

      All the links point to slashdot.org/topic/bi/...
      That counts as definite proof that the article is BS.

    3. Re:The usual consulting snake oil by St.Creed · · Score: 4, Interesting

      Two points here I think:
      1) Yes it is possible to build maintainable triggers - I'm doing it right now, as a matter of fact. However, it's certainly not my first choice since it's (a) hard to debug when they cascade and b) performance is hard to keep under control as they proliferate. Just look at Oracle's older products (or heck, look at Apex) and the huge amounts of triggers firing for even the most simple of tasks. It's a weed that you have to control rigourously or it will grow out and suffocate your software. It is NOT a best practice to use triggers if you can avoid them, they're a last resort if all other options are off the table.

      2) Centralizing the business rules has a lot of repercussions beyond the technical side of things. Look at BeInformed's products for that. With proper definition of business rules, a good business rule engine can generate most CRUD-code from scratch, dynamically populating the screens with the required fields. BeInformed's latest product even generated the workflow at runtime, all business rule based. It was much more advanced than reactive. Unfortunately they invested too much and they're now up for grabs as they went under. As I understand it, SAP and Microsoft are fighting over the remains. Which is a much better buy than Reactive.

      I'm sure you can find an edge case where some platform can't access the centralized business rule repository, or needs an exception. Or it becomes inflexible and unwieldy. Those are generally signs of failing organizational processes, not technical issues.

      That said, there's another point: why can't databases integrate with business rule engines? We're still stuck with constraints from the 60's, even Domain-Key constraints have to be programmed instead of declared. Databases could leap forward if they would deal properly with time, versioning, and business rules. Instead, we get slightly higher marks on the TP benchmarks. That's useless.

      --
      Therefore, by the (faulty) logic you're using, you're just a cow with a keyboard - osu-neko (2604)
    4. Re:The usual consulting snake oil by ADRA · · Score: 2

      Rule Engines are one very tenuous issue. Here are some thoughts on them as I see them:
      1. It requires businesses significant overhead to bring in expertise to allow developers / architects / solutions providers for new products, but
      2. most products are legacy, so when moving into a business rules eninge model, you need to essentially re-implement everything you've ever done, because
      3. Integration with a system of this sort becomes very difficult, and somewhat unmanagable, especially when these outside systems share much of the same behaviour

      I have a customer who's debating 'replacing the crown jewels' with a rules engine, and every time I hear them talk about it, it makes me cringe. This mind you is replacing the implementation of 10's of millions of lines of code and hundreds or even thousands of inter-dependent data elements with multiple workflow stages increasing the complexity factor. The higher ups just don't realize how complicated their system really is and someone was like 'fuck it, its the new buzz word!'.

      --
      Bye!
  9. Looks more like a formula by Anonymous Coward · · Score: 3, Insightful

    Having read TFA, it looks to me like all they have done is compared a schema which was not properly normalised, with something which was; for example the 'reactive' code calculates total cost as quantity x price, where as the author is conjecting that the SQL version would have a total-price field, and therefore have to have '500' lines of code to keep this field updated.

    Smells like snake oil to me.

    You have to ask, "Why would the SQL schema need a totalprice field?"
    If your business logic says that the totalprice is always Q x price, then ditch the field and ditch all the code which enforces the relationship. But ... then you have to recalculate the totalprice every time you look at it.

    There are other examples of denormalised data in the sample provided, and in all cases the 'reactive' code simply calculates the value on the fly - and as other commenters have mentioned, this blows up as soon as the business rule is no longer valid, such as "when a product's price is changed, DONT change the price on quoted or shipped orders, DO change the price on scheduled or reoccuring orders"

    1. Re:Looks more like a formula by rjstanford · · Score: 2

      And "this customer gets a 3% discount except on orders in the first month of the quarter when its 5% because they're massive and we want to encourage them to book early..."

      --
      You're special forces then? That's great! I just love your olympics!
  10. Re:Drive-by disagreements by TechyImmigrant · · Score: 2

    No. He's an Anonymous Coward.

    I'm British.

    --
    I should use this sig to advertise my book ISBN-13 : 978-1501515132.
  11. Marketing Hype... by mrthoughtful · · Score: 3, Informative

    This is just marketing hype dressed up as a question. Having said that, anything that gets anyone enthused about programming is good, I guess.

    What I really don't like is when Val Huber refers to a previous article he submitted as if it were written by a third party.
    Now, I love SQL (and triggers are ok) - and so does Val Huber - I'm sure we would get along fine.
    Val, you've been doing SQL for 20 years! woot. So that means you started back 'round '94.
    (Aw. I started back in '85. I was doing websites in '94 - remember Lycos?)

    But it's just using SQL Triggers, Val - why give it some sort of fancy name? Ohh everyone else does that, like "Web2"? or "The Cloud", etc?
    Still stinks - but hopefully someone may actually pick up how to use some of the cool features of SQL.

    --
    This comment was written with the intention to opt out of advertising.
  12. Ditto by goombah99 · · Score: 5, Insightful

    I've done reactive programs. They make fun little interface gizmhos. But holy shit, try debugging something that does something complex. You can't assure when, where and how variables might be changing in some outer reaches of your program while another part of the program is assuming they are momentarily fixed. It's going to be unpossible to seriously optimize a reactive program.
    So yeah for silly data base queries of simple mathematical calcs go for it. Complex programs. run away

    --
    Some drink at the fountain of knowledge. Others just gargle.
  13. Labview by goombah99 · · Score: 2

    By the way, I thought I'd add, the only reactive style language that I've really found could get modestly complex and still not be incomprehensible is Lab view. It's event driven, and the you can literally see where and how a variable is being modified with the wires it draws (unless you like using globals. The problem with labview is feeding a wire through a lot of graphical levels is so annoying that you end up resorting to globals more than you should.). Labview takes a really different mind set to do well but anyone can be crappy at it and get the job done. It's the only program I've felt comfortable modifying in the middle of an experimental run. It's just really robust in that the errors one makes tend not to be fatal. Maybe it's because visually you can see the logic and know the scope of any side effects. But major application complexity? nope. Get complex interfaces hacked together fast? yes.

    --
    Some drink at the fountain of knowledge. Others just gargle.
  14. lazy and memoized by goombah99 · · Score: 2

    It is a tool. Like any other tool you apply it when your skill and experience tells you to. I belive the term commonly associated with this is "professional".

    My experience is that nearly anytime you see a problem reactive programming could address you would be better off designing a program in which evaluation is lazy, and every calculation is memoized. Spend a little time designing for laziness and memoization and there's no need to lock everything into being based on a reactive language.

    --
    Some drink at the fountain of knowledge. Others just gargle.
  15. Apologies to Douglas Adams by Hognoxious · · Score: 4, Funny

    The Americans considered themselves the winners because afterwards America became an entirely separate country. The British considered themselves the winners for exactly the same reason.

    --
    Confucius say, "Find worm in apple - bad. Find half a worm - worse."
  16. Non-trivial by Livius · · Score: 2

    address not just typical problems, but complex ones as well

    If they find that complex problems are not typical, that tells us a lot about the scope of their experience.