Jake quin
Jake quin

Reputation: 742

efficient way of making a library for different languages and platforms

Hello i need to write 4 libraries in 3 different languages for 2 platforms for my PCB module to work on the raspberry pi and arduino. Most of the library just contain functions of bit manipulation which will then be passed to a function that will be unique to each language and platform combination.

So basically the 4 libraries will be 90-95% identical. Now i find it very inefficient that i will have to code for all 4 libraries, where all i do is just adjust the syntaxes. This can also be a pain when there is an update that has to be done on the library because you have to update all 4 of them. There has to be a better way of doing this

enter image description here

My idea is to have a core library where it will be written in one language that can be loaded by a some sort of Hardware Abstraction Layer (HAL) written using the three different languages it is needed python, javascript, and c++. My problem is what will that language be. And what will i use to load it into the other languages. Would C be my best option?

enter image description here

Upvotes: 1

Views: 186

Answers (1)

jvd
jvd

Reputation: 774

Probably the simplest option would be to write your library in C++ and to add bindings for that library. That way you will have your "master" library and also you will be able to use the library in other languages. Proposed diagram would look something like this:

enter image description here

Upvotes: 2

Related Questions