See also my mixed-programming links.
C ↔ Python with SWIG
Files used:
example.c, C sourceexample.h, C headerexample.i, SWIG interfacetest.py, a simple Python testmandel.py, another Mandelbrot generator, using the C implementation
After saving those files, I did this to get everything running:
swig -python example.i gcc -c example.c example_wrap.c -I/usr/include/python2.7 # -fPIC required on some systems ld -shared example.o example_wrap.o -o _example.so python test.py python mandel.py
Java ↔ Ruby with JRuby
Files used:
Mandel.java, Java classjruby.rb, Ruby code that uses it
… and to run this:
javac Mandel.java jruby jruby.rb
.NET library with IronPython
Files used:
net.py, IronPython code
This uses the .NET ArrayList to store and manipulate some data. To run this:
ipy net.py