/ffi

A Foreign Function Call Through the TIOBE Top 20 and some

Primary LanguageC++

A Foreign Call Through the TIOBE Top 20 and some

The "and some" being due to TIOBE Top 20 being a shitty index and lacked some of the most interesting languages.

Console output

The call starts in Java and proceeds through the chain (with highlights such as PL/PGSQL, VisualBasic and bash) and ends up in a kernel module providing the much needed "leftpad" functionality.

This will probably be almost impossible to reproduce as I did some pretty dirty hacks to make this even work, but I warmly invite you to try. I did all of this on a sort-of up-to-date debian stable with mono, jxcore, postgres and go built from source. I can send you a copy of the ~10GB debian VM image I used to develop this, just /query me on freenode.

--jaseg

Complete list of languages involved

  1. Java (JNI out)
  2. C
  3. C++
  4. Java (JNI in, JNA out)
  5. C#
  • Due to two separate segfaulty bugs this needs a very recent version of Mono, and needs to be run with sgen, not boem.
  1. Python
  2. Visual Basic
  • vbnc is kind of unstabley, but generally works fine.
  1. Javascript
  • That think needs to be compiled from source to work
  1. Perl
  2. Ruby
  • Not mruby as I couldn't get mruby to work
  1. Delphi
  • Does something that fucks with the jvm enough to make it crash on exit. Thus, we exit a bit harder than normal and everything works again.
  1. Assembly
  2. Objective C
  3. Objective C++
  • Oh god these toolchains
  1. R
  • Requires ulimiting the maximum stack size to something like 256MB to work
  1. Groovy
  • On first run downloads a bunch of shit from the internet and executes it in the background.
  1. Matlab/Octave
  2. PL/pgSQL
  • Requires that strange borked postgres build done by the Makefile.
  1. Fortran 90
  • Actually quite a neat language!
  1. bash
  • Uses ctypes.sh
  1. TCL
  2. Lua
  3. Rust
  4. Go
  5. Haskell
  • Requires a metric fuckton of libraries spread everywhere, but when invoked with those, works.
  1. Linux kernel module via chardev