DEV Community

loading...

How do I create a desktop app that easily allow plugins?

patarapolw profile image Pacharapol Withayasakpunt ・1 min read

Of course, the desktop app will be open sourced; but I don't want people to have to recompile, just to easily write a plugin.

An idea of mine is to use Deno (~15 MB) or NW.js (~100 MB) (and not sure about Electron), so that it can easily pick up the JavaScript code in a selected directory, and run on the fly, without compiling.

Python would be another idea, but I am not exactly sure how to...

Is there a better idea?

Discussion (10)

pic
Editor guide
Collapse
zoedreams profile image
☮️✝️☪️🕉☸️✡️☯️ • Edited

basically its sounding like you need a design pattern for a modular architecture. This stuff is pretty hard in comp sci, but your a smart pho so i think you will have no problem.

stackoverflow.com/questions/497856...
you need to write some code which scans a directory which the mods are stored in. You create a standard which loads them in a specific order of your choosing.. like by date or name, or version etc... usually by name. you could also make a algorthm to generate a unique guid that represents the mod.. think crc hash but on the name and version. Then you must be consistent and load them in the same order.

you need to program your functions to be data driven. Also you mods will overload existing functions, or add new functionality. It could also include additional assets which can be used by your new modular code.

If you author your mods in the same language as the code base then its a bit easier. You will not have to transpile into the language. You can also use scripting language to create your own scriptable objects. rather than say grab data from memory or a database, pull it from the mod dir in your filesystem. Interpreted language like JS you do not need to compile to run.. however LLVM like rust or c++ you will need to compile and basically restart the app.

if i had to choose i would use a python interpreter to ingest your script objects. python is actually excellent for this. I wish the game industry used python.. In fact this is exactly how Blender works.

anyways HMU if you would like help. this sounds super fun. Thank's doc!

Collapse
patarapolw profile image
Pacharapol Withayasakpunt Author

I actually realized that at least Golang (via Otto) and Java (via Nashorn / GraalVM) can also parse JavaScript on the fly. Python is much less supported.

Of course, if I use Java, I can also parse JAR or JVM bytecode on the fly.

As for how I can make it, I can see two ways,

  • Serialized data (maybe JSON)
  • Hooks
Collapse
zoedreams profile image
☮️✝️☪️🕉☸️✡️☯️

Have you looked into RUST?

Honestly i would stay away from java, there is a heated copyright war going on between oracle and google, which oracle is trying to make API copyright. Java seems to keep migrating further and further from OSS>

I like Golang, but haven't had the fun to get to apply it yet. C# is an option. Within my unity mono framework this stuff is cookie cutter. I know most people use it for games, but you can use it to design web sites and productivity apps for engineering and medical.

JS is probably one of the most extensible flavors for what your trying to do, however its JS. Typescript might be more favorable since you will be working with alot of data driven stuff and parsing. Basically you need to write en.wikipedia.org/wiki/Interpreter_... that translates scripts into overloads.,

you can also write your own DSL. This is what i invented dragon for, but its so new i haven't been able to work on it. github.com/ZoeDreams/Dragon Maybe my diagram might help?

my only advice is to just try to get a single overload working. and adding in a dir scan. gl;hc;

Thread Thread
patarapolw profile image
Pacharapol Withayasakpunt Author

I actually realized that Deno allows not only browser-compatible Javascript, but also Rust plugins.

Though, I don't feel it is production ready yet.

Thread Thread
zoedreams profile image
☮️✝️☪️🕉☸️✡️☯️

hype

don't believe the hype. I personally think deno is a terrible idea and uber insecure. We run remote code locally because fo spoofying. Its an exciting idea on paper, but i would not use it for anything important other than making web sites to catalogue my friends cats or some goof like that

Thread Thread
zoedreams profile image
☮️✝️☪️🕉☸️✡️☯️

honestly if its not a force requirement i would focus on getting verticle slice working for one system that your most comfortable with, get some people to give you money or kickstarter, and port a separate code base. cross platform is a bit overated.. OBEY!

Collapse
zoedreams profile image
Collapse
vonheikemen profile image
Heiker

I feel like lua is good for that kind of thing, and it's seriously lightweight like 1MB light.

Collapse
zoedreams profile image
Collapse
zdev1official profile image