Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Let's Go With Ruby

Let's Go With Ruby

Slides for the talk about Ruby & Golang language interop presented at RubyConf India 2016.

Shishir Joshi

March 22, 2016
Tweet

Other Decks in Programming

Transcript

  1. Golang • C family • Statically typed • Type inference

    • Explicit type conversion • Automatic memory management, garbage collected • Compiled
  2. CGo

  3. CGo Provides utility functions to convert between Golang and C

    types. E.g. • Go string to C string func C.CString(goString string) *C.char • C string to Go string func C.GoString(cString *C.char) string • C Arrays to Go slices import "C" import "unsafe" var theCArray *C.YourType = C.getTheArray() length := C.getTheArrayLength() slice := (*[1 << 30]C.YourType)(unsafe.Pointer(theCArray))[:length:length]
  4. FFI

  5. FFI “Ruby-FFI is a ruby extension for programmatically loading dynamic

    libraries, binding functions within them, and calling those functions from Ruby code. Moreover, a Ruby-FFI extension works without changes on Ruby and JRuby”.
  6. Ruby callbacks • Not possible to pass Ruby callbacks to

    Golang code • Will have use an adapter written in C to use Ruby callbacks