I'm hoping to find some answers to questions around the state of Ruby and Windows as it relates to native extensions.
First, my background is non-Windows, so that is why I'm trying to get an understanding. I've been using Ruby since Rails came out around 2006, but always in a mac or linux environment.
We recently had a situation come up where we have a large amount of internal C++ code we are trying to integrate with our backend server code that is written in node. The integration is not great, as the event-loop to c++ integration makes for an ugly, manual, painful wrapping style. I thought ruby might be a more natural integration, and it was. I was able to essentially wrap a large portion of our c++ codebase in an automated way, with fully generated documentation, and use it from ruby easily, almost magically. I did this all under linux as that is where I'm familiar.
The problems began when trying to get this to work under Windows. Our internal C++ code compiles under gcc and visual studio. For linux/gcc, where I am comfortable, all of the above worked excellent. However for Windows, we hit a major roadblock. Because the dll's from our internal c++ code are built by visual studio, I was unable to link with them when trying to build my native extension. I believe this is due to the name mangling differences between the compilers but this is not my area of expertise - I just know we hit a point where the "fix" would be very difficult.
I believe we had two options, both of which seemed to be too hard to pursue:
1.) Get our internal c++ code to compile with mingw. This would require a significant effort due to 3rd party dependencies. We went through this effort to get it to compile with gcc about a year ago, and my understanding was this took months of work. But if we did this, then the output .lib/.so/.dll files would be compatible with ruby on windows which is built with mingw, and everything would "just work" - plus we could cross-compile for both platforms from linux.
2.) Build ruby itself with visual studio. This seemed very difficult and as we have very limited ruby talent outside of myself (who has no Windows experience), it would basically be non-ruby ops people with Windows experience trying to understand how to build Ruby - not ideal in either direction! And, even if we achieved this, my understanding is we would probably run into tons of problems with other 3rd part rubygems that probably don't support mswin ruby. So in short this would be a constant pain point if we went off the "easy path".
Maybe there is a 3rd option I didn't consider, or options 1 or 2 aren't as bad as we think. Ideally what we are building would be containerized, so this wouldn't matter - we would just package this up into linux docker containers and it would work everywhere. However our largest customer base are primarily Windows users who probably don't even know what docker is, and so a big consideration is making it easy for them to "install" our product. I think there is work happening now in this space with CNAB and duffle.sh, but it is still early. Maybe some day this will be a reality. For now, we probably need to stick with the lowest common denominator and make sure what we build works natively on both Windows and Linux.
If we could find a way to use Ruby for this, the solution is so beautiful compared to the way we have to integrate on the nodejs side. Any feedback or suggestions anyone might have would be very much appreciated!