3 ms·
It might make sense to put some compute intensive tasks in Go, or any other compiled language thats more efficient, but exec'ing and returning JSON isnt really
by thinkingkong 12y ago
It might make sense to put some compute intensive tasks in Go, or any other compiled language thats more efficient, but exec'ing and returning JSON isnt really a great idea.
If you were going to consider this seriously, then you should have the target app start once, listen for comands on some channel like a socket, and have it return information. JSON is probably a little too verbose for this kind of use-case as well, but it depends how efficient Ruby would be at unpacking alternative serialization formats.
- 3pt14159 12y agoWhy couldn't the coder use Extconf and just include the Go program into its scope like C?
- jamescun 12y agoWith regards to Go, it is currently not possible as the Go compiler only supports building static binary executables. For it to work with extconf, Go would need the ability to build dynamic libraries. There has been talk of incorporating this ability and slim executables go (I think it might even be in the roadmap now).
- vinceguidry 12y ago> It might make sense to put some compute intensive tasks in Go, or any other compiled language thats more efficient, but exec'ing and returning JSON isnt really a great idea. It's not a terrible one, though. You don't choose Ruby for its performance. If you find yourself creating and returning lots of JSON with this, that should be a clue that you should be pushing more functionality down to that lower level, and just returning the bulk results back up.
- pselbert 12y agoUsing a library like Oj[1] it is vastly faster to unpack JSON in Ruby than it is even to use the built in marshaling. It's extremely portable, performs well and is easy to debug. There really aren't many practical drawbacks to using it for transport on the same system. [1]: https://github.com/ohler55/oj https://github.com/ohler55/oj