0

I want to create an app that will be extensible via plugins.

I know that I have 2 options.

  1. I can create my own interpreted language and app with a built-in interpreter for this language.
  2. I can use one of the existing languages such as Python, Lua or another scripting language.

I want to use option 2. And I know that I must create a layer for external language to enable communication between this language and my app. But I don't know how to do it. Maybe I must use interprocess communication or something like that.

Let's assume that I have an application written in C++. In the beginning, it may be even a simple console app that displays a few options. And I want to write a plugin in Python like this:

option = "additional option"
myApp.addOption(option)

And then:

  1. I launch my app

  2. My app loads the plugin

  3. I see my app with this additional option displayed

I want to do this simple thing to understand how it works and then I will be able to do something more complicated.

8
  • On which operating system? That matters a lot! Commented Feb 13, 2020 at 9:33
  • I use the Windows 10 operating system. Commented Feb 21, 2020 at 21:54
  • Please accept my deepest condolences for that fact. In my biased opinion, Linux is much more developer friendly than Windows 10 is Commented Feb 22, 2020 at 8:04
  • I have Virtual Box and Linux Machine installed on it. But I can't get used to it. I know that GUI is not the most important think on Linux. The most important thing is the power of the console, safety, and a few other things. But I think that Linux is firstly for administrators and secondly for developers. I am not an administrator, I am a developer and just user. So I want to have both a reliable, safe, developer-friendly environment and intuitive, comfortable interface. I think MacOS have both. But I am just a poor student and I have not money for apple xD Commented Feb 22, 2020 at 9:59
  • My opinion is that Linux is or was for developers. The first users of Linux (in the previous century) have been developers. I used GNU/Linux in 1993 and at that time could not have been able to use it without developer skills. At that time, you had to recompile the kernel for your graphics card. Read about unix philosophy and about free software Commented Feb 22, 2020 at 15:05

2 Answers 2

1

You could start by looking at the languages' documentation(if you're new):

Python -->https://docs.python.org/3/ Lua --> https://www.lua.org/docs.html

C++ libraries can also be called in C(If you're careful enough),you could look at this too https://www.teddy.ch/c++_library_in_c/

Sign up to request clarification or add additional context in comments.

Comments

0

You should be aware that, with care, a C++ library can be called from a C program, mostly by appropriately using extern "C" to disable name mangling. On Linux, read also the C++ dlopen mini Howto.

Then you need to read the chapter Extending and embedding the Python interpreter

At last, Python is open source, so please study its source code.

I can use one of the existing languages such as Python, Lua or another scripting language.

I strongly recommend considering using GNU Guile or extending Ocaml.

And both TensorFlow or NumPy could inspire you, since they are open source libraries (coded in C and/or C++) usable from Python.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.