SlideShare a Scribd company logo
1 of 29
Download to read offline
Android is going to Go!
Android and golang
Who are you?
@AlmogBaku on github
1. A serial entrepreneur
2. Co-Founder & CTO @ Rimoto
3. Developer for 12 years
4. GitHub addicted.
5. Blog about entrepreneurship and
development:
www.AlmogBaku.com
What is Rimoto?
Rimoto enable apps to sponsor their user’s mobile-data, and
to became accessible for international travellers,
regardless their data-plan, boosting their engagement.
What are we going to talk about?
1. What is Go?
2. How can we use Go with Android?
3. When is it useful?
Disclaimer
You wanna know more? Google it!
Google tip: use the keyword “golang”
Who heard
about Go?
Why use Go, and what is it?!
• New modern language (since 2009)
• Super fast (native) compiling
• Concurrent
• Performant
• Garbage collected
• Standard libraries
Hello world
package main
import "fmt"
func main() {
fmt.Println("Hello DroidCon!")
}
RUN
Goroutines
func boring() {
for i := 0; i < 10; i++ {
sayIt(i)
}
}
func sayIt(i int) {
time.Sleep(time.Duration(rand.Intn(1e3)) * time.Millisecond)
fmt.Println("I'm saying ", i)
}
RUN
Goroutines
func not_boring() {
for i := 0; i < 10; i++ {
go sayIt(i)
}
time.Sleep(2 * time.Second)
}
func sayIt(i int) {
time.Sleep(time.Duration(rand.Intn(1e3)) * time.Millisecond)
fmt.Println("I'm saying ", i)
}
RUN
Goroutines syncing / WaitGroup
func not_boring_at_all() {
wg := sync.WaitGroup{}
wg.Add(10)
for i := 0; i < 10; i++ {
go sayIt(i, &wg)
}
wg.Wait()
}
func sayIt(i int, wg *sync.WaitGroup) {
defer wg.Done()
time.Sleep(time.Duration(rand.Intn(1e3)) * time.Millisecond)
fmt.Println("I'm saying ", i)
}
RUN
Goroutines communications / Channels
package main
import "fmt"
func main() {
c := make(chan string)
for i := 0; i < 5; i++ {
go func() {
c <- "ping"
}()
}
for i := 0; i < 5; i++ {
go func() {
c <- "pong"
}()
}
for i := 0; i < 10; i++ {
fmt.Println(<-c)
}
}
RUN
Standard libraries
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hi there!")
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}
Go Mobile
A tool for using Golang for native mobile apps easily!
Caution
The Go Mobile project is experimental. Use this at your own
risk.
Why?
1. Full-stack development
2. Write a single cross-platform Go library
3. Bring a simple and modern language
and development tooling to mobile
4. Enjoy Go benefits of native, faster, and
much more concurrent code
How?
Native Apps
● Write the whole app in Go (with OpenGL)
● Use Go packages for graphics, event handling, audio,
etc.
● When Native App UI is not required (i.e. games)
SDK Apps
● Write common functionality in
Go, as a library
Native Go Apps
• 100% Go app
• Multi platform: Android, iOS and Desktop
• GUI with OpenGL
Behind the scenes
NativeActivity
Android
App
Gomobile
A tool that automate this process
– Toolchain installation
– Creating NativeActivity
– Attach the Go runtime to the app
– Bind the App binary to the app
– Multi Architecture build
– Cross platform(Android/iOS) build
$ gomobile build golang.org/x/mobile/example/basic
$ gomobile install golang.org/x/mobile/example/basic
DEMO
SDKs
• Build the app natively with Java/Swift/Obj. C
• Write a simple regular Go library
• Reuse libraries across platforms and projects
Common library
iOS
Android
Backend
service A
Backend
service B
3rd party
Behind the scenes
JNI
Android
App
Go shared binary
rpc
Behind the scenes
package mypkg
func Hello() (string, error) { return "Gopher", nil }
public abstract class Mypkg {
public static String hello() throws Exception { ... }
}
Go Library:
Java API:
Gomobile
A tool that automate this process
– Multi Architecture build
– Build as shared library
– Automatically generate the binding for Java/Swift/Obj. C
– Bundle everything to an .aar
– Cross platform(Android/iOS) build
$ gomobile bind -target=android golang.org/x/mobile/example/bind/hello
DEMO
Disadvantages
Nothing is perfect..
• .aar includes all architecture binaries (increase size)
• go binaries are currently statically linked
• Go as a native app is lack of many sensors and
integrations with the Android/iOS APIs
• The communication between the Platform and the go
binary is not free
Questions?
Thanks.
@AlmogBaku

More Related Content

What's hot

Let the contribution begin
Let the contribution beginLet the contribution begin
Let the contribution beginSeongJae Park
 
如何透過 Golang 與 Heroku 來一鍵部署 臉書機器人與 Line Bot
如何透過 Golang 與 Heroku 來一鍵部署 臉書機器人與 Line Bot如何透過 Golang 與 Heroku 來一鍵部署 臉書機器人與 Line Bot
如何透過 Golang 與 Heroku 來一鍵部署 臉書機器人與 Line BotEvan Lin
 
iThome Chatbot Day: 透過 Golang 無痛建置機器學習聊天機器人
iThome Chatbot Day: 透過 Golang 無痛建置機器學習聊天機器人iThome Chatbot Day: 透過 Golang 無痛建置機器學習聊天機器人
iThome Chatbot Day: 透過 Golang 無痛建置機器學習聊天機器人Evan Lin
 
Fastlane for Androidによる継続的デリバリー
Fastlane for Androidによる継続的デリバリーFastlane for Androidによる継続的デリバリー
Fastlane for Androidによる継続的デリバリーFumiya Nakamura
 
All a flutter about Flutter.io
All a flutter about Flutter.ioAll a flutter about Flutter.io
All a flutter about Flutter.ioSteven Cooper
 
Librerías Opensoure de Square
Librerías Opensoure de Square Librerías Opensoure de Square
Librerías Opensoure de Square betabeers
 
Spring-batch Groovy y Gradle
Spring-batch Groovy y GradleSpring-batch Groovy y Gradle
Spring-batch Groovy y GradleAntonio Mas
 
RESTful API Development using Go
RESTful API Development using GoRESTful API Development using Go
RESTful API Development using GoBaiju Muthukadan
 
Getting started with Go - Florin Patan - Codemotion Rome 2017
Getting started with Go - Florin Patan - Codemotion Rome 2017Getting started with Go - Florin Patan - Codemotion Rome 2017
Getting started with Go - Florin Patan - Codemotion Rome 2017Codemotion
 
Development of Mobile Applications
Development of Mobile ApplicationsDevelopment of Mobile Applications
Development of Mobile ApplicationsDávid Kaya
 
Coding with golang
Coding with golangCoding with golang
Coding with golangHannahMoss14
 
ChromeとAndroidの過去・現在・未来
ChromeとAndroidの過去・現在・未来ChromeとAndroidの過去・現在・未来
ChromeとAndroidの過去・現在・未来Shinobu Okano
 
Intro to Flutter
Intro to FlutterIntro to Flutter
Intro to FlutterEason Pai
 
Google I/O 2018 Extended, Baghdad - Flutter
Google I/O 2018 Extended, Baghdad  - FlutterGoogle I/O 2018 Extended, Baghdad  - Flutter
Google I/O 2018 Extended, Baghdad - FlutterAbdElmomenKadhim
 
Understanding Pseudo-Versions Moving to Go 1.13 What is in Go 1.14+ for Modules
Understanding Pseudo-Versions Moving to Go 1.13 What is in Go 1.14+ for ModulesUnderstanding Pseudo-Versions Moving to Go 1.13 What is in Go 1.14+ for Modules
Understanding Pseudo-Versions Moving to Go 1.13 What is in Go 1.14+ for ModulesMitali Bisht
 
Cross-Platform App Development with Flutter, Xamarin, React Native
Cross-Platform App Development with Flutter, Xamarin, React NativeCross-Platform App Development with Flutter, Xamarin, React Native
Cross-Platform App Development with Flutter, Xamarin, React NativeKorhan Bircan
 
Introduction to go
Introduction to goIntroduction to go
Introduction to goAnthony Chow
 

What's hot (20)

Let the contribution begin
Let the contribution beginLet the contribution begin
Let the contribution begin
 
如何透過 Golang 與 Heroku 來一鍵部署 臉書機器人與 Line Bot
如何透過 Golang 與 Heroku 來一鍵部署 臉書機器人與 Line Bot如何透過 Golang 與 Heroku 來一鍵部署 臉書機器人與 Line Bot
如何透過 Golang 與 Heroku 來一鍵部署 臉書機器人與 Line Bot
 
iThome Chatbot Day: 透過 Golang 無痛建置機器學習聊天機器人
iThome Chatbot Day: 透過 Golang 無痛建置機器學習聊天機器人iThome Chatbot Day: 透過 Golang 無痛建置機器學習聊天機器人
iThome Chatbot Day: 透過 Golang 無痛建置機器學習聊天機器人
 
Fastlane for Androidによる継続的デリバリー
Fastlane for Androidによる継続的デリバリーFastlane for Androidによる継続的デリバリー
Fastlane for Androidによる継続的デリバリー
 
All a flutter about Flutter.io
All a flutter about Flutter.ioAll a flutter about Flutter.io
All a flutter about Flutter.io
 
Jedi knight
Jedi knightJedi knight
Jedi knight
 
Librerías Opensoure de Square
Librerías Opensoure de Square Librerías Opensoure de Square
Librerías Opensoure de Square
 
Spring-batch Groovy y Gradle
Spring-batch Groovy y GradleSpring-batch Groovy y Gradle
Spring-batch Groovy y Gradle
 
RESTful API Development using Go
RESTful API Development using GoRESTful API Development using Go
RESTful API Development using Go
 
Getting started with Go - Florin Patan - Codemotion Rome 2017
Getting started with Go - Florin Patan - Codemotion Rome 2017Getting started with Go - Florin Patan - Codemotion Rome 2017
Getting started with Go - Florin Patan - Codemotion Rome 2017
 
Development of Mobile Applications
Development of Mobile ApplicationsDevelopment of Mobile Applications
Development of Mobile Applications
 
Coding with golang
Coding with golangCoding with golang
Coding with golang
 
ChromeとAndroidの過去・現在・未来
ChromeとAndroidの過去・現在・未来ChromeとAndroidの過去・現在・未来
ChromeとAndroidの過去・現在・未来
 
Intro to Flutter
Intro to FlutterIntro to Flutter
Intro to Flutter
 
Google I/O 2018 Extended, Baghdad - Flutter
Google I/O 2018 Extended, Baghdad  - FlutterGoogle I/O 2018 Extended, Baghdad  - Flutter
Google I/O 2018 Extended, Baghdad - Flutter
 
Intro. to Git and Github
Intro. to Git and GithubIntro. to Git and Github
Intro. to Git and Github
 
Understanding Pseudo-Versions Moving to Go 1.13 What is in Go 1.14+ for Modules
Understanding Pseudo-Versions Moving to Go 1.13 What is in Go 1.14+ for ModulesUnderstanding Pseudo-Versions Moving to Go 1.13 What is in Go 1.14+ for Modules
Understanding Pseudo-Versions Moving to Go 1.13 What is in Go 1.14+ for Modules
 
Cross-Platform App Development with Flutter, Xamarin, React Native
Cross-Platform App Development with Flutter, Xamarin, React NativeCross-Platform App Development with Flutter, Xamarin, React Native
Cross-Platform App Development with Flutter, Xamarin, React Native
 
Go lang
Go langGo lang
Go lang
 
Introduction to go
Introduction to goIntroduction to go
Introduction to go
 

Viewers also liked

A microservice architecture based on golang
A microservice architecture based on golangA microservice architecture based on golang
A microservice architecture based on golangGianfranco Reppucci
 
Build REST APIs like a Jedi with Symfony2
Build REST APIs like a Jedi with Symfony2Build REST APIs like a Jedi with Symfony2
Build REST APIs like a Jedi with Symfony2Almog Baku
 
Symfony2 form type
Symfony2 form typeSymfony2 form type
Symfony2 form typeAlmog Baku
 
Drupal & javascript
Drupal & javascriptDrupal & javascript
Drupal & javascriptAlmog Baku
 
Go goes Mobile: Quick Exploration on Go 1.5 and Gomobile
Go goes Mobile: Quick Exploration on Go 1.5 and GomobileGo goes Mobile: Quick Exploration on Go 1.5 and Gomobile
Go goes Mobile: Quick Exploration on Go 1.5 and GomobileTakahiro Yoshimura
 
Golang Performance : microbenchmarks, profilers, and a war story
Golang Performance : microbenchmarks, profilers, and a war storyGolang Performance : microbenchmarks, profilers, and a war story
Golang Performance : microbenchmarks, profilers, and a war storyAerospike
 
Docker-hanoi meetup #1: introduction about Docker
Docker-hanoi meetup #1: introduction about DockerDocker-hanoi meetup #1: introduction about Docker
Docker-hanoi meetup #1: introduction about DockerNguyen Anh Tu
 
Go debugging and troubleshooting tips - from real life lessons at SignalFx
Go debugging and troubleshooting tips - from real life lessons at SignalFxGo debugging and troubleshooting tips - from real life lessons at SignalFx
Go debugging and troubleshooting tips - from real life lessons at SignalFxSignalFx
 
Redis to the Rescue?
Redis to the Rescue?Redis to the Rescue?
Redis to the Rescue?Wooga
 
Continuous Integration using Docker & Jenkins
Continuous Integration using Docker & JenkinsContinuous Integration using Docker & Jenkins
Continuous Integration using Docker & JenkinsB1 Systems GmbH
 
Redis in Practice
Redis in PracticeRedis in Practice
Redis in PracticeNoah Davis
 
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golangBo-Yi Wu
 
Go Profiling - John Graham-Cumming
Go Profiling - John Graham-Cumming Go Profiling - John Graham-Cumming
Go Profiling - John Graham-Cumming Cloudflare
 
Social Media Platforms, Insights & Data - Engage Bali 2016 by Jan Rezab
Social Media Platforms, Insights & Data - Engage Bali 2016 by Jan RezabSocial Media Platforms, Insights & Data - Engage Bali 2016 by Jan Rezab
Social Media Platforms, Insights & Data - Engage Bali 2016 by Jan RezabJan Rezab
 
Docker Tips And Tricks at the Docker Beijing Meetup
Docker Tips And Tricks at the Docker Beijing MeetupDocker Tips And Tricks at the Docker Beijing Meetup
Docker Tips And Tricks at the Docker Beijing MeetupJérôme Petazzoni
 
Proposal format
Proposal formatProposal format
Proposal formatMr SMAK
 
The Future of Everything
The Future of EverythingThe Future of Everything
The Future of EverythingCharbel Zeaiter
 

Viewers also liked (20)

Functional go
Functional goFunctional go
Functional go
 
A microservice architecture based on golang
A microservice architecture based on golangA microservice architecture based on golang
A microservice architecture based on golang
 
Build REST APIs like a Jedi with Symfony2
Build REST APIs like a Jedi with Symfony2Build REST APIs like a Jedi with Symfony2
Build REST APIs like a Jedi with Symfony2
 
Symfony2 form type
Symfony2 form typeSymfony2 form type
Symfony2 form type
 
Drupal & javascript
Drupal & javascriptDrupal & javascript
Drupal & javascript
 
Go goes Mobile: Quick Exploration on Go 1.5 and Gomobile
Go goes Mobile: Quick Exploration on Go 1.5 and GomobileGo goes Mobile: Quick Exploration on Go 1.5 and Gomobile
Go goes Mobile: Quick Exploration on Go 1.5 and Gomobile
 
Golang Performance : microbenchmarks, profilers, and a war story
Golang Performance : microbenchmarks, profilers, and a war storyGolang Performance : microbenchmarks, profilers, and a war story
Golang Performance : microbenchmarks, profilers, and a war story
 
Introduction to Go-Lang
Introduction to Go-LangIntroduction to Go-Lang
Introduction to Go-Lang
 
Docker-hanoi meetup #1: introduction about Docker
Docker-hanoi meetup #1: introduction about DockerDocker-hanoi meetup #1: introduction about Docker
Docker-hanoi meetup #1: introduction about Docker
 
Go debugging and troubleshooting tips - from real life lessons at SignalFx
Go debugging and troubleshooting tips - from real life lessons at SignalFxGo debugging and troubleshooting tips - from real life lessons at SignalFx
Go debugging and troubleshooting tips - from real life lessons at SignalFx
 
Redis to the Rescue?
Redis to the Rescue?Redis to the Rescue?
Redis to the Rescue?
 
Continuous Integration using Docker & Jenkins
Continuous Integration using Docker & JenkinsContinuous Integration using Docker & Jenkins
Continuous Integration using Docker & Jenkins
 
Redis in Practice
Redis in PracticeRedis in Practice
Redis in Practice
 
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golang
 
Go Profiling - John Graham-Cumming
Go Profiling - John Graham-Cumming Go Profiling - John Graham-Cumming
Go Profiling - John Graham-Cumming
 
Social Media Platforms, Insights & Data - Engage Bali 2016 by Jan Rezab
Social Media Platforms, Insights & Data - Engage Bali 2016 by Jan RezabSocial Media Platforms, Insights & Data - Engage Bali 2016 by Jan Rezab
Social Media Platforms, Insights & Data - Engage Bali 2016 by Jan Rezab
 
Docker Tips And Tricks at the Docker Beijing Meetup
Docker Tips And Tricks at the Docker Beijing MeetupDocker Tips And Tricks at the Docker Beijing Meetup
Docker Tips And Tricks at the Docker Beijing Meetup
 
Proposal format
Proposal formatProposal format
Proposal format
 
The Future of Everything
The Future of EverythingThe Future of Everything
The Future of Everything
 
Build Features, Not Apps
Build Features, Not AppsBuild Features, Not Apps
Build Features, Not Apps
 

Similar to Android is going to Go! Android and Golang

The Ring programming language version 1.5.1 book - Part 4 of 180
The Ring programming language version 1.5.1 book - Part 4 of 180The Ring programming language version 1.5.1 book - Part 4 of 180
The Ring programming language version 1.5.1 book - Part 4 of 180Mahmoud Samir Fayed
 
Introduction to go lang
Introduction to go langIntroduction to go lang
Introduction to go langAmal Mohan N
 
When, how &amp; why use golang in 2021 go benefits &amp; use cases
When, how &amp; why use golang in 2021  go benefits &amp; use casesWhen, how &amp; why use golang in 2021  go benefits &amp; use cases
When, how &amp; why use golang in 2021 go benefits &amp; use casesKaty Slemon
 
welcome to gopherlabs - why go (golang)?
welcome to gopherlabs - why go (golang)?welcome to gopherlabs - why go (golang)?
welcome to gopherlabs - why go (golang)?sangam biradar
 
Android Jumpstart ESC SV 2012 Part I
Android Jumpstart ESC SV 2012 Part IAndroid Jumpstart ESC SV 2012 Part I
Android Jumpstart ESC SV 2012 Part IOpersys inc.
 
What's New in Hybrid App Development
What's New in Hybrid App DevelopmentWhat's New in Hybrid App Development
What's New in Hybrid App DevelopmentJay Graves
 
Scaling applications with go
Scaling applications with goScaling applications with go
Scaling applications with goVimlesh Sharma
 
Embedded Android Workshop at ELC Europe
Embedded Android Workshop at ELC EuropeEmbedded Android Workshop at ELC Europe
Embedded Android Workshop at ELC EuropeOpersys inc.
 
Embedded Android Workshop / ELC 2013
Embedded Android Workshop / ELC 2013Embedded Android Workshop / ELC 2013
Embedded Android Workshop / ELC 2013Opersys inc.
 
Golang (Go Programming Language)
Golang (Go Programming Language)Golang (Go Programming Language)
Golang (Go Programming Language)ShubhamMishra485
 
Embedded Android Workshop at Embedded World Conference 2013
Embedded Android Workshop at Embedded World Conference 2013Embedded Android Workshop at Embedded World Conference 2013
Embedded Android Workshop at Embedded World Conference 2013Opersys inc.
 
Hire golang developers and make the shift to brighter business future (build ...
Hire golang developers and make the shift to brighter business future (build ...Hire golang developers and make the shift to brighter business future (build ...
Hire golang developers and make the shift to brighter business future (build ...Katy Slemon
 
5 Reasons why Business Choose Go Program for Software Development
5 Reasons why Business Choose Go Program for Software Development5 Reasons why Business Choose Go Program for Software Development
5 Reasons why Business Choose Go Program for Software DevelopmentNelsonSEO
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageAniruddha Chakrabarti
 
Introduction to Go
Introduction to GoIntroduction to Go
Introduction to GoSimon Hewitt
 
Embedded Android Workshop with Nougat
Embedded Android Workshop with NougatEmbedded Android Workshop with Nougat
Embedded Android Workshop with NougatOpersys inc.
 
Gomobile: gophers in the land of Android
Gomobile: gophers in the land of AndroidGomobile: gophers in the land of Android
Gomobile: gophers in the land of AndroidJovica Popovic
 
Embedded Android Workshop
Embedded Android WorkshopEmbedded Android Workshop
Embedded Android WorkshopOpersys inc.
 
Adobe phonegap-workshop-2013
Adobe phonegap-workshop-2013Adobe phonegap-workshop-2013
Adobe phonegap-workshop-2013Haig Armen
 

Similar to Android is going to Go! Android and Golang (20)

The Ring programming language version 1.5.1 book - Part 4 of 180
The Ring programming language version 1.5.1 book - Part 4 of 180The Ring programming language version 1.5.1 book - Part 4 of 180
The Ring programming language version 1.5.1 book - Part 4 of 180
 
Introduction to go lang
Introduction to go langIntroduction to go lang
Introduction to go lang
 
When, how &amp; why use golang in 2021 go benefits &amp; use cases
When, how &amp; why use golang in 2021  go benefits &amp; use casesWhen, how &amp; why use golang in 2021  go benefits &amp; use cases
When, how &amp; why use golang in 2021 go benefits &amp; use cases
 
welcome to gopherlabs - why go (golang)?
welcome to gopherlabs - why go (golang)?welcome to gopherlabs - why go (golang)?
welcome to gopherlabs - why go (golang)?
 
Android Jumpstart ESC SV 2012 Part I
Android Jumpstart ESC SV 2012 Part IAndroid Jumpstart ESC SV 2012 Part I
Android Jumpstart ESC SV 2012 Part I
 
What's New in Hybrid App Development
What's New in Hybrid App DevelopmentWhat's New in Hybrid App Development
What's New in Hybrid App Development
 
Scaling applications with go
Scaling applications with goScaling applications with go
Scaling applications with go
 
Embedded Android Workshop at ELC Europe
Embedded Android Workshop at ELC EuropeEmbedded Android Workshop at ELC Europe
Embedded Android Workshop at ELC Europe
 
Embedded Android Workshop / ELC 2013
Embedded Android Workshop / ELC 2013Embedded Android Workshop / ELC 2013
Embedded Android Workshop / ELC 2013
 
Golang (Go Programming Language)
Golang (Go Programming Language)Golang (Go Programming Language)
Golang (Go Programming Language)
 
Embedded Android Workshop at Embedded World Conference 2013
Embedded Android Workshop at Embedded World Conference 2013Embedded Android Workshop at Embedded World Conference 2013
Embedded Android Workshop at Embedded World Conference 2013
 
Hire golang developers and make the shift to brighter business future (build ...
Hire golang developers and make the shift to brighter business future (build ...Hire golang developers and make the shift to brighter business future (build ...
Hire golang developers and make the shift to brighter business future (build ...
 
Features of go
Features of goFeatures of go
Features of go
 
5 Reasons why Business Choose Go Program for Software Development
5 Reasons why Business Choose Go Program for Software Development5 Reasons why Business Choose Go Program for Software Development
5 Reasons why Business Choose Go Program for Software Development
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) Language
 
Introduction to Go
Introduction to GoIntroduction to Go
Introduction to Go
 
Embedded Android Workshop with Nougat
Embedded Android Workshop with NougatEmbedded Android Workshop with Nougat
Embedded Android Workshop with Nougat
 
Gomobile: gophers in the land of Android
Gomobile: gophers in the land of AndroidGomobile: gophers in the land of Android
Gomobile: gophers in the land of Android
 
Embedded Android Workshop
Embedded Android WorkshopEmbedded Android Workshop
Embedded Android Workshop
 
Adobe phonegap-workshop-2013
Adobe phonegap-workshop-2013Adobe phonegap-workshop-2013
Adobe phonegap-workshop-2013
 

Recently uploaded

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 

Recently uploaded (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 

Android is going to Go! Android and Golang

  • 1. Android is going to Go! Android and golang
  • 2. Who are you? @AlmogBaku on github 1. A serial entrepreneur 2. Co-Founder & CTO @ Rimoto 3. Developer for 12 years 4. GitHub addicted. 5. Blog about entrepreneurship and development: www.AlmogBaku.com
  • 3. What is Rimoto? Rimoto enable apps to sponsor their user’s mobile-data, and to became accessible for international travellers, regardless their data-plan, boosting their engagement.
  • 4. What are we going to talk about? 1. What is Go? 2. How can we use Go with Android? 3. When is it useful?
  • 5. Disclaimer You wanna know more? Google it! Google tip: use the keyword “golang”
  • 7. Why use Go, and what is it?! • New modern language (since 2009) • Super fast (native) compiling • Concurrent • Performant • Garbage collected • Standard libraries
  • 8. Hello world package main import "fmt" func main() { fmt.Println("Hello DroidCon!") } RUN
  • 9. Goroutines func boring() { for i := 0; i < 10; i++ { sayIt(i) } } func sayIt(i int) { time.Sleep(time.Duration(rand.Intn(1e3)) * time.Millisecond) fmt.Println("I'm saying ", i) } RUN
  • 10. Goroutines func not_boring() { for i := 0; i < 10; i++ { go sayIt(i) } time.Sleep(2 * time.Second) } func sayIt(i int) { time.Sleep(time.Duration(rand.Intn(1e3)) * time.Millisecond) fmt.Println("I'm saying ", i) } RUN
  • 11. Goroutines syncing / WaitGroup func not_boring_at_all() { wg := sync.WaitGroup{} wg.Add(10) for i := 0; i < 10; i++ { go sayIt(i, &wg) } wg.Wait() } func sayIt(i int, wg *sync.WaitGroup) { defer wg.Done() time.Sleep(time.Duration(rand.Intn(1e3)) * time.Millisecond) fmt.Println("I'm saying ", i) } RUN
  • 12. Goroutines communications / Channels package main import "fmt" func main() { c := make(chan string) for i := 0; i < 5; i++ { go func() { c <- "ping" }() } for i := 0; i < 5; i++ { go func() { c <- "pong" }() } for i := 0; i < 10; i++ { fmt.Println(<-c) } } RUN
  • 13. Standard libraries package main import ( "fmt" "net/http" ) func handler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hi there!") } func main() { http.HandleFunc("/", handler) http.ListenAndServe(":8080", nil) }
  • 14. Go Mobile A tool for using Golang for native mobile apps easily!
  • 15. Caution The Go Mobile project is experimental. Use this at your own risk.
  • 16. Why? 1. Full-stack development 2. Write a single cross-platform Go library 3. Bring a simple and modern language and development tooling to mobile 4. Enjoy Go benefits of native, faster, and much more concurrent code
  • 17. How? Native Apps ● Write the whole app in Go (with OpenGL) ● Use Go packages for graphics, event handling, audio, etc. ● When Native App UI is not required (i.e. games) SDK Apps ● Write common functionality in Go, as a library
  • 18. Native Go Apps • 100% Go app • Multi platform: Android, iOS and Desktop • GUI with OpenGL
  • 20. Gomobile A tool that automate this process – Toolchain installation – Creating NativeActivity – Attach the Go runtime to the app – Bind the App binary to the app – Multi Architecture build – Cross platform(Android/iOS) build $ gomobile build golang.org/x/mobile/example/basic $ gomobile install golang.org/x/mobile/example/basic
  • 21. DEMO
  • 22. SDKs • Build the app natively with Java/Swift/Obj. C • Write a simple regular Go library • Reuse libraries across platforms and projects Common library iOS Android Backend service A Backend service B 3rd party
  • 24. Behind the scenes package mypkg func Hello() (string, error) { return "Gopher", nil } public abstract class Mypkg { public static String hello() throws Exception { ... } } Go Library: Java API:
  • 25. Gomobile A tool that automate this process – Multi Architecture build – Build as shared library – Automatically generate the binding for Java/Swift/Obj. C – Bundle everything to an .aar – Cross platform(Android/iOS) build $ gomobile bind -target=android golang.org/x/mobile/example/bind/hello
  • 26. DEMO
  • 27. Disadvantages Nothing is perfect.. • .aar includes all architecture binaries (increase size) • go binaries are currently statically linked • Go as a native app is lack of many sensors and integrations with the Android/iOS APIs • The communication between the Platform and the go binary is not free