title: Bridging between different programming languages
body: <p>This is more of a design question.</p>
  
  <p>I was planning on writing some web-services which implement CPU intensive algorithms. The problem that I am trying to solve is - higher level languages such as python, perl or java make it easy to write web services. While lower level languages such as C, C++ make it possible to fine tune the performance of your code.</p>
  
  <p>So I was looking at what I could do bridge two languages. Here's the options I came up with:</p>
  
  <h2>Language specific bindings</h2>
  
  <p>Use something like perl-xs or python's ctypes/loadlibrary or java's JNI. The up-side is that I can write extensions which can execute in the same process. There is small overhead of converting between the native language types to C and back.</p>
  
  <h2>Implement a separate daemon</h2>
  
  <p>Use something like thrift / avro and have a separate daemon that runs the C/C++ code. The upside is, it's loosely coupled from the higher level language. I can quickly replace the high level language. The downside being that the overhead of serializing and local unix domain sockets might be higher than executing the code in the same address space (offered by the previous option.)</p>
  
  <p>What do you guys think?</p>