On Wed, Aug 16, 2017 at 11:57:51PM -0700, mrech...@gmail.com wrote:

> I would like to implement a valuation server. For the whole server 
> infrastructure I would like to use Go, because it feels more natural than 
> any other language for it. For the implementation of the valuations I would 
> like to use Julia. Thus, using the aforementioned languages where (IMHO) 
> their strengths are. Googling turned up nothing so far except for an old 
> post on this list suggesting that it is indeed not too easy: 
> https://groups.google.com/d/msg/golang-nuts/Tl7IMu6UnZ4/PBqA_v4rZhEJ
> Is anyone aware of an existing solution for embedding Julia into Go?

I'm not familiar with Julia, but I'd offer two possible points to
consider:

* If Julia code can be compiled to a library exposing C interface
  (as Go makes possible on some platforms with the compiler's option
  -buildmode=c-archive), you can do just that and the call it from Go
  via the standard Go's cgo facility.

* You may consider an often overlooked approach to just not embed
  anything to anything else and instead employ IPC (inter-process
  communication).

  Say, you could possibly compile your Julia program
  so that it reads data in certain agreed-upon format on its stdin
  and writes the results of processing them to its stdout.

  Your Go server then merely starts your Julia program and wires two
  pipes to those standard I/O streams of the process it created.
  Communication then becomes a matter of writing stuff to one of those
  pipes and then reading the result from another one.

  If your Julia server need to be multithreaded, it's possible to
  use "job identifiers" with each task submitted to that Julia process;
  this would allow the latter to perform the jobs in parallel and
  use those job IDs in its answers which then could come out the result
  pipe in any order.

Certainly the latter approach is slower than the first but it's
definitely easier to implement and to reason about, and it fully
decouples both programs.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to