A honest comparison / contrast of ECA vs Rules?

Created on 9 January 2025, 3 months ago

Problem/Motivation

ECA and Rules address similar requirements

Hello, I have been away from Drupal development for a while and now I see that Rules appears to be production-ready.

Last time I worked on a Drupal project, this was not the case and looking for alternatives I discovered ECA and with great results, so I really appreciated the fact that ECA did the job (and a great one for that matter) when Rules was not a viable option.

Now coming back to Drupal development I would like to assess the two modules. I understand that there might be some sense of competition, but for the sake of the opensource community I would like to hear a honest comparison / contrast between the two.

The main points I would like to assess are :

  1. Stability
  2. Number of features

I do not care about UI friendliness. I need a solution that can handle the highest number of events / actions and that is production-stable.

πŸ’¬ Support request
Status

Active

Version

2.1

Component

Documentation

Created by

πŸ‡ΊπŸ‡ΈUnited States fortran77

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @fortran77
  • πŸ‡ΊπŸ‡ΈUnited States freelock Seattle

    Hi,

    Not sure there's a good person to comment on this -- I just became aware that Rules had a stable release earlier today, answering a client question. I used Rules extensively in Drupal 7, but found it too buggy and cumbersome to use broadly ever since Drupal 8 -- one of the key bugs we hit is still not fixed, after I created a patch for it 8 years ago: https://www.drupal.org/project/rules/issues/2816033 πŸ› Rules registers no listeners on rare occasions. Needs review

    ... that said it looks like there's a decent amount of activity on Rules in the past 6 months, after very, very little for most of the past 8 years.

    I started using ECA a little over 2 years ago, and I have not found anything I could do in Rules that ECA doesn't do, and it usually does it better. ECA has the advantage of starting in the Drupal 9 architecture -- Rules seems to still have a legacy architecture that requires info hooks to register plugins, and a lot of refactoring to do to be as streamlined, effective, and powerful as ECA.

    This means ECA plugins are really simple to create. ECA also supports just about every event Drupal dispatches, and supports core action plugins as well as ECA action plugins -- this means there's a lot of existing code that "just works" with ECA even though they were built with other systems in mind. That means you can do more with ECA!

    Aside from code, I see one significant architectural decision that seems different: Rules seems tightly integrated with Typed Data, whereas ECA is tightly integrated with Token. I see on the Rules page that they changed their tokens from Token module syntax to Twig syntax, calling out that this allows them to leverage the TypedData system to support any data property on the various objects involved, as long as the TypedData is set up correctly -- and point out that Token is generally limited to strings.

    ECA on the other hand has expanded its use of tokens to include objects and lists, as well as wrapping them in "DTO" - Data Transfer Objects. So this basically means the two systems have made a very different decision on how to solve the same problem -- passing structured data around. Both of these seem legitimate to me -- the typed data approach might lead to better (or at least easier) validation of data objects, but less flexibility. So that means it might be easier to find the data elements you need when working with Rules, compared to ECA where you're using the Token Browser which doesn't always show exactly the token you need.

    That said, I think there's a lot more support for tokens than TypedData, so that's another area where ECA might have the edge in terms of pure breadth of available "stuff" you can do with it, while possibly being harder to discover exactly how to hook it all up.

    The other differences that come to mind, take my feedback with a grain of salt -- we've been all in on ECA for over 2 years, and I have not looked at Rules since we switched over -- but here are my informed opinion of ECA vs uninformed opinion of Rules:

    - Lists -- ECA has a "list" token built in that allows loops, entire subroutines acting on each item of a list (or row of a view). Loops in Rules are cumbersome and confusing -- and "Rules Components" which allow you to do subroutines are on entirely different admin pages

    - BPMN -- I would not minimize how powerful it is to be able to visualize the flow of events, particularly when talking with stakeholders and less involved people.

    - Documentation -- there's still a lot of room for improvement here, a lot of stuff that's missing -- but Jurgen has done a fantastic job of setting up a documentation site, making it so all actions/events/conditions link to a doc page that lists tokens, etc. and is full of examples. He also did a series of videos that walk through a lot of different scenarios. But it's not just documentation of ECA -- in the BPMN modeler, it's easy for you to document your models. This is huge, particularly when you come back years later to change some functionality. There's a documentation field in each action, flow, and event where you can put notes, and you can attach freeform notes anywhere you want in the model. The Rules documentation seems woefully out of date -- but on the other hand when I last looked at it it was quite similar to Rules in Drupal 7, so maybe there's some old docs that still apply?

    - Performance - original versions of ECA might've carried a small performance penalty because it had code called for every event in the system which had to then check if there was any ECA model to execute. That's why there are so many submodules so you could turn off swaths of functionality. Now that's no longer the case -- ECA manages its event handlers so they are only run if the event exists in a model. I haven't seen any benchmarks of either ECA or Rules, and I don't know what sort of performance impact Rules 4.x has.

    Regarding stability, the move from 1.x to 2.x was a bit rocky -- a bunch of our models broke, silently. 2.x does have a lot better validation, and the event performance improvements which I think were really the cause of the breakage -- in 2.x the event registration is centralized and standardized, which meant a lot of the tokens that were defined in the original event plugins now need to be properly declared. These were easy to fix, but caught us by surprise. On the other hand, I'm seeing lots of issues in Rules that still seem to block a bunch of scenarios, and it wasn't marked stable for nearly a decade -- is it really stable, or just enough pressure to declare it so that it (finally) starts getting security team coverage and enterprise adoption (which is not meant as a slam, that seems totally legitimate to me). I think ECA has had so much more attention and excitement from the active Drupal community than Rules in the past couple years.

    So all in all, I think ECA wins in just about every category - the one thing Rules has that ECA doesn't is that tight integration with Typed Data.

    I'm quite curious to hear what others have to say...

  • πŸ‡ΉπŸ‡­Thailand AlfTheCat

    Perhaps just like the OP, I was a Rules orphan for many years, skipping D8 entirely because of the absence of a compatible release. Then I found ECA and I've never looked back.

    I've accomplished some extremely advanced scenarios using ECA and thanks to the BPMN IO modeler it's a delight to work with it. These readability these models introduce is fantastic.

    The previous comment covers all the bases, I'd like to add that with ECA, it's easy to integrate AI in many or any nook and cranny of your site using the brilliant ai_eca and ai_automator modules. The sky is really the limit.

    On top of all that, the patient, pleasant, and professional support from Jurgen and the team is amazing and that's extremely important to consider if you're working on important projects.

    I'll always love Rules for the many years of my life that I've spent with it. I haven't kept up with it and am happy it's moving forward. However I'm marrying ECA to death do us part.

  • πŸ‡ΊπŸ‡ΈUnited States freelock Seattle

    Just turned most of my response into a blog post, here: https://www.freelock.com/blog/john-locke/2025-01/ask-freelock-eca-vs-rules ... would love any comments people have on that, especially from people who have used Rules recently.

    Comments there are now auto-moderated by AI -- if you leave a relevant comment, it should get automatically published within 5 minutes!

  • πŸ‡ΊπŸ‡ΈUnited States fortran77

    Thank you very much for the great replies.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Thanks for all the great input.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen
Production build 0.71.5 2024