alanxoc3 / concards

A flashcard note app
GNU General Public License v3.0
8 stars 0 forks source link

Create algorithm plugin system #45

Open alanxoc3 opened 4 years ago

alanxoc3 commented 4 years ago

When I first had this idea, I was thinking that plugins could be in Python. I'm actually against that idea now for a few reasons. One reason is that it is more work to translate between languages. Another is that it forces an extra dependency. And another is that python has quite a big overhead.

But go-plugin looks promising. Technically, the plugin doesn't even have to be written in golang, it could be written in any language. The nice thing about it though is that there are no extra dependencies needed. And everything the plugin would want to use are already available in a module.

So this case is to research into and implement go-plugin or something similar. Plugins should be contained in a folder and the name of the file would be the algorithm name referenced in .concards-meta.

I like this idea. It's pretty solid now. And super lightweight.

alanxoc3 commented 4 years ago

Adding to this. Should the plugins specify the version they were written for? One minus to this is that I might have to keep track of things in the main codebase. But a plus would be that I could change inputs and outputs for plugins relatively easy.

I guess I should think about how likely the API is to change.

alanxoc3 commented 4 years ago

About half of this has been addressed in my latest refactor.

alanxoc3 commented 3 years ago

Hmm.. I think plugins could be solved by using hooks. Why not? Kakoune does this. I think terraform kind of works like this.

If I use hooks, then the plugin could be any executable. I just needs a specific name. I'm currently creating a basic listener hook as part of #109. I think this could be extended to algorithms later.

A benefit of hooks is that information is communicated via stdout/stderr. This means the hook program could also be reused for other things.