GopherCon 2022: Takeshi Yoneda - CGO-less Foreign Function Interface with WebAssembly

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ต.ค. 2024
  • Foreign Function Interface(FFI) is a mechanism to invoke functions written in another language. In Go, there are only a few ways to achieve this, calling C functions via CGO, embedding Lua VM, etc. FFI is especially useful when we want to extend the existing Go projects by leveraging other programming languages’ ecosystems.
    WebAssembly(Wasm) is a relatively-new instruction format for a virtual machine, and numerous programming languages can be compiled down to Wasm binary format. Therefore, if there were a Wasm virtual machine that is embeddable in Go projects, executing Wasm binary in Go could be a way to achieve FFI in a secure and flexible way since Wasm is designed to be secure, and any programming language can have support for it.
    At Tetrate, we have open-sourced a WebAssembly runtime purely in Go called “wazero”. wazero is 100% compliant with the WebAssembly Core Specification 1.0 and 2.0. It has zero dependencies and doesn't rely on CGO. This means you can run applications in other languages and still keep cross-compilation, etc. The prime motivation behind wazero was to write a Wasm runtime purely in Go to avoid CGO usage since there was no pure Go Wasm runtime out there (except a few that are archived), therefore we were not able to achieve FFI via Wasm without CGO.
    This tutorial will cover the basics of WebAssembly, the state of the Go ecosystem around it, how CGO-less FFI with Wasm looks like through a live demo, a deep dive into the wazero’s WebAssembly to machine code compiler and the virtual machine implementation, and how Gophers can start leveraging CGO-less FFI in their project.

ความคิดเห็น • 9

  • @xiongding
    @xiongding 4 หลายเดือนก่อน

    incredible work!

  • @TheArgentan
    @TheArgentan ปีที่แล้ว +2

    Holy cow, this was super neat

  • @JudahCaruso
    @JudahCaruso ปีที่แล้ว +3

    super neat, played with the library during the talk and was able to get Odin code to run using it!

  • @komuwairagu3942
    @komuwairagu3942 ปีที่แล้ว +2

    This is a really good talk. Thanks
    👍

  • @Василь-ю5ш
    @Василь-ю5ш ปีที่แล้ว

    That was so cool! Thank you for the great talk!

  • @mgjulesdev
    @mgjulesdev ปีที่แล้ว

    Really cool 😁

  • @yarbersheer8559
    @yarbersheer8559 ปีที่แล้ว +3

    insane guy ))) cool

  • @alurma
    @alurma ปีที่แล้ว +1

    Great!