Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Golang interface with CppMicroservices #395

Open
al-sabr opened this issue Oct 11, 2019 · 6 comments
Open

Golang interface with CppMicroservices #395

al-sabr opened this issue Oct 11, 2019 · 6 comments

Comments

@al-sabr
Copy link

al-sabr commented Oct 11, 2019

I've come across recently to the knowledge about being able to write Windows/Linux/MacOs dlls/so libraries with golang. I was wondering if it would be possible to write Bundles with golang targeting CppMicroservices.

@jeffdiclemente
Copy link
Member

CppMicroServices only supports C++. There is no cross language support between C++ and any other language.

@al-sabr
Copy link
Author

al-sabr commented Oct 28, 2019

I meant that with golang it is possible to compile dlls/so library. Why shouldn't it be possible to write bundles in go and compile them to native dlls?

@jeffdiclemente
Copy link
Member

I don't know enough about golang to answer definitively. What I do know is that CppMicroServices requires extern C functions to exist within the dll/so so that it can create C++ objects and call the bundle's activator contained within the dll/so, which is required to be a c++ object. Any services which the bundle wants to provide must also be C++ objects.

CppMicroServices requires C++ code in the dll/so to be able to work. If golang can call into C++ code within the same dll/so, then I suppose its possible.

@al-sabr
Copy link
Author

al-sabr commented Oct 28, 2019

Yes based on this it is possible to produce extern C from golang.

What should be done to be able to directly from go compile dlls and just use them plainly within CppMicroservices?

Do we need to create the includes in Golang?

https://github.com/z505/goDLL

@jeffdiclemente
Copy link
Member

CppMicroServices services are based on C++ abstract base classes (service interfaces). Clients access services by including the header file declaring the service interface and using CppMicroServices C++ APIs to get the c++ service object. CppMicroServices only knows how to create C++ objects. I suppose its possible to create a C++ service object which simply delegated calls to golang.

I think a more fundamental question is, what problem does golang solve than can't be solved using C++?

@al-sabr
Copy link
Author

al-sabr commented Oct 28, 2019

The main problem solved by golang is the fact that as a language it is easier to learn and code with and as powerful as C++ because it has the same concept such as pointers, interface, etc... There is also the fact that concurrency is part of the language and pretty easy to use right away with go routines, channels., etc...

Also any code can be compiled towards any platform and architecture with a one liner compile command. In C++ cross-platform compilation is so complicated that one needs to know so many small details.

It is just easier to use than anything I've seen up until this day. That simplicity is why C++ developers have a blast with golang.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants