SlideShare a Scribd company logo
David Chang
DevOps@mithril
初探 Go-WebAssembly
What is WebAssembly
WebAssembly
● A new language for web
● Compiled from other
languages
● Offers maximized, reliable
performance
● Not replacing JS
A new language for web
● A low level language
● standard
● a binary instruction and a
assembly-like format
● Supported by Mozilla, Google,
Microsoft, Apple
WebAssembly Now
● Release 1.0
(Draft, last updated Dec 13,
2018)
● Experimental
Why WebAssembly
What’s wrong with JS?
Web Javascript
● Slow
● Insecure
● Dynamic type vs static type
● Avoid heavy computing in
Front-End
● Easy-writing
● Huge eco-system
Historical Javascript
● ECMAScript
-> by Brendan Eich in late 1995
● Internet Explorer 3
● NodeJS -> 2009
● npm -> 2010
JS is getting faster
● Just In Time compiler of JS
engine
● trace and re-optimize (loop)
● GC
● Built-in functions / Stadard
Library / APIs
But wasm is faster
https://hacks.mozilla.org/2017/02/w
hat-makes-webassembly-fast/
● Wasm is compiled
● No type assertion
● No need to re-optimize
● Much less GC
.go
.wasm
(IR)
Firefox x86
Assembly
spider
monkey
Chart Data Source Info
From WebAssembly to JS engine
https://mbebenita.github.io/WasmExplorer/
Some Examples
“Unleash the power of your web devices”
Wasm vs JS
github.com/shamadee/web-dsp
https://d2jta7o2zej4pf.cloudfront.net/
Epic Epic Zen Garden
Unreal Engine in WebAssembly and WebGL 2.0
https://s3.amazonaws.com/mozilla-games/ZenGarden/EpicZenGarden.html
Go WebAssembly
From Go to web
Go-WebAssembly
● go 1.11 (Aug. 2018)
● Experimental feature
https://github.com/golang/go/wiki/W
ebAssembly
1.11 Release Note
Go 1.11 adds an experimental port to WebAssembly (js/wasm).
Go programs compile to one WebAssembly module
Go runtime for goroutine scheduling, garbage collection,
maps, etc.
Go programs can call into JavaScript using the new
experimental syscall/js package.
new GOOS "js" and GOARCH "wasm"
Why Go-WebAssembly
Again, why?
Go-WebAssembly
● Runs existing program / library
in Front-End
● Make golang protable
● Thread Safe
● Back-End to Full-Stack?
Let’s Go-WebAssembly
<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>
run-%:
GOOS=js GOARCH=wasm
go run -exec="$(shell go env
GOROOT)/misc/wasm/go_js_wasm_exec" ./src/$*
test:
GOOS=js GOARCH=wasm
go test -exec="$(shell go env GOROOT)/misc/wasm/go_js_wasm_exec" ./...
build-%:
GOOS=js GOARCH=wasm
go build -o public/lib.wasm ./src/$*
server:
go run ./src/server -listen :8080 -dir public
.go .wasm JS API
Engine
Chart Data Source Info
From Golang to Web
Compile golang functions to wasm, and runs in JS
package main
import (
"strconv"
"syscall/js"
)
func add(i []js.Value) {
doc := js.Global().Get("document")
value1 := doc.Call("getElementById", "input1").Get("value").String()
value2 := doc.Call("getElementById", "input2").Get("value").String()
int1, _ := strconv.Atoi(value1)
int2, _ := strconv.Atoi(value2)
doc.Call("getElementById", "sum").Set("value", int1+int2)
}
// JS
func add() {
var value1 = document.getElementById("input1").value;
vat value2 = document.getElementById("input2").value;
document.getElementById("sum").value = Number(value1) + Number(value2);
}
// Go
func add(i []js.Value) {
doc := js.Global().Get("document")
value1 := doc.Call("getElementById", "input1").Get("value").String()
value2 := doc.Call("getElementById", "input2").Get("value").String()
int1, _ := strconv.Atoi(value1)
int2, _ := strconv.Atoi(value2)
doc.Call("getElementById", "sum").Set("value", int1+int2)
}
Pacakge syscall/js
● Bumpy when manipulate DOM
● access WebAssembly host
environment using the
js/wasm architecture
● API is based on JavaScript
semantics.
● EXPERIMENTAL
func main() {
c := make(chan struct{}, 0)
println("WASM Go Initialized")
// register functions
registerCallbacks()
<-c
println("Callbacks registered.") // console.log
}
func registerCallbacks() {
js.Global().Set("add", js.NewCallback(add))
js.Global().Set("subtract", js.NewCallback(subtract))
}
Use Go as Modules
● Import Go packages
● Complie to .wasm
● Register functions as JS
callbacks
● Invoke functions in JS
● Leave the DOMs to JS
Benefits from Go-wasm
● Runs existing program / library
in Front-End
● Make golang protable
● Thread Safe
● Join .wasm from other
languages
Go-Wasm Examples
https://justinclift.github.io/wasmGraph1/
GameBoyColor-Wasm
https://github.com/djhworld/gomeboycolor-wasm
Move Back-End Front
Performance no longer a problem. What you want to run in browser?
kubernetes, kubectl, geth...
Lin Clark: A Cartoon Intro to WebAssembly | JSConf EU 2017
https://www.youtube.com/watch?v=HktWin_LPf4
https://hacks.mozilla.org/2017/02/a-cartoon-intro-to-webassembly/
Dan Callahan: Practical WebAssembly | JSConf Budapest 2017
https://www.youtube.com/watch?v=bac0dGQbUto
Using WebAssembly and Threads (Chrome Dev Summit 2018)
https://www.youtube.com/watch?v=zgOGZgAPUjQ
Watch Lin Clark cartoon if you only have 30 mins!
Q&A

More Related Content

What's hot

Hey webpack
Hey webpackHey webpack
Hey webpack
Andrew Makarow
 
Create Rest API in Nodejs
Create Rest API in Nodejs Create Rest API in Nodejs
Create Rest API in Nodejs
Irfan Maulana
 
Webpack: from 0 to 2
Webpack: from 0 to 2Webpack: from 0 to 2
Webpack: from 0 to 2
Alessandro Bellini
 
Improving build solutions dependency management with webpack
Improving build solutions  dependency management with webpackImproving build solutions  dependency management with webpack
Improving build solutions dependency management with webpack
NodeXperts
 
Webpack
Webpack Webpack
Webpack
DataArt
 
Webpack slides
Webpack slidesWebpack slides
JS & NodeJS - An Introduction
JS & NodeJS - An IntroductionJS & NodeJS - An Introduction
JS & NodeJS - An Introduction
Nirvanic Labs
 
Node.js with Express
Node.js with ExpressNode.js with Express
Node.js with Express
Gergely Németh
 
Bundle your modules with Webpack
Bundle your modules with WebpackBundle your modules with Webpack
Bundle your modules with Webpack
Jake Peyser
 
Webpack: your final module bundler
Webpack: your final module bundlerWebpack: your final module bundler
Webpack: your final module bundler
Andrea Giannantonio
 
Create a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBCreate a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDB
Hengki Sihombing
 
CasperJS
CasperJSCasperJS
CasperJS
LearningTech
 
Continuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScriptContinuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScript
Lars Thorup
 
Nodejs web,db,hosting
Nodejs web,db,hostingNodejs web,db,hosting
Nodejs web,db,hosting
Kenu, GwangNam Heo
 
Grunt - The JavaScript Task Runner
Grunt - The JavaScript Task RunnerGrunt - The JavaScript Task Runner
Grunt - The JavaScript Task Runner
Mohammed Arif
 
An Intro into webpack
An Intro into webpackAn Intro into webpack
An Intro into webpack
Squash Apps Pvt Ltd
 
JavaScript Engine and WebAssembly
JavaScript Engine and WebAssemblyJavaScript Engine and WebAssembly
JavaScript Engine and WebAssembly
Changhwan Yi
 
Node.js 201: building real-world applications in pure JavaScript
Node.js 201: building real-world applications in pure JavaScriptNode.js 201: building real-world applications in pure JavaScript
Node.js 201: building real-world applications in pure JavaScript
Tom Boutell
 
What grunt?
What grunt?What grunt?
What grunt?
Lucio Martinez
 
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
 

What's hot (20)

Hey webpack
Hey webpackHey webpack
Hey webpack
 
Create Rest API in Nodejs
Create Rest API in Nodejs Create Rest API in Nodejs
Create Rest API in Nodejs
 
Webpack: from 0 to 2
Webpack: from 0 to 2Webpack: from 0 to 2
Webpack: from 0 to 2
 
Improving build solutions dependency management with webpack
Improving build solutions  dependency management with webpackImproving build solutions  dependency management with webpack
Improving build solutions dependency management with webpack
 
Webpack
Webpack Webpack
Webpack
 
Webpack slides
Webpack slidesWebpack slides
Webpack slides
 
JS & NodeJS - An Introduction
JS & NodeJS - An IntroductionJS & NodeJS - An Introduction
JS & NodeJS - An Introduction
 
Node.js with Express
Node.js with ExpressNode.js with Express
Node.js with Express
 
Bundle your modules with Webpack
Bundle your modules with WebpackBundle your modules with Webpack
Bundle your modules with Webpack
 
Webpack: your final module bundler
Webpack: your final module bundlerWebpack: your final module bundler
Webpack: your final module bundler
 
Create a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBCreate a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDB
 
CasperJS
CasperJSCasperJS
CasperJS
 
Continuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScriptContinuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScript
 
Nodejs web,db,hosting
Nodejs web,db,hostingNodejs web,db,hosting
Nodejs web,db,hosting
 
Grunt - The JavaScript Task Runner
Grunt - The JavaScript Task RunnerGrunt - The JavaScript Task Runner
Grunt - The JavaScript Task Runner
 
An Intro into webpack
An Intro into webpackAn Intro into webpack
An Intro into webpack
 
JavaScript Engine and WebAssembly
JavaScript Engine and WebAssemblyJavaScript Engine and WebAssembly
JavaScript Engine and WebAssembly
 
Node.js 201: building real-world applications in pure JavaScript
Node.js 201: building real-world applications in pure JavaScriptNode.js 201: building real-world applications in pure JavaScript
Node.js 201: building real-world applications in pure JavaScript
 
What grunt?
What grunt?What grunt?
What grunt?
 
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
 

Similar to Intro to go web assembly

Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
Greg Whalin
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
Justin Cataldo
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest services
Ioan Eugen Stan
 
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
 
Grunt & Front-end Workflow
Grunt & Front-end WorkflowGrunt & Front-end Workflow
Grunt & Front-end Workflow
Pagepro
 
Let Grunt do the work, focus on the fun!
Let Grunt do the work, focus on the fun!Let Grunt do the work, focus on the fun!
Let Grunt do the work, focus on the fun!
Dirk Ginader
 
Developing High Performance Web Apps
Developing High Performance Web AppsDeveloping High Performance Web Apps
Developing High Performance Web Apps
Timothy Fisher
 
Grails 101
Grails 101Grails 101
Grails 101
David Jacobs
 
Why Gradle?
Why Gradle?Why Gradle?
Why Gradle?
Peter Ledbrook
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Engine
catherinewall
 
Module, AMD, RequireJS
Module, AMD, RequireJSModule, AMD, RequireJS
Module, AMD, RequireJS
偉格 高
 
Devfest09 Cschalk Gwt
Devfest09 Cschalk GwtDevfest09 Cschalk Gwt
Devfest09 Cschalk Gwt
Chris Schalk
 
Supercharging tutorials with WebAssembly
Supercharging tutorials with WebAssemblySupercharging tutorials with WebAssembly
Supercharging tutorials with WebAssembly
All Things Open
 
The Dojo Build System
The Dojo Build SystemThe Dojo Build System
The Dojo Build System
klipstein
 
7 tips for javascript rich ajax websites
7 tips for javascript rich ajax websites7 tips for javascript rich ajax websites
7 tips for javascript rich ajax websites
oazabir
 
Treinamento frontend
Treinamento frontendTreinamento frontend
Treinamento frontend
Adrian Caetano
 
Javascript as a target language - GWT KickOff - Part 2/2
Javascript as a target language - GWT KickOff - Part 2/2Javascript as a target language - GWT KickOff - Part 2/2
Javascript as a target language - GWT KickOff - Part 2/2
JooinK
 
Andriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tipsAndriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tips
OWASP Kyiv
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
toddbr
 
Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2
Asher Martin
 

Similar to Intro to go web assembly (20)

Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest services
 
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)
 
Grunt & Front-end Workflow
Grunt & Front-end WorkflowGrunt & Front-end Workflow
Grunt & Front-end Workflow
 
Let Grunt do the work, focus on the fun!
Let Grunt do the work, focus on the fun!Let Grunt do the work, focus on the fun!
Let Grunt do the work, focus on the fun!
 
Developing High Performance Web Apps
Developing High Performance Web AppsDeveloping High Performance Web Apps
Developing High Performance Web Apps
 
Grails 101
Grails 101Grails 101
Grails 101
 
Why Gradle?
Why Gradle?Why Gradle?
Why Gradle?
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Engine
 
Module, AMD, RequireJS
Module, AMD, RequireJSModule, AMD, RequireJS
Module, AMD, RequireJS
 
Devfest09 Cschalk Gwt
Devfest09 Cschalk GwtDevfest09 Cschalk Gwt
Devfest09 Cschalk Gwt
 
Supercharging tutorials with WebAssembly
Supercharging tutorials with WebAssemblySupercharging tutorials with WebAssembly
Supercharging tutorials with WebAssembly
 
The Dojo Build System
The Dojo Build SystemThe Dojo Build System
The Dojo Build System
 
7 tips for javascript rich ajax websites
7 tips for javascript rich ajax websites7 tips for javascript rich ajax websites
7 tips for javascript rich ajax websites
 
Treinamento frontend
Treinamento frontendTreinamento frontend
Treinamento frontend
 
Javascript as a target language - GWT KickOff - Part 2/2
Javascript as a target language - GWT KickOff - Part 2/2Javascript as a target language - GWT KickOff - Part 2/2
Javascript as a target language - GWT KickOff - Part 2/2
 
Andriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tipsAndriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tips
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2
 

More from Che-Chia Chang

COSCUP Scouter: Face recognizer retrieves your Github contribution
COSCUP Scouter: Face recognizer retrieves your Github contributionCOSCUP Scouter: Face recognizer retrieves your Github contribution
COSCUP Scouter: Face recognizer retrieves your Github contribution
Che-Chia Chang
 
Elk for applications on k8s
Elk for applications on k8sElk for applications on k8s
Elk for applications on k8s
Che-Chia Chang
 
Gdg devfest-2018
Gdg devfest-2018Gdg devfest-2018
Gdg devfest-2018
Che-Chia Chang
 
CRI, OCI, and CRI-O
CRI, OCI, and CRI-OCRI, OCI, and CRI-O
CRI, OCI, and CRI-O
Che-Chia Chang
 
Kubernetes networks
Kubernetes networksKubernetes networks
Kubernetes networks
Che-Chia Chang
 
Automated container-deployment-on-kubernetes
Automated container-deployment-on-kubernetesAutomated container-deployment-on-kubernetes
Automated container-deployment-on-kubernetes
Che-Chia Chang
 
Deploy High Availability Kubernetes with Kubespray
Deploy High Availability Kubernetes with KubesprayDeploy High Availability Kubernetes with Kubespray
Deploy High Availability Kubernetes with Kubespray
Che-Chia Chang
 
K8s storage-glusterfs-20180210
K8s storage-glusterfs-20180210K8s storage-glusterfs-20180210
K8s storage-glusterfs-20180210
Che-Chia Chang
 

More from Che-Chia Chang (8)

COSCUP Scouter: Face recognizer retrieves your Github contribution
COSCUP Scouter: Face recognizer retrieves your Github contributionCOSCUP Scouter: Face recognizer retrieves your Github contribution
COSCUP Scouter: Face recognizer retrieves your Github contribution
 
Elk for applications on k8s
Elk for applications on k8sElk for applications on k8s
Elk for applications on k8s
 
Gdg devfest-2018
Gdg devfest-2018Gdg devfest-2018
Gdg devfest-2018
 
CRI, OCI, and CRI-O
CRI, OCI, and CRI-OCRI, OCI, and CRI-O
CRI, OCI, and CRI-O
 
Kubernetes networks
Kubernetes networksKubernetes networks
Kubernetes networks
 
Automated container-deployment-on-kubernetes
Automated container-deployment-on-kubernetesAutomated container-deployment-on-kubernetes
Automated container-deployment-on-kubernetes
 
Deploy High Availability Kubernetes with Kubespray
Deploy High Availability Kubernetes with KubesprayDeploy High Availability Kubernetes with Kubespray
Deploy High Availability Kubernetes with Kubespray
 
K8s storage-glusterfs-20180210
K8s storage-glusterfs-20180210K8s storage-glusterfs-20180210
K8s storage-glusterfs-20180210
 

Recently uploaded

Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
lorraineandreiamcidl
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Undress Baby
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
pavan998932
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 

Recently uploaded (20)

Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 

Intro to go web assembly

  • 3. WebAssembly ● A new language for web ● Compiled from other languages ● Offers maximized, reliable performance ● Not replacing JS
  • 4. A new language for web ● A low level language ● standard ● a binary instruction and a assembly-like format ● Supported by Mozilla, Google, Microsoft, Apple
  • 5. WebAssembly Now ● Release 1.0 (Draft, last updated Dec 13, 2018) ● Experimental
  • 7. Web Javascript ● Slow ● Insecure ● Dynamic type vs static type ● Avoid heavy computing in Front-End ● Easy-writing ● Huge eco-system
  • 8. Historical Javascript ● ECMAScript -> by Brendan Eich in late 1995 ● Internet Explorer 3 ● NodeJS -> 2009 ● npm -> 2010
  • 9. JS is getting faster ● Just In Time compiler of JS engine ● trace and re-optimize (loop) ● GC ● Built-in functions / Stadard Library / APIs
  • 10. But wasm is faster https://hacks.mozilla.org/2017/02/w hat-makes-webassembly-fast/ ● Wasm is compiled ● No type assertion ● No need to re-optimize ● Much less GC
  • 11. .go .wasm (IR) Firefox x86 Assembly spider monkey Chart Data Source Info From WebAssembly to JS engine https://mbebenita.github.io/WasmExplorer/
  • 12. Some Examples “Unleash the power of your web devices”
  • 14. Epic Epic Zen Garden Unreal Engine in WebAssembly and WebGL 2.0 https://s3.amazonaws.com/mozilla-games/ZenGarden/EpicZenGarden.html
  • 16. Go-WebAssembly ● go 1.11 (Aug. 2018) ● Experimental feature https://github.com/golang/go/wiki/W ebAssembly
  • 17. 1.11 Release Note Go 1.11 adds an experimental port to WebAssembly (js/wasm). Go programs compile to one WebAssembly module Go runtime for goroutine scheduling, garbage collection, maps, etc. Go programs can call into JavaScript using the new experimental syscall/js package. new GOOS "js" and GOARCH "wasm"
  • 19. Go-WebAssembly ● Runs existing program / library in Front-End ● Make golang protable ● Thread Safe ● Back-End to Full-Stack?
  • 21. <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>
  • 22. run-%: GOOS=js GOARCH=wasm go run -exec="$(shell go env GOROOT)/misc/wasm/go_js_wasm_exec" ./src/$* test: GOOS=js GOARCH=wasm go test -exec="$(shell go env GOROOT)/misc/wasm/go_js_wasm_exec" ./... build-%: GOOS=js GOARCH=wasm go build -o public/lib.wasm ./src/$* server: go run ./src/server -listen :8080 -dir public
  • 23. .go .wasm JS API Engine Chart Data Source Info From Golang to Web Compile golang functions to wasm, and runs in JS
  • 24. package main import ( "strconv" "syscall/js" ) func add(i []js.Value) { doc := js.Global().Get("document") value1 := doc.Call("getElementById", "input1").Get("value").String() value2 := doc.Call("getElementById", "input2").Get("value").String() int1, _ := strconv.Atoi(value1) int2, _ := strconv.Atoi(value2) doc.Call("getElementById", "sum").Set("value", int1+int2) }
  • 25. // JS func add() { var value1 = document.getElementById("input1").value; vat value2 = document.getElementById("input2").value; document.getElementById("sum").value = Number(value1) + Number(value2); } // Go func add(i []js.Value) { doc := js.Global().Get("document") value1 := doc.Call("getElementById", "input1").Get("value").String() value2 := doc.Call("getElementById", "input2").Get("value").String() int1, _ := strconv.Atoi(value1) int2, _ := strconv.Atoi(value2) doc.Call("getElementById", "sum").Set("value", int1+int2) }
  • 26. Pacakge syscall/js ● Bumpy when manipulate DOM ● access WebAssembly host environment using the js/wasm architecture ● API is based on JavaScript semantics. ● EXPERIMENTAL
  • 27. func main() { c := make(chan struct{}, 0) println("WASM Go Initialized") // register functions registerCallbacks() <-c println("Callbacks registered.") // console.log } func registerCallbacks() { js.Global().Set("add", js.NewCallback(add)) js.Global().Set("subtract", js.NewCallback(subtract)) }
  • 28. Use Go as Modules ● Import Go packages ● Complie to .wasm ● Register functions as JS callbacks ● Invoke functions in JS ● Leave the DOMs to JS
  • 29. Benefits from Go-wasm ● Runs existing program / library in Front-End ● Make golang protable ● Thread Safe ● Join .wasm from other languages
  • 32. Move Back-End Front Performance no longer a problem. What you want to run in browser? kubernetes, kubectl, geth...
  • 33. Lin Clark: A Cartoon Intro to WebAssembly | JSConf EU 2017 https://www.youtube.com/watch?v=HktWin_LPf4 https://hacks.mozilla.org/2017/02/a-cartoon-intro-to-webassembly/ Dan Callahan: Practical WebAssembly | JSConf Budapest 2017 https://www.youtube.com/watch?v=bac0dGQbUto Using WebAssembly and Threads (Chrome Dev Summit 2018) https://www.youtube.com/watch?v=zgOGZgAPUjQ Watch Lin Clark cartoon if you only have 30 mins!
  • 34. Q&A

Editor's Notes

  1. Runs in javascript engines
  2. Slow: type assertion, parse, execute, requires lots of optimization Insecure: memory control
  3. Designed for web
  4. Slow: type assertion, parse, execute, requires lots of optimization
  5. Near machine code performance
  6. Runs in javascript engines
  7. Go
  8. The WebAssembly.instantiateStreaming() function compiles and instantiates a WebAssembly module directly from a streamed underlying source. This is the most efficient, optimized way to load wasm code.
  9. Go