SlideShare a Scribd company logo
1's and 0's:
Go and WebAssembly
GoDays Berlin, 30th January ‘19
Guus van Weelden
Loodse GmbH
@guusvw91
Guus van Weelden
00. Guus van Weelden
guus := Speaker{
Name: "Guus van Weelden",
Positions: {"Developer", "Consultant"},
Employer: "Loodse GmbH",
Age: 27,
Likes: {"Go", "K8s", "American Football"},
Origin: "Hamburg, Germany",
Twitter: "@guusvw91",
}
guus.Talk(“1's and 0's: Go and WebAssembly”)
$ go run guus.go
Today’s (glorious) agenda.
WebAssembly?
Go 1.11
Go & WASM - Past, Present & Future
Demo Time
Metas
Questions?
02
Much slides,
Some live coding,
Cool Memes,
Let’s Go!
WebAssembly?
Why should I care, I’m a
damn backend/ops guy!
WebAssembly?
01
WebAssembly is a binary instruction
format for a stack-based virtual
machine. WASM is designed as a
portable target for compilation of
high-level languages like C/C++/Rust/Go,
enabling deployment on the web for
client and server applications.
WebAssembly
WebAssembly?
WebAssembly?
WebAssembly is a binary
instruction format...
WebAssembly?
{binary
instruction
format
➔ Less file size
➔ Faster
execution
WebAssembly?
… WASM is designed as a
portable target for
compilation of high-level
languages like Go ...
WebAssembly?
{portable
target
of high-level
languages
➔ Use languages
you already
know
➔ Stuff like
type-safety
WebAssembly?
… enabling deployment on
the web for client and server
applications.
WebAssembly?
{enabling
deployment
on client
and server
apps
➔ Enables for a
shared code
base, so less
deployment
WebAssembly?
WebAssembly’s Values
WebAssembly?
● Efficiency
● Standardization
● Security/Sandboxed
● More Languages
Need more motivation?
WebAssembly?
WebAssembly?
Go code
Go
24th of August ‘18
The release of Go1.11
{Go 1.11
● Getting rid of GOPATH
● Getting Modules support
● many changes &
improvements to the
toolchain, runtime, and
libraries
● WebAssembly support
● ...
Go 1.11
{Go 1.11
● Getting rid of GOPATH
● Getting Modules support
● many changes &
improvements to the
toolchain, runtime, and
libraries
● WebAssembly support
● ...
Go 1.11
We’re getting
native WASM
support! Yeah!
Go 1.11
Go 1.11
Go 1.11
Go 1.11
● compile to one WebAssembly module
● resulting size is at minimum around 2 MB
● Go programs can call into JavaScript
● new experimental syscall/js package
● new GOOS value "js" and GOARCH value
"wasm"
Go & WASM - Past, Present & Future
But wasn’t there
something called
GopherJS?!
Go & WASM - Past, Present & Future
Yes.
But it compiles Go
ONLY(!) to JS.
Go & WASM - Past, Present & Future
Current Limitations
Go & WASM - Past, Present & Future
● No native DOM APIs (yet - OS lib is out there)
● No multithreading (yet)
● Large binary file sizes
● Performance not yet where it should be
● Some core libraries are not supported
○ Parts of the net-package =(
○ ...
import "syscall/js"
Go & WASM - Past, Present & Future
package js
Package js gives access to the WebAssembly host
environment when using the js/wasm architecture. Its API
is based on JavaScript semantics.
This package is EXPERIMENTAL. Its current scope is only to
allow tests to run, but not yet to provide a comprehensive
API for users. It is exempt from the Go compatibility
promise.
$ godoc syscall/js | head -n 12
Its API is based on JavaScript semantics.
import "syscall/js"
Go & WASM - Past, Present & Future
js.Global(), js.Null(),
js.Undefined(),
js.ValueOf()
Values
Value.Get(), Value.Set(),
Value.Call(), Value.New()
Objects
import "syscall/js"
Go & WASM - Past, Present & Future
Value.Invoke()Functions
Value.Bool(), Value.Float(),
Value.Int(), Value.String()
Transformations from JS
Value to Go type
import "syscall/js"
Go & WASM - Past, Present & Future
TypedArray, Index(),
SetIndex()
Arrays
NewEventCallback(flags
EventCallbackFlag,
fn func(event Value)) Callback
Callbacks
import "syscall/js"
Go & WASM - Past, Present & Future
| Go | JavaScript |
| ---------------------- | ---------------------- |
| js.Value | [its value] |
| js.TypedArray | typed array |
| js.Callback | function |
| nil | null |
| bool | boolean |
| integers and floats | number |
| string | string |
| []interface{} | new array |
| map[string]interface{} | new object |
js.ValueOf()
Sample Code
Go & WASM - Past, Present & Future
import (
"log"
"syscall/js"
)
func main() {
var cb js.Callback
cb = js.NewCallback(func(args []js.Value) {
log.Println("button clicked")
})
js.Global().Get("document").Call("getElementById",
"myButton").Call("addEventListener", "click", cb)
}
$ GOARCH=wasm GOOS=js go build ./cmd/wasm
Go & WASM - Past, Present & Future
{How to start?
● Writing some Go code
● Writing some HTML code
● Copying js-glue files
● Compile to wasm
● Serve the files
Writing some Go code
package main
import "fmt"
func main() {
fmt.Println("Hello, WebAssembly!")
}
Writing some HTML code
<html>
<head>
<meta charset="utf-8">
<script src="wasm_exec.js"></script>
<script>
const go = new Go();
WebAssembly.instantiateStreaming(fetch("main.wasm"), go.importObject).then((result) =>
{
go.run(result.instance);
});
</script>
</head>
<body></body>
</html>
$ GOOS=js GOARCH=wasm go build -o
main.wasm
$ cp "$(go env
GOROOT)/misc/wasm/wasm_exec.js" .
$ goexec
'http.ListenAndServe(":8081",
http.FileServer(http.Dir(".")))'
● Copying js-glue
files
● Compile to wasm
● Serve the files
Kelsey Hightower
Praise the demo gods!
Upcoming - Past, Present & Future
● Go WASM frameworks
● Package-level caching
● Native Browser APIs
● Threading, Garbage Collection (?)
● Continual improvements
● github.com/dave/wasmgo
○ CLI to compile Go to WASM & serve it locally or
upload it
● github.com/gopherjs/vecty
○ Vecty is a React-like library for GopherJS ->
currently working on WASM support
● Grpcweb.jbrandhorst.com
○ GopherJS gRPC-Web Client ->
currently working on WASM support
Go & WASM - Past, Present & Future
One last
thing!
Any Questions?
Didn’t you missed
anything?
Yeah, a cute cat gif!
Recommendations
Metas
● Today - joining the PARTY!
● Container Days ‘19
● Support your local Go community
Container Days
Metas
Thanks to...
Metas
● Matthias Loibl (@MetalMatze) - First Go & WASM
hacking
● Jason Murray (@chaosaffe) - Title of the talk
● Markus Zimmermann (@markus_zm) - stole some ideas
& slides from him
● The great team of the GoDays(@godaysio) for organizing
this event
03
Thanks for listening &
attending
enjoy the rest of the
conference.
The end
Ad

More Related Content

What's hot (17)

Bundling your front-end with Webpack
Bundling your front-end with WebpackBundling your front-end with Webpack
Bundling your front-end with Webpack
Danillo Corvalan
 
Web Optimisation
Web OptimisationWeb Optimisation
Web Optimisation
Gregory Benner
 
Preprocessor Workflow with Grunt
Preprocessor Workflow with GruntPreprocessor Workflow with Grunt
Preprocessor Workflow with Grunt
Vlad Filippov
 
MOConf'13: WebNotBombs: Optimize this
MOConf'13: WebNotBombs: Optimize thisMOConf'13: WebNotBombs: Optimize this
MOConf'13: WebNotBombs: Optimize this
Boris Zapolsky
 
Velocity dust
Velocity dustVelocity dust
Velocity dust
Veena Basavaraj
 
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.jsThe MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
MongoDB
 
Advanced front-end automation with npm scripts
Advanced front-end automation with npm scriptsAdvanced front-end automation with npm scripts
Advanced front-end automation with npm scripts
k88hudson
 
Petar Nikolow - OA Conf 2021
Petar Nikolow - OA Conf 2021Petar Nikolow - OA Conf 2021
Petar Nikolow - OA Conf 2021
Internet marketing agency Netpeak
 
Dirty - How simple is your database?
Dirty - How simple is your database?Dirty - How simple is your database?
Dirty - How simple is your database?
Felix Geisendörfer
 
브라우저에 날개를 달자
브라우저에 날개를 달자브라우저에 날개를 달자
브라우저에 날개를 달자
NAVER SHOPPING
 
When Will Drupal Die? (Keynote talk)
When Will Drupal Die? (Keynote talk)When Will Drupal Die? (Keynote talk)
When Will Drupal Die? (Keynote talk)
chrisshattuck
 
NodeJS Concurrency
NodeJS ConcurrencyNodeJS Concurrency
NodeJS Concurrency
pgriess
 
Php johannesburg meetup - talk 2014 - scaling php in the enterprise
Php johannesburg   meetup - talk 2014 - scaling php in the enterprisePhp johannesburg   meetup - talk 2014 - scaling php in the enterprise
Php johannesburg meetup - talk 2014 - scaling php in the enterprise
Sarel van der Walt
 
Couchdb Nosql
Couchdb NosqlCouchdb Nosql
Couchdb Nosql
elliando dias
 
Advanced jQuery (Ajax Exp 2007)
Advanced jQuery (Ajax Exp 2007)Advanced jQuery (Ajax Exp 2007)
Advanced jQuery (Ajax Exp 2007)
jeresig
 
Node.js concurrency
Node.js concurrencyNode.js concurrency
Node.js concurrency
Giacomo Fornari
 
Bundling your front-end with Webpack
Bundling your front-end with WebpackBundling your front-end with Webpack
Bundling your front-end with Webpack
Danillo Corvalan
 
Preprocessor Workflow with Grunt
Preprocessor Workflow with GruntPreprocessor Workflow with Grunt
Preprocessor Workflow with Grunt
Vlad Filippov
 
MOConf'13: WebNotBombs: Optimize this
MOConf'13: WebNotBombs: Optimize thisMOConf'13: WebNotBombs: Optimize this
MOConf'13: WebNotBombs: Optimize this
Boris Zapolsky
 
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.jsThe MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
MongoDB
 
Advanced front-end automation with npm scripts
Advanced front-end automation with npm scriptsAdvanced front-end automation with npm scripts
Advanced front-end automation with npm scripts
k88hudson
 
Dirty - How simple is your database?
Dirty - How simple is your database?Dirty - How simple is your database?
Dirty - How simple is your database?
Felix Geisendörfer
 
브라우저에 날개를 달자
브라우저에 날개를 달자브라우저에 날개를 달자
브라우저에 날개를 달자
NAVER SHOPPING
 
When Will Drupal Die? (Keynote talk)
When Will Drupal Die? (Keynote talk)When Will Drupal Die? (Keynote talk)
When Will Drupal Die? (Keynote talk)
chrisshattuck
 
NodeJS Concurrency
NodeJS ConcurrencyNodeJS Concurrency
NodeJS Concurrency
pgriess
 
Php johannesburg meetup - talk 2014 - scaling php in the enterprise
Php johannesburg   meetup - talk 2014 - scaling php in the enterprisePhp johannesburg   meetup - talk 2014 - scaling php in the enterprise
Php johannesburg meetup - talk 2014 - scaling php in the enterprise
Sarel van der Walt
 
Advanced jQuery (Ajax Exp 2007)
Advanced jQuery (Ajax Exp 2007)Advanced jQuery (Ajax Exp 2007)
Advanced jQuery (Ajax Exp 2007)
jeresig
 

Similar to Go & WebAssembly (20)

Everything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the WebEverything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the Web
James Rakich
 
Intro to go web assembly
Intro to go web assemblyIntro to go web assembly
Intro to go web assembly
Che-Chia Chang
 
Spicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QASpicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QA
Alban Gérôme
 
Html5 Overview
Html5 OverviewHtml5 Overview
Html5 Overview
Abdel Moneim Emad
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
toddbr
 
Webpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of usWebpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of us
Stefan Adolf
 
Philip Stehlik at TechTalks.ph - Intro to Groovy and Grails
Philip Stehlik at TechTalks.ph - Intro to Groovy and GrailsPhilip Stehlik at TechTalks.ph - Intro to Groovy and Grails
Philip Stehlik at TechTalks.ph - Intro to Groovy and Grails
Philip Stehlik
 
JS & NodeJS - An Introduction
JS & NodeJS - An IntroductionJS & NodeJS - An Introduction
JS & NodeJS - An Introduction
Nirvanic Labs
 
KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天
tblanlan
 
kissy-past-now-future
kissy-past-now-futurekissy-past-now-future
kissy-past-now-future
yiming he
 
Compact Web - Remind "web compression" -
Compact Web - Remind "web compression" -Compact Web - Remind "web compression" -
Compact Web - Remind "web compression" -
Tomokazu Kiyohara
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
David Padbury
 
Modern Static Site with GatsbyJS
Modern Static Site with GatsbyJSModern Static Site with GatsbyJS
Modern Static Site with GatsbyJS
Riza Fahmi
 
Web Performance Workshop - Velocity London 2013
Web Performance Workshop - Velocity London 2013Web Performance Workshop - Velocity London 2013
Web Performance Workshop - Velocity London 2013
Andy Davies
 
JavaOne TS-5098 Groovy SwingBuilder
JavaOne TS-5098 Groovy SwingBuilderJavaOne TS-5098 Groovy SwingBuilder
JavaOne TS-5098 Groovy SwingBuilder
Andres Almiray
 
New Features Coming in Browsers (RIT '09)
New Features Coming in Browsers (RIT '09)New Features Coming in Browsers (RIT '09)
New Features Coming in Browsers (RIT '09)
jeresig
 
Get Grulping with JavaScript Task Runners (Matt Gifford)
Get Grulping with JavaScript Task Runners (Matt Gifford)Get Grulping with JavaScript Task Runners (Matt Gifford)
Get Grulping with JavaScript Task Runners (Matt Gifford)
Future Insights
 
Алексей Швайка "Bundling: you are doing it wrong"
Алексей Швайка "Bundling: you are doing it wrong"Алексей Швайка "Bundling: you are doing it wrong"
Алексей Швайка "Bundling: you are doing it wrong"
Fwdays
 
About Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSAbout Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JS
Naga Harish M
 
Front End Development Automation with Grunt
Front End Development Automation with GruntFront End Development Automation with Grunt
Front End Development Automation with Grunt
Ladies Who Code
 
Everything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the WebEverything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the Web
James Rakich
 
Intro to go web assembly
Intro to go web assemblyIntro to go web assembly
Intro to go web assembly
Che-Chia Chang
 
Spicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QASpicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QA
Alban Gérôme
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
toddbr
 
Webpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of usWebpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of us
Stefan Adolf
 
Philip Stehlik at TechTalks.ph - Intro to Groovy and Grails
Philip Stehlik at TechTalks.ph - Intro to Groovy and GrailsPhilip Stehlik at TechTalks.ph - Intro to Groovy and Grails
Philip Stehlik at TechTalks.ph - Intro to Groovy and Grails
Philip Stehlik
 
JS & NodeJS - An Introduction
JS & NodeJS - An IntroductionJS & NodeJS - An Introduction
JS & NodeJS - An Introduction
Nirvanic Labs
 
KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天
tblanlan
 
kissy-past-now-future
kissy-past-now-futurekissy-past-now-future
kissy-past-now-future
yiming he
 
Compact Web - Remind "web compression" -
Compact Web - Remind "web compression" -Compact Web - Remind "web compression" -
Compact Web - Remind "web compression" -
Tomokazu Kiyohara
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
David Padbury
 
Modern Static Site with GatsbyJS
Modern Static Site with GatsbyJSModern Static Site with GatsbyJS
Modern Static Site with GatsbyJS
Riza Fahmi
 
Web Performance Workshop - Velocity London 2013
Web Performance Workshop - Velocity London 2013Web Performance Workshop - Velocity London 2013
Web Performance Workshop - Velocity London 2013
Andy Davies
 
JavaOne TS-5098 Groovy SwingBuilder
JavaOne TS-5098 Groovy SwingBuilderJavaOne TS-5098 Groovy SwingBuilder
JavaOne TS-5098 Groovy SwingBuilder
Andres Almiray
 
New Features Coming in Browsers (RIT '09)
New Features Coming in Browsers (RIT '09)New Features Coming in Browsers (RIT '09)
New Features Coming in Browsers (RIT '09)
jeresig
 
Get Grulping with JavaScript Task Runners (Matt Gifford)
Get Grulping with JavaScript Task Runners (Matt Gifford)Get Grulping with JavaScript Task Runners (Matt Gifford)
Get Grulping with JavaScript Task Runners (Matt Gifford)
Future Insights
 
Алексей Швайка "Bundling: you are doing it wrong"
Алексей Швайка "Bundling: you are doing it wrong"Алексей Швайка "Bundling: you are doing it wrong"
Алексей Швайка "Bundling: you are doing it wrong"
Fwdays
 
About Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSAbout Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JS
Naga Harish M
 
Front End Development Automation with Grunt
Front End Development Automation with GruntFront End Development Automation with Grunt
Front End Development Automation with Grunt
Ladies Who Code
 
Ad

Recently uploaded (20)

WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Lionel Briand
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
Egor Kaleynik
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Lionel Briand
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
Egor Kaleynik
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
Ad

Go & WebAssembly

  • 1. 1's and 0's: Go and WebAssembly GoDays Berlin, 30th January ‘19 Guus van Weelden Loodse GmbH @guusvw91
  • 2. Guus van Weelden 00. Guus van Weelden guus := Speaker{ Name: "Guus van Weelden", Positions: {"Developer", "Consultant"}, Employer: "Loodse GmbH", Age: 27, Likes: {"Go", "K8s", "American Football"}, Origin: "Hamburg, Germany", Twitter: "@guusvw91", } guus.Talk(“1's and 0's: Go and WebAssembly”) $ go run guus.go
  • 3. Today’s (glorious) agenda. WebAssembly? Go 1.11 Go & WASM - Past, Present & Future Demo Time Metas Questions?
  • 4. 02 Much slides, Some live coding, Cool Memes, Let’s Go!
  • 5. WebAssembly? Why should I care, I’m a damn backend/ops guy! WebAssembly?
  • 6. 01 WebAssembly is a binary instruction format for a stack-based virtual machine. WASM is designed as a portable target for compilation of high-level languages like C/C++/Rust/Go, enabling deployment on the web for client and server applications. WebAssembly WebAssembly?
  • 8. WebAssembly is a binary instruction format... WebAssembly?
  • 9. {binary instruction format ➔ Less file size ➔ Faster execution WebAssembly?
  • 10. … WASM is designed as a portable target for compilation of high-level languages like Go ... WebAssembly?
  • 11. {portable target of high-level languages ➔ Use languages you already know ➔ Stuff like type-safety WebAssembly?
  • 12. … enabling deployment on the web for client and server applications. WebAssembly?
  • 13. {enabling deployment on client and server apps ➔ Enables for a shared code base, so less deployment WebAssembly?
  • 14. WebAssembly’s Values WebAssembly? ● Efficiency ● Standardization ● Security/Sandboxed ● More Languages
  • 18. 24th of August ‘18 The release of Go1.11
  • 19. {Go 1.11 ● Getting rid of GOPATH ● Getting Modules support ● many changes & improvements to the toolchain, runtime, and libraries ● WebAssembly support ● ... Go 1.11
  • 20. {Go 1.11 ● Getting rid of GOPATH ● Getting Modules support ● many changes & improvements to the toolchain, runtime, and libraries ● WebAssembly support ● ... Go 1.11
  • 24. Go 1.11 ● compile to one WebAssembly module ● resulting size is at minimum around 2 MB ● Go programs can call into JavaScript ● new experimental syscall/js package ● new GOOS value "js" and GOARCH value "wasm"
  • 25. Go & WASM - Past, Present & Future
  • 26. But wasn’t there something called GopherJS?! Go & WASM - Past, Present & Future
  • 27. Yes. But it compiles Go ONLY(!) to JS. Go & WASM - Past, Present & Future
  • 28. Current Limitations Go & WASM - Past, Present & Future ● No native DOM APIs (yet - OS lib is out there) ● No multithreading (yet) ● Large binary file sizes ● Performance not yet where it should be ● Some core libraries are not supported ○ Parts of the net-package =( ○ ...
  • 29. import "syscall/js" Go & WASM - Past, Present & Future package js Package js gives access to the WebAssembly host environment when using the js/wasm architecture. Its API is based on JavaScript semantics. This package is EXPERIMENTAL. Its current scope is only to allow tests to run, but not yet to provide a comprehensive API for users. It is exempt from the Go compatibility promise. $ godoc syscall/js | head -n 12
  • 30. Its API is based on JavaScript semantics.
  • 31. import "syscall/js" Go & WASM - Past, Present & Future js.Global(), js.Null(), js.Undefined(), js.ValueOf() Values Value.Get(), Value.Set(), Value.Call(), Value.New() Objects
  • 32. import "syscall/js" Go & WASM - Past, Present & Future Value.Invoke()Functions Value.Bool(), Value.Float(), Value.Int(), Value.String() Transformations from JS Value to Go type
  • 33. import "syscall/js" Go & WASM - Past, Present & Future TypedArray, Index(), SetIndex() Arrays NewEventCallback(flags EventCallbackFlag, fn func(event Value)) Callback Callbacks
  • 34. import "syscall/js" Go & WASM - Past, Present & Future | Go | JavaScript | | ---------------------- | ---------------------- | | js.Value | [its value] | | js.TypedArray | typed array | | js.Callback | function | | nil | null | | bool | boolean | | integers and floats | number | | string | string | | []interface{} | new array | | map[string]interface{} | new object | js.ValueOf()
  • 35. Sample Code Go & WASM - Past, Present & Future import ( "log" "syscall/js" ) func main() { var cb js.Callback cb = js.NewCallback(func(args []js.Value) { log.Println("button clicked") }) js.Global().Get("document").Call("getElementById", "myButton").Call("addEventListener", "click", cb) } $ GOARCH=wasm GOOS=js go build ./cmd/wasm
  • 36. Go & WASM - Past, Present & Future
  • 37. {How to start? ● Writing some Go code ● Writing some HTML code ● Copying js-glue files ● Compile to wasm ● Serve the files
  • 38. Writing some Go code package main import "fmt" func main() { fmt.Println("Hello, WebAssembly!") }
  • 39. Writing some HTML code <html> <head> <meta charset="utf-8"> <script src="wasm_exec.js"></script> <script> const go = new Go(); WebAssembly.instantiateStreaming(fetch("main.wasm"), go.importObject).then((result) => { go.run(result.instance); }); </script> </head> <body></body> </html>
  • 40. $ GOOS=js GOARCH=wasm go build -o main.wasm $ cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" . $ goexec 'http.ListenAndServe(":8081", http.FileServer(http.Dir(".")))' ● Copying js-glue files ● Compile to wasm ● Serve the files
  • 42. Upcoming - Past, Present & Future ● Go WASM frameworks ● Package-level caching ● Native Browser APIs ● Threading, Garbage Collection (?) ● Continual improvements
  • 43. ● github.com/dave/wasmgo ○ CLI to compile Go to WASM & serve it locally or upload it ● github.com/gopherjs/vecty ○ Vecty is a React-like library for GopherJS -> currently working on WASM support ● Grpcweb.jbrandhorst.com ○ GopherJS gRPC-Web Client -> currently working on WASM support Go & WASM - Past, Present & Future
  • 47. Yeah, a cute cat gif!
  • 48. Recommendations Metas ● Today - joining the PARTY! ● Container Days ‘19 ● Support your local Go community
  • 50. Thanks to... Metas ● Matthias Loibl (@MetalMatze) - First Go & WASM hacking ● Jason Murray (@chaosaffe) - Title of the talk ● Markus Zimmermann (@markus_zm) - stole some ideas & slides from him ● The great team of the GoDays(@godaysio) for organizing this event
  • 51. 03 Thanks for listening & attending enjoy the rest of the conference. The end