SlideShare a Scribd company logo
I’m @aq
HELLO!
5 facts about @aq
Follow
@catskillsconf
Oct 23-25
Ruby, JS, Go Performance etc
but you can hire me!
The Story of
a Yak Shave
Some node.js options:
not precise or 1:1; poor font handling
node-canvas
almost there, but more geared to GUI
applications
node-webkit
Have the ability to reuse existing code and
knowledge about production
I wanted to see if go was
possible
aka Chromium Embedded Framework
Enter and cef2go
chromium
C & C++ API
cef2go (cgo)
C & C++ API
cef2go
your go app
your js app
Service Request/
Response
chromium
JS Exec/
Response
1 for i := 0; i < 3; i++ {
2 browser := cef.CreateBrowser(browserSettings, url, true)
3 browser.ExecuteJavaScript("console.log('we outchea');", "sup.js", 1)
4 }
5
3 browser.ExecuteJavaScript("console.log('we outchea');", "sup.js", 1)
github.com/paperlesspost/chromefarm
Solve it with AJAX
10 func main() {
12 farm := chromefarm.NewFarm()
14 // This serves the postback.html for the browser to load
15 http.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) {
17 http.ServeFile(res, req, "postback.html")
18 })
19 // this handles the callback from JS/AJAX
20 http.HandleFunc("/callback", func(res http.ResponseWriter, req *http.Request) {
21 message := req.FormValue("message")
22 log.Println("Received message from browser: %s", message)
25 })
26 farm.OnReady(func() {
29 for i := 0; i < 2; i++ {
30 browser := farm.CreateBrowser(url)
31 browser.ExecuteJavaScript(fmt.Sprintf("console.log('sup %d');", i), "eva
32 }
33 })
34 farm.Start(":3000")
36 }
7 <script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
8 <script type="text/javascript">
9 $.post('/callback', {message: "I've loaded successfully"}, function(resp) {
10 console.log(resp);
11 });
12 </script>
13 </body>
This has to get MORE awesome
Hmmm
24 extCode := `
25 var cef2go;
26 if (!cef2go) {
27 cef2go = {};
28 }
29 (function() {
30 cef2go.callback = function() {
31 native function callback();
32 return callback.apply(this, arguments);
33 }
34 })();
35 `
36 C.cef_register_extension(CEFString("v8/cef2go"), CEFString(extCode), handler)
C C
cef.callback('myGoCallback', "any", "type", 0, "args", true)
1 // cef.callback('myGoCallback', "any", "type", 0.0, 13, true)
2 cef.RegisterV8Callback("myGoCallback", cef.V8Callback(func(args []*cef.V8Value) {
3 arg0 := args[0].ToString() //=> "any"
4 arg1 := args[1].ToString() //=> "type"
5 arg2 := args[2].ToFloat32() //=> 0.0
6 arg3 := args[3].ToInt32() //=> 13
7 arg4 := args[4].ToBool() //=> true
8 // I'm in go now #yolo
9 }))
10
BUt WHY?!
Or a JS app that takes advantage of Go’s
concurrency + tools
A Go app that makes
use of the browser + JS
I mean the real reason is because its an
epic and beautiful hack.
@aq
quirkey.com
github.com/quirkey
THANKS

More Related Content

What's hot

Доклад Антона Поварова "Go in Badoo" с Golang Meetup
Доклад Антона Поварова "Go in Badoo" с Golang MeetupДоклад Антона Поварова "Go in Badoo" с Golang Meetup
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
Badoo Development
 
Async programming on NET
Async programming on NETAsync programming on NET
Async programming on NET
yuyijq
 
非同期javascriptの過去と未来
非同期javascriptの過去と未来非同期javascriptの過去と未来
非同期javascriptの過去と未来
Taketoshi 青野健利
 
Security Challenges in Node.js
Security Challenges in Node.jsSecurity Challenges in Node.js
Security Challenges in Node.js
Websecurify
 
みんなの知らないChrome appsの世界
みんなの知らないChrome appsの世界みんなの知らないChrome appsの世界
みんなの知らないChrome appsの世界
Yoichiro Tanaka
 
Scalable Angular 2 Application Architecture
Scalable Angular 2 Application ArchitectureScalable Angular 2 Application Architecture
Scalable Angular 2 Application Architecture
FDConf
 
Potential gotchas in making a backbone app
Potential gotchas in making a backbone appPotential gotchas in making a backbone app
Potential gotchas in making a backbone app
Vignesh Nandha Kumar
 
G*なクラウド 雲のかなたに ショートバージョン
G*なクラウド 雲のかなたに ショートバージョンG*なクラウド 雲のかなたに ショートバージョン
G*なクラウド 雲のかなたに ショートバージョン
Tsuyoshi Yamamoto
 
KEYNOTE: Node.js interactive 2017 - The case for node.js
KEYNOTE: Node.js interactive 2017 - The case for node.jsKEYNOTE: Node.js interactive 2017 - The case for node.js
KEYNOTE: Node.js interactive 2017 - The case for node.js
Justin Beckwith
 
Hunting for malicious modules in npm - NodeSummit
Hunting for malicious modules in npm - NodeSummitHunting for malicious modules in npm - NodeSummit
Hunting for malicious modules in npm - NodeSummit
Adam Baldwin
 
Serenity Now
Serenity NowSerenity Now
Serenity Now
Daniel MacTough
 
Star bed 2018.07.19
Star bed 2018.07.19Star bed 2018.07.19
Star bed 2018.07.19
Ruo Ando
 
HTML_HHC
HTML_HHCHTML_HHC
HTML_HHC
princekumar420
 
Puppeteer
PuppeteerPuppeteer
Puppeteer
Adrian Caetano
 
Владимир Мигуро "Дао Node.js"
Владимир Мигуро "Дао Node.js"Владимир Мигуро "Дао Node.js"
Владимир Мигуро "Дао Node.js"EPAM Systems
 
ActionHeroJS Talk
ActionHeroJS TalkActionHeroJS Talk
ActionHeroJS Talk
David Peralta
 
ReactJS & Material-ui Hello world
ReactJS & Material-ui Hello worldReactJS & Material-ui Hello world
ReactJS & Material-ui Hello world
Daniel Lim
 
02 Introduction to Javascript
02 Introduction to Javascript02 Introduction to Javascript
02 Introduction to Javascriptcrgwbr
 

What's hot (20)

Доклад Антона Поварова "Go in Badoo" с Golang Meetup
Доклад Антона Поварова "Go in Badoo" с Golang MeetupДоклад Антона Поварова "Go in Badoo" с Golang Meetup
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
 
Include
IncludeInclude
Include
 
Async programming on NET
Async programming on NETAsync programming on NET
Async programming on NET
 
非同期javascriptの過去と未来
非同期javascriptの過去と未来非同期javascriptの過去と未来
非同期javascriptの過去と未来
 
Security Challenges in Node.js
Security Challenges in Node.jsSecurity Challenges in Node.js
Security Challenges in Node.js
 
みんなの知らないChrome appsの世界
みんなの知らないChrome appsの世界みんなの知らないChrome appsの世界
みんなの知らないChrome appsの世界
 
Scalable Angular 2 Application Architecture
Scalable Angular 2 Application ArchitectureScalable Angular 2 Application Architecture
Scalable Angular 2 Application Architecture
 
Potential gotchas in making a backbone app
Potential gotchas in making a backbone appPotential gotchas in making a backbone app
Potential gotchas in making a backbone app
 
G*なクラウド 雲のかなたに ショートバージョン
G*なクラウド 雲のかなたに ショートバージョンG*なクラウド 雲のかなたに ショートバージョン
G*なクラウド 雲のかなたに ショートバージョン
 
KEYNOTE: Node.js interactive 2017 - The case for node.js
KEYNOTE: Node.js interactive 2017 - The case for node.jsKEYNOTE: Node.js interactive 2017 - The case for node.js
KEYNOTE: Node.js interactive 2017 - The case for node.js
 
Hunting for malicious modules in npm - NodeSummit
Hunting for malicious modules in npm - NodeSummitHunting for malicious modules in npm - NodeSummit
Hunting for malicious modules in npm - NodeSummit
 
Serenity Now
Serenity NowSerenity Now
Serenity Now
 
Gkm referral program
Gkm referral programGkm referral program
Gkm referral program
 
Star bed 2018.07.19
Star bed 2018.07.19Star bed 2018.07.19
Star bed 2018.07.19
 
HTML_HHC
HTML_HHCHTML_HHC
HTML_HHC
 
Puppeteer
PuppeteerPuppeteer
Puppeteer
 
Владимир Мигуро "Дао Node.js"
Владимир Мигуро "Дао Node.js"Владимир Мигуро "Дао Node.js"
Владимир Мигуро "Дао Node.js"
 
ActionHeroJS Talk
ActionHeroJS TalkActionHeroJS Talk
ActionHeroJS Talk
 
ReactJS & Material-ui Hello world
ReactJS & Material-ui Hello worldReactJS & Material-ui Hello world
ReactJS & Material-ui Hello world
 
02 Introduction to Javascript
02 Introduction to Javascript02 Introduction to Javascript
02 Introduction to Javascript
 

Similar to Chromium Embedded Framework + Go at Brooklyn JS

Living with garbage
Living with garbageLiving with garbage
Living with garbage
lucenerevolution
 
Living With Garbage
Living With GarbageLiving With Garbage
Living With Garbage
Gregg Donovan
 
Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013
Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013
Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013
Gregg Donovan
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
David Padbury
 
Everything as a Code / Александр Тарасов (Одноклассники)
Everything as a Code / Александр Тарасов (Одноклассники)Everything as a Code / Александр Тарасов (Одноклассники)
Everything as a Code / Александр Тарасов (Одноклассники)
Ontico
 
Everything as a code
Everything as a codeEverything as a code
Everything as a code
Aleksandr Tarasov
 
JavaScript front end performance optimizations
JavaScript front end performance optimizationsJavaScript front end performance optimizations
JavaScript front end performance optimizations
Chris Love
 
Oracle APEX migration to 5.1 - Our experience
Oracle APEX migration to 5.1 - Our experienceOracle APEX migration to 5.1 - Our experience
Oracle APEX migration to 5.1 - Our experience
Lino Schildenfeld
 
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Provectus
 
HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?
Ankara JUG
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing UpDavid Padbury
 
[drupalcampatx] Adaptive Images in Responsive Web Design
[drupalcampatx] Adaptive Images in Responsive Web Design[drupalcampatx] Adaptive Images in Responsive Web Design
[drupalcampatx] Adaptive Images in Responsive Web DesignChristopher Schmitt
 
Live deployment, ci, drupal
Live deployment, ci, drupalLive deployment, ci, drupal
Live deployment, ci, drupal
Andrii Podanenko
 
Scripting Oracle Develop 2007
Scripting Oracle Develop 2007Scripting Oracle Develop 2007
Scripting Oracle Develop 2007
Tugdual Grall
 
[psuweb] Adaptive Images in Responsive Web Design
[psuweb] Adaptive Images in Responsive Web Design[psuweb] Adaptive Images in Responsive Web Design
[psuweb] Adaptive Images in Responsive Web DesignChristopher Schmitt
 
Appsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaolaAppsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaoladrewz lin
 
[refreshpitt] Adaptive Images in Responsive Web Design
[refreshpitt] Adaptive Images in Responsive Web Design[refreshpitt] Adaptive Images in Responsive Web Design
[refreshpitt] Adaptive Images in Responsive Web DesignChristopher Schmitt
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App Engine
Andy McKay
 
Reutov, yunusov, nagibin random numbers take ii
Reutov, yunusov, nagibin   random numbers take iiReutov, yunusov, nagibin   random numbers take ii
Reutov, yunusov, nagibin random numbers take iiDefconRussia
 

Similar to Chromium Embedded Framework + Go at Brooklyn JS (20)

Living with garbage
Living with garbageLiving with garbage
Living with garbage
 
Living With Garbage
Living With GarbageLiving With Garbage
Living With Garbage
 
Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013
Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013
Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
 
Everything as a Code / Александр Тарасов (Одноклассники)
Everything as a Code / Александр Тарасов (Одноклассники)Everything as a Code / Александр Тарасов (Одноклассники)
Everything as a Code / Александр Тарасов (Одноклассники)
 
Everything as a code
Everything as a codeEverything as a code
Everything as a code
 
JavaScript front end performance optimizations
JavaScript front end performance optimizationsJavaScript front end performance optimizations
JavaScript front end performance optimizations
 
huhu
huhuhuhu
huhu
 
Oracle APEX migration to 5.1 - Our experience
Oracle APEX migration to 5.1 - Our experienceOracle APEX migration to 5.1 - Our experience
Oracle APEX migration to 5.1 - Our experience
 
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
 
HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
[drupalcampatx] Adaptive Images in Responsive Web Design
[drupalcampatx] Adaptive Images in Responsive Web Design[drupalcampatx] Adaptive Images in Responsive Web Design
[drupalcampatx] Adaptive Images in Responsive Web Design
 
Live deployment, ci, drupal
Live deployment, ci, drupalLive deployment, ci, drupal
Live deployment, ci, drupal
 
Scripting Oracle Develop 2007
Scripting Oracle Develop 2007Scripting Oracle Develop 2007
Scripting Oracle Develop 2007
 
[psuweb] Adaptive Images in Responsive Web Design
[psuweb] Adaptive Images in Responsive Web Design[psuweb] Adaptive Images in Responsive Web Design
[psuweb] Adaptive Images in Responsive Web Design
 
Appsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaolaAppsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaola
 
[refreshpitt] Adaptive Images in Responsive Web Design
[refreshpitt] Adaptive Images in Responsive Web Design[refreshpitt] Adaptive Images in Responsive Web Design
[refreshpitt] Adaptive Images in Responsive Web Design
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App Engine
 
Reutov, yunusov, nagibin random numbers take ii
Reutov, yunusov, nagibin   random numbers take iiReutov, yunusov, nagibin   random numbers take ii
Reutov, yunusov, nagibin random numbers take ii
 

Recently uploaded

Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Sanjeev Rampal
 
Internet-Security-Safeguarding-Your-Digital-World (1).pptx
Internet-Security-Safeguarding-Your-Digital-World (1).pptxInternet-Security-Safeguarding-Your-Digital-World (1).pptx
Internet-Security-Safeguarding-Your-Digital-World (1).pptx
VivekSinghShekhawat2
 
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdfJAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
Javier Lasa
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
3ipehhoa
 
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Brad Spiegel Macon GA
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
3ipehhoa
 
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
3ipehhoa
 
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
keoku
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
nirahealhty
 
Comptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guideComptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guide
GTProductions1
 
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
eutxy
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
Rogerio Filho
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
JungkooksNonexistent
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
Arif0071
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
laozhuseo02
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
Gal Baras
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
natyesu
 
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
ufdana
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
laozhuseo02
 

Recently uploaded (20)

Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
 
Internet-Security-Safeguarding-Your-Digital-World (1).pptx
Internet-Security-Safeguarding-Your-Digital-World (1).pptxInternet-Security-Safeguarding-Your-Digital-World (1).pptx
Internet-Security-Safeguarding-Your-Digital-World (1).pptx
 
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdfJAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
 
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
 
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
 
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
 
Comptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guideComptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guide
 
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
 
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
 

Chromium Embedded Framework + Go at Brooklyn JS

  • 3.
  • 5.
  • 6. Ruby, JS, Go Performance etc but you can hire me!
  • 7.
  • 8. The Story of a Yak Shave
  • 9.
  • 11. not precise or 1:1; poor font handling node-canvas
  • 12. almost there, but more geared to GUI applications node-webkit
  • 13.
  • 14. Have the ability to reuse existing code and knowledge about production I wanted to see if go was possible
  • 15. aka Chromium Embedded Framework Enter and cef2go
  • 16. chromium C & C++ API cef2go (cgo)
  • 17. C & C++ API cef2go your go app your js app Service Request/ Response chromium JS Exec/ Response
  • 18. 1 for i := 0; i < 3; i++ { 2 browser := cef.CreateBrowser(browserSettings, url, true) 3 browser.ExecuteJavaScript("console.log('we outchea');", "sup.js", 1) 4 } 5
  • 21. 10 func main() { 12 farm := chromefarm.NewFarm() 14 // This serves the postback.html for the browser to load 15 http.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) { 17 http.ServeFile(res, req, "postback.html") 18 }) 19 // this handles the callback from JS/AJAX 20 http.HandleFunc("/callback", func(res http.ResponseWriter, req *http.Request) { 21 message := req.FormValue("message") 22 log.Println("Received message from browser: %s", message) 25 }) 26 farm.OnReady(func() { 29 for i := 0; i < 2; i++ { 30 browser := farm.CreateBrowser(url) 31 browser.ExecuteJavaScript(fmt.Sprintf("console.log('sup %d');", i), "eva 32 } 33 }) 34 farm.Start(":3000") 36 } 7 <script src="http://code.jquery.com/jquery-2.1.4.min.js"></script> 8 <script type="text/javascript"> 9 $.post('/callback', {message: "I've loaded successfully"}, function(resp) { 10 console.log(resp); 11 }); 12 </script> 13 </body>
  • 22. This has to get MORE awesome Hmmm
  • 23. 24 extCode := ` 25 var cef2go; 26 if (!cef2go) { 27 cef2go = {}; 28 } 29 (function() { 30 cef2go.callback = function() { 31 native function callback(); 32 return callback.apply(this, arguments); 33 } 34 })(); 35 ` 36 C.cef_register_extension(CEFString("v8/cef2go"), CEFString(extCode), handler)
  • 24. C C
  • 26. 1 // cef.callback('myGoCallback', "any", "type", 0.0, 13, true) 2 cef.RegisterV8Callback("myGoCallback", cef.V8Callback(func(args []*cef.V8Value) { 3 arg0 := args[0].ToString() //=> "any" 4 arg1 := args[1].ToString() //=> "type" 5 arg2 := args[2].ToFloat32() //=> 0.0 6 arg3 := args[3].ToInt32() //=> 13 7 arg4 := args[4].ToBool() //=> true 8 // I'm in go now #yolo 9 })) 10
  • 27.
  • 29. Or a JS app that takes advantage of Go’s concurrency + tools A Go app that makes use of the browser + JS
  • 30. I mean the real reason is because its an epic and beautiful hack.

Editor's Notes

  1. 1) grew up less then a mile from here which leads me to
  2. 2) KINGSTON now repping the HV and live in a 350 year old house, save the date Oct 23rd: Catskills Conf is coming
  3. 3) Used to be the Chief Taco Officer at Paperless Post, now I'm the Chief Scientist and get to work on things like I'm about to show you
  4. 4) Also been doing JS/Ruby/Go Perfomance and Organization consulting so hire me
  5. 5) I host a weekly podcast about Music, Food and Programming with MRB called Beats, Rye & Types (check out the episode with Jed)
  6. Started with the need to take a JS application that relied on canvas to turn data into images. It's important to note that we actually needed a full browser and not just JS - we needed canvas and a way to get that rendered buffer from canvas
  7. I’m sure there are other options and newer ones since we started this project a year ago.
  8. that damn gopher
  9. I really wanted to figure out a way to do this in Go because I've been writing a lot of Go and wanted to be able to reuse the communication, monitoring and tooling that I had already created.
  10. Explored some existing webkit wrappers but nothing really worked well, until I found Chromium embedded framework (CEF) and cef2go.
  11. cef2go takes advantage of the fact that cef exposes a simple C api/bindings and go has amazing support for embedding utilizing c code through cef2go cef2go was in a sort of bad state, so I spent a bunch of time cleaning it up and getting it working on linux
  12. eventually I got to a place where I could boot up a "browser" and execute JS in it.
  13. The cool thing is that because of Go's concurrency model it took no extra work to just loop and create many browsers. In this case, the idea would be 1-per CPU.
  14. The next part was getting data back from JS into the go process and back to the client of the application. The problem is ExecuteJavascript is async so you can't just get the return value.
  15. The "normal" way to do this was to set up an http server and handle AJAX post calls from the JS. This actually was pretty easy, I combined the cef boot + http setup in a little wrapper. Created a little library to manage this called chromefarm.
  16. It looked something like: Go code JS code
  17. But i knew there had to be SOME way to call directly back to go from JS.
  18. Turns out, through some roundabout ways, you can create JS methods bound to the V8 instance in CEF that are backed by NATIVE methods. Native in this case means a C function that is compiled alongside CEF, but using the magic of CGO that method can actually be backed by a Go function. SO
  19. Creating these native methods was sort of a pain though, so using the property of JS that allows methods to have variable argument arity we can bind a single method as a "native" method that can then call any "registered" method on the go side. In the JS this looks like: cef.callback('myGoCallback', "any", "type", 0, "args", true)
  20. And on the go side we just have to register what we want to do with this callback: we also have to translate the individual types to the native types we want in Go. But this actually works, and means we can pass data back and forth from a running browser to Go.
  21. For us it enabled a really stable and fast platform for turning canvas based renders into images. This is running in production today and has already handled requests in the 100s of millions
  22. But ton's of possibilities, it could bring the power of anything you want to do in a modern chrome browser to go and really the other way around, too. You could have an app that's primarily JS but run in a cef shell and have access to all the powerful system level (and concurrent code) that go can provide.