Could Elixir ever support a good plugin system and wouldn't it be awesome if it did?

I had to search around for a CMS for a project recently. It was the first time I’ve had to do that in years but I was surprised that nothing seems to have changed in the past 10 years. Most of the search results were for PHP and there’s a good reason for that.

I’m not a fan of PHP but language bashing aside it has one fantastic thing going for it which is you can create plugin systems with little effort because everything is just run from top to bottom. You include a file somehow and it gets run with everything else. Wordpress etc just do this. It’s primitive but it works.

Of course, you could say this a bad thing because this could lead to some awful spaghetti code and security concerns (which is true) but I’d argue this “plugin-ability” lead to some really great movements on the web particularly open source projects.

Some nice things that “plugin-abilty” could give you

  • More people can contribute in more ways
  • More likely to lead to popular open source projects like CMS’s, forums, shopping carts
  • Broader audience - not just corporations that understand software development
  • Might make it more accessible for kids, hobbyists, and non-professionals plus get them interested in the language, which I think is nice
  • Can lead to ecosystems like Market Places, App Stores, which can’t be bad either

I don’t think it’s possible to build something in Elixir that could do this right now. I might be wrong, but I can’t see how you could create a web interface that uploads something then recompiles that something into your app. Someone might correct me here though.

So I’m just putting it out there. Would it or could it ever be possible to do a real plugin system in Elixir?

3 Likes

CMS is more web related, You might think of plugins for Phoenix.

But the fact that Elixir is compiled makes it more complicated to just drop a plugin :slight_smile:

True, I get that. It might even be impossible. I just think it might be great if it were possible :slight_smile:

There are no build tools on my production server, but that does not mean it’s impossible, and there is hot upgrades :slight_smile:

I don’t think so. It should be trivial to drop a compiled module to a known location and let the BEAM load that module.

And exactly this is the thing that makes the plugin system quasi-built-in, all you have to do is “simply” defining an interface for the plugin…

2 Likes

Yes it is possible, but I remember some previous warnings doing this :slight_smile:

You do not get any sandboxes with about any other plugin system that relies on loading foreign code.

If you want a sandbox, there is nothing you can do except for evaluating the code on your own and not by the environment…

2 Likes

It should be possible, but we already have complete solutions like WordPress, Joomla, PhpBB… for this advanced kind of things, so it would be a waste of time creating just the same in Elixir, if you need a personal customized solution for you, I’d recommend embedding the plugins inside the whole app.

It’s such a pain creating a general CMS solution, as you need to think in terms of reusability, modularity and extensibility among other things. The more use-cases you want to cover, the more complex it becomes.

We’re discussing pretty much the same here: Web Forum Software in Elixir / Phoenix

1 Like

Thanks @NobbZ I didn’t understand that it would work this way until now

@adrianrl That’s so interesting that you’ve been having a similar discussion about plugins at the same time. Maybe there’s something to it.

It’s not that I’d want to recreate Wordpress or Joomla etc. I strongly dislike all of those solutions. I was more making a point that I don’t think there’s been any innovation in any of these areas for a long time. Even sadder I think the trend has gone over to just going commercial SASS products for things like content management or shopping carts.

My point was more that Elixir/Phoenix might be well placed to bring about some new innovations if people were trying to build plugins for general purpose apps rather than just products for companies. Where your thread mentions Firestorm, that’s a good example. Maybe if it had some way of being extensible it would be more alive?

1 Like

It’s even worse, the compiled code doesn’t even have to be in a file. If I can get a binary containing the compiled code to the node then I can load it with the BIF :erlang.load_module/2. All I need is to be able to run a shell on the node and I am in and can do anything.

And we will not mention distribution here which makes it trivial. :grinning:

2 Likes

The idea of a certified module has been floating around for ages. Basically the runtime only loading a beam which has been certified/encrypted via a key. Might make a good research topic for a graduate project.

4 Likes