SlideShare una empresa de Scribd logo
1 de 48
Go & multi platform GUI
Trials and Errors
Go Conference 2016 sprint @ 4/23/2016
@shibukawa (Twitter)
github.com/shibukawa
Yoshiki Shibukawa
Who Are You?
• Programmer in Mobile Game Department
– http://www.slideshare.net/dena_study/final-
fantasy-record-keeper
Yoshiki Shibukawa
 Languages
 C++/JavaScript/Python/Golang etc
 Japanese/English/Español (studying with Duolingo)
 Books
 Translations: Expert Python/Pomodoro Technique/The Art of community
 Original: Mithril, つまみぐい勉強 etc
Before talking my presentation…
• Machine readable docs for web service API
Before talking my presentation…
• Machine readable docs for web service API
YES!
• https://shibukawa.github.io/curl_as_dsl/
• I will add net/http, fasthttp server code generate in future
• Welcome Ruby/Perl/emacs lisp pull request
Conclusion
• This presentation doesn’t show the best
solution for multi platform GUI
• I am exploring possibility about Go and GUI
and creating experimental codes.
• GUI programming is not easy
• C++ is required
Solutions I tried
Pros Cons
Toolkit Wrapper The most intuitive solution Maintaining wrappers is
extremely hard job
Can’t use deploy support
tool
Create new Toolkit in Go Perfect matching with
golang
Supporting multi platform
is very tough
Hybrid
(C++ for GUI, Go for logic)
Solution 1
Toolkit Wrapper
Toolkit Wrapper
• I used wxPython, Qt for JavaScript etc…
• The most intuitive solution
– You can use it in same methodology with original
native language
I tried go-qml
http://qiita.com/shibukawa/items/47cb0ea60bf4a7259b5e
Toolkit Wrapper Cons (1)
• Qt provides deployment helper tool
– macdeployqt, windeployqt etc
– They collects required .dll/.framework and rewrite
dependency paths and create installer etc
– This tool works only for Pre build Qt/C++ project
• Few documents/examples
– We reinterpret original toolkit documents
– C++ knowledge is required
• Debug is very hard
– Where does this panic come from?
Toolkit Wrapper Cons (2)
• Maintaining toolkit wrapper is hard work
– GUI toolkit is contains many C++ classes
• Qt has more than 1200 classes
– Many wrappers were discarded
• QtJS, QtJambi, ruby qtbindings, go-qml etc…
– GUI toolkits update continuously
• Basically newer version is better
• Almost all toolkit gave up updating
• I have to update wrapper by myself to use newer future
– Languages update too
Expect
Hours
Create My Application
Maintaining Toolkit
Actually
Hours
Create My Application
Maintaining Toolkit
Not all GUI toolkit wrappers are bad
PyQt Commercial (Qt 5.5 supports)
wxPython Nightly build still supports latest Python(2.7/3.5)
GTK# Xamarin supports?
pygobject or some libs gobject introspection is good for keeping fresh
Swing from Jython/JRuby Using toolkit directly
tkinter / Qt Quick Official wrapper provided by suppliers
• Some wrappers provide updates continuously
• Maintaining is too heavy for individual developer
• Community/Organizational support is required
Solution 2
Create New Toolkit in Go
Implement GUI toolkit in Go
• There are many small GUI toolkits in C/C++
– http://qiita.com/shimacpyon/items/e5d2a4e2019273345c37
• Port one of them to Go!
– NanoGUI seems good to port
※ When start porting, I didn’t the existence of Shiny
GUI toolkit on GL building blocks
Font Loader Font Renderer
Texture
Management
Font Texture
Management
Event Handling
Vector GraphicsImage Loader
Widget Drawing
OpenGLOS Window System
Widget
Management
NanoGUI toolkit on GL building blocks
Font Loader Font Renderer
Texture
Management
Font Texture
Management
Event Handling
Vector GraphicsImage Loader
Widget Drawing
OpenGLOS Window System
Widget
Management
stb_truetype.h
stb_image.h
NanoVG
GLFW
NanoGUI
fontstash
My toolkit on GL building blocks
Font Loader Font Renderer
Texture
Management
Font Texture
Management
Event Handling
Vector GraphicsImage Loader
Widget Drawing
OpenGLOS Window System
Widget
Management
go’s image
NanoVGo
goxjs/glfw
goxjs/gl
NanoGUI.go
nanovgo
nanogui-go
Input Method Editor issue
• IME support is needed to input Asian chars
• Now IME becomes more generic than before
– Voice / pen input uses same infrastructure
– Modern OS treats IMEs as keyboards
• This is processed in GLFW (C++ layer)
Japanese IME
English
Speech Input
Handwriting Input
Operating
System
Application
※On Windows, Handwriting features seem to be a part of MS IMEs
IME support levels
• Level 1: Root window mode
• Level 2: Over the spot
Images from http://www.mozilla-japan.org/projects/intl/input-method-spec.html
※This is not common classify. My original.
• Level 3: On the spot
• Level 4: Context aware conversion
Image from http://nyaruru.hatenablog.com/entry/20070309/p1
IME tasks viewed from Application
Level 1 Level 2 Level 3 Level 4
Receive multi byte input ✔ ✔ ✔ ✔
Send cursor position ✔ ✔ ✔
React to preedit text ✔ ✔
Send surrounding text
around cursor
✔
• To achieve higher level IME support, applications
should communicate with IME more
• Each OS provides each API for IME. I should add
new method to GLFW to absorb OS layers
Achievement Unlocked!
Current Status
• Windows
– Level 3. Now I use IMM32(old), but Text Services
Framework (TSF) is preferred.
– Old Chrome and Firefox use TSF (but MPL is not
good for GLFW)
• MacOS X
– Level 3. Applications should implement
NSTextInputClient protocol. I don’t implement
Level 4 feature yet.
https://github.com/glfw/glfw/pull/658
Current Status
• X11
– Level 3. XIM protocol doesn’t support level 4.
– On Linux/BSDs, there many input method frameworks
(UIM, SCIM, ibus, fcitx etc) and Qt/GTK communicate
with them directly, but don’t use them (not to
introduce new dependency to GLFW)
• Wayland
– Not yet
• Mir
– Not yet
https://github.com/glfw/glfw/pull/658
Future Plan
• Improve GLFW more to support level 4 and
Wayland, Mir
• Reconstruct NanoVGo
– Cache geometry
– Now it redraw from scratch on every frame
• Reconstruct NanoGUI.go
– ListView support like QAbstractItemView /
QAbstractItemModel
– Better image resource handling
Solution 3
Hybrid Style
Hybrid Model
Thin GUI Logic
C++ is not so fear than before
• Use Qt via C++ directly
– No wrapper issues
– Using C++ is not tough anymore
– C++11 is much better than 20 years ago
– Qt5 supports C++11 (C++11 is required from 5.7)
• But building code in Golang is still faster than
C++ for me
C++ support tool
• Go is easy to build. C++ is boring
• I made helper tool to make C++ easy
– https://github.com/qtpm/qtpm
• Generate CMakeLists.txt. Support following IDEs:
– Qt Creator
– CLion (thank you for Jetbrains OSS support program)
• It support the following commands like go:
– qtpm get
– qtpm build
– qtpm vet
– qtpm fmt
How to communicate?
Thin GUI Logic
???
• I am trying several solutions for communication
Qt’s thread model
• You should understand it if use Go with Qt
• http://doc.qt.io/qt-5/threads-qobject.html
• All Qt’s objects are belonging to thread
– Calling object’s method from non-owner thread
causes panic
– To call other thread’s method,
QMetaObject::invokeMethod is needed
(signal/slot uses this behind it)
– Each thread has event loop
– Of course, blocking main thread is not preferred
3.1: QProcess
• Create standalone CUI program in Golang and
call via QProcess class
– If the job is simple, it is the best (it becomes
simple code)
• Bi-directional communication is tough
– Receiving message in SLOT (callback)
– No fluent code
3.2: QLocalServer/QLocalSocket
• Qt provides special wrapper to provides high
performance inter process communication
– On Windows, it uses named pipe
– On other environment, it uses UNIX domain socket
• Go implementation is ready
– I tested on Windows and Mac
• How to manage process?
– I need to implement some process supervisor
https://github.com/shibukawa/localsocket
3.3: c-archive
• Creating c-archive and link with Qt application
• Go 1.7 will support it on Windows too
• If the API is simple, it is the best
• All method is called synchronous by default
• If callback from Golang to C++, it is little messy
– Polling is easy, but not beautiful
– Pass function pointer from C++ and call it in Go
• https://gist.github.com/shibukawa/ab516964b0390cb2
34c7c42e5c9bfda1
• How to specify “-mmacosx-version-
min=10.x”?
3.4: dRuby style
• dRuby is a my favorite API in Ruby
• dRuby hooks method call and transfers
method name and parameters via TCP/IP
– Go: https://github.com/shibukawa/tobubus
– C++: https://github.com/qtpm/QtTobubus
DRbObjectClient
hello(“world”)
method_missing()
DRbServer
Actual
Instance
hello(“world”)
tobubus
• Now it works on QLocalSocket/Server
• It uses Qt
reflection(QMetaObject/QMetaMethod) and
Go’s reflect
• Method call is serialized by CBOR
– CBOR is almost RFC version of MessagePacktobubusC++/Go Client
hello(“world”)
Proxy
C++/Go Actual
Instance
hello(“world”)
tobubus
CBOR on local socket
3.5: gRPC
• I didn’t try it
– I don’t want to create extra interface definitions
for communication
• It is suitable for loose coupling of micro services
– It seems difficult to use with Qt threading model
• I may need create wrappers for all interfaces in Qt
Combinations of my solutions
Infrastructur
e
Connect Pros/Cons Simple Teste
d
QProcess stdin/std
out
bi-direction is difficult
Go is always running in other process
(should take care QThread)
S ✔
tobubus Not implemented yet A
QProcess +
QLocalSocket
/Server
tobubus It needs process supervisor
C++ client code is not clean because of
Qt thread model
Go is always running in other process
(should take care QThread)
B ✔
c-archive linker Writing callback is little messy
Windows doesn’t support until 1.7
It works synchronously
S ✔
Which is better?
• QProcess is the most simple now
• tobubus + QLocalSocket/Server was originally
designed for generic plug-in system. I already
implemented but I feel too heavy now.
• c-archive is a stable way. It is not bad if you
can wait by 1.7 release.
Conclusion
• This presentation doesn’t show the best
solution for multi platform GUI
• I am exploring possibility about Go and GUI
and creating experimental codes.
– I will still improve GLFW IME support to realize
pure Go solution
– If you can wait by Go 1.7, c-archive is better
• GUI programming is not easy
• C++ is required
Actually
Hours
Create My Application
Maintaining Toolkit
In future I want to achieve
Hours
Create My Application
Maintaining Toolkit

Más contenido relacionado

La actualidad más candente

Subversion @ JUG Milano 11 dic 2009
Subversion @ JUG Milano 11 dic 2009Subversion @ JUG Milano 11 dic 2009
Subversion @ JUG Milano 11 dic 2009
Andrea Francia
 

La actualidad más candente (20)

The State of Puppet - Dan Bode
The State of Puppet - Dan BodeThe State of Puppet - Dan Bode
The State of Puppet - Dan Bode
 
Python for IoT, A return of experience
Python for IoT, A return of experiencePython for IoT, A return of experience
Python for IoT, A return of experience
 
Puppet at DemonWare - Ruaidhri Power - Puppetcamp Dublin '12
Puppet at DemonWare - Ruaidhri Power - Puppetcamp Dublin '12Puppet at DemonWare - Ruaidhri Power - Puppetcamp Dublin '12
Puppet at DemonWare - Ruaidhri Power - Puppetcamp Dublin '12
 
PyParis 2017 / Writing a C Python extension in 2017, Jean-Baptiste Aviat
PyParis 2017 / Writing a C Python extension in 2017, Jean-Baptiste Aviat PyParis 2017 / Writing a C Python extension in 2017, Jean-Baptiste Aviat
PyParis 2017 / Writing a C Python extension in 2017, Jean-Baptiste Aviat
 
Deploying 3 times a day without a downtime @ Rocket Tech Summit in Berlin
Deploying 3 times a day without a downtime @ Rocket Tech Summit in BerlinDeploying 3 times a day without a downtime @ Rocket Tech Summit in Berlin
Deploying 3 times a day without a downtime @ Rocket Tech Summit in Berlin
 
PuppetCamp SEA 1 - The State of Puppet
PuppetCamp SEA 1 - The State of PuppetPuppetCamp SEA 1 - The State of Puppet
PuppetCamp SEA 1 - The State of Puppet
 
Puppeteerのお話
Puppeteerのお話Puppeteerのお話
Puppeteerのお話
 
Developer-friendly taskqueues: What you should ask yourself before choosing one
Developer-friendly taskqueues: What you should ask yourself before choosing oneDeveloper-friendly taskqueues: What you should ask yourself before choosing one
Developer-friendly taskqueues: What you should ask yourself before choosing one
 
Dev to Delivery with Puppet, Vagrant and AWS
Dev to Delivery with Puppet, Vagrant and AWSDev to Delivery with Puppet, Vagrant and AWS
Dev to Delivery with Puppet, Vagrant and AWS
 
Pragmatic Monolith-First, easy to decompose, clean architecture
Pragmatic Monolith-First, easy to decompose, clean architecturePragmatic Monolith-First, easy to decompose, clean architecture
Pragmatic Monolith-First, easy to decompose, clean architecture
 
Introduction to dockerfile, SF Peninsula Software Development Meetup @Guidewire
Introduction to dockerfile, SF Peninsula Software Development Meetup @Guidewire Introduction to dockerfile, SF Peninsula Software Development Meetup @Guidewire
Introduction to dockerfile, SF Peninsula Software Development Meetup @Guidewire
 
Git and Github workshop
Git and Github workshopGit and Github workshop
Git and Github workshop
 
State of the Jenkins Automation
State of the Jenkins AutomationState of the Jenkins Automation
State of the Jenkins Automation
 
[KubeCon NA 2018] Effective Kubernetes Develop: Turbocharge Your Dev Loop - P...
[KubeCon NA 2018] Effective Kubernetes Develop: Turbocharge Your Dev Loop - P...[KubeCon NA 2018] Effective Kubernetes Develop: Turbocharge Your Dev Loop - P...
[KubeCon NA 2018] Effective Kubernetes Develop: Turbocharge Your Dev Loop - P...
 
Open shift intro for Philly PUG
Open shift intro for Philly PUGOpen shift intro for Philly PUG
Open shift intro for Philly PUG
 
Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL
 
Subversion @ JUG Milano 11 dic 2009
Subversion @ JUG Milano 11 dic 2009Subversion @ JUG Milano 11 dic 2009
Subversion @ JUG Milano 11 dic 2009
 
Deploy Node.js application in Heroku using Eclipse
Deploy Node.js application in Heroku using EclipseDeploy Node.js application in Heroku using Eclipse
Deploy Node.js application in Heroku using Eclipse
 
Docker Workshop Birthday #3
Docker Workshop Birthday #3Docker Workshop Birthday #3
Docker Workshop Birthday #3
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
 

Destacado

Advanced file permissions in linux
Advanced file permissions in linuxAdvanced file permissions in linux
Advanced file permissions in linux
Mohit Singh
 
GopherJS + Nashorn
GopherJS + NashornGopherJS + Nashorn
GopherJS + Nashorn
Takuya Ueda
 
GUI_using_QT_Designer_PyQT4
GUI_using_QT_Designer_PyQT4GUI_using_QT_Designer_PyQT4
GUI_using_QT_Designer_PyQT4
zenonas
 
Qt Development Tools
Qt Development ToolsQt Development Tools
Qt Development Tools
William Lee
 
Python Programming - XIII. GUI Programming
Python Programming - XIII. GUI ProgrammingPython Programming - XIII. GUI Programming
Python Programming - XIII. GUI Programming
Ranel Padon
 

Destacado (20)

Mithril
MithrilMithril
Mithril
 
My client wanted their apps synced, and I made it with Go
My client wanted their apps synced, and I made it with GoMy client wanted their apps synced, and I made it with Go
My client wanted their apps synced, and I made it with Go
 
Go conference 2017 Lightning talk
Go conference 2017 Lightning talkGo conference 2017 Lightning talk
Go conference 2017 Lightning talk
 
go 1.8 net/http timeouts
go 1.8 net/http timeoutsgo 1.8 net/http timeouts
go 1.8 net/http timeouts
 
Coding in the context era
Coding in the context eraCoding in the context era
Coding in the context era
 
Goをカンストさせる話
Goをカンストさせる話Goをカンストさせる話
Goをカンストさせる話
 
Goでヤフーの分散オブジェクトストレージを作った話 Go Conference 2017 Spring
Goでヤフーの分散オブジェクトストレージを作った話 Go Conference 2017 SpringGoでヤフーの分散オブジェクトストレージを作った話 Go Conference 2017 Spring
Goでヤフーの分散オブジェクトストレージを作った話 Go Conference 2017 Spring
 
条件式評価器の実装による管理ツールの抽象化
条件式評価器の実装による管理ツールの抽象化条件式評価器の実装による管理ツールの抽象化
条件式評価器の実装による管理ツールの抽象化
 
How to Build Your First Web App in Go
How to Build Your First Web App in GoHow to Build Your First Web App in Go
How to Build Your First Web App in Go
 
Advanced file permissions in linux
Advanced file permissions in linuxAdvanced file permissions in linux
Advanced file permissions in linux
 
[C++ GUI Programming with Qt4] chap6
[C++ GUI Programming with Qt4] chap6[C++ GUI Programming with Qt4] chap6
[C++ GUI Programming with Qt4] chap6
 
Intro to gui, cross platform and qt
Intro to gui, cross platform and qtIntro to gui, cross platform and qt
Intro to gui, cross platform and qt
 
GopherJS + Nashorn
GopherJS + NashornGopherJS + Nashorn
GopherJS + Nashorn
 
GUI_using_QT_Designer_PyQT4
GUI_using_QT_Designer_PyQT4GUI_using_QT_Designer_PyQT4
GUI_using_QT_Designer_PyQT4
 
Qt Development Tools
Qt Development ToolsQt Development Tools
Qt Development Tools
 
20170131 python3 6 PEP526
20170131 python3 6 PEP526 20170131 python3 6 PEP526
20170131 python3 6 PEP526
 
Introduction to Qt programming
Introduction to Qt programmingIntroduction to Qt programming
Introduction to Qt programming
 
Python3 移行への軌跡
Python3 移行への軌跡Python3 移行への軌跡
Python3 移行への軌跡
 
Python Programming - XIII. GUI Programming
Python Programming - XIII. GUI ProgrammingPython Programming - XIII. GUI Programming
Python Programming - XIII. GUI Programming
 
File permission in linux
File permission in linuxFile permission in linux
File permission in linux
 

Similar a Go & multi platform GUI Trials and Errors

Cooking a rabbit pie
Cooking a rabbit pieCooking a rabbit pie
Cooking a rabbit pie
Tomas Doran
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
goccy
 

Similar a Go & multi platform GUI Trials and Errors (20)

Unikernel User Summit 2015: Getting started in unikernels using the rump kernel
Unikernel User Summit 2015: Getting started in unikernels using the rump kernelUnikernel User Summit 2015: Getting started in unikernels using the rump kernel
Unikernel User Summit 2015: Getting started in unikernels using the rump kernel
 
How I become Go GDE
How I become Go GDEHow I become Go GDE
How I become Go GDE
 
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
 
Steamlining your puppet development workflow
Steamlining your puppet development workflowSteamlining your puppet development workflow
Steamlining your puppet development workflow
 
Go fundamentals
Go fundamentalsGo fundamentals
Go fundamentals
 
Docker and Fluentd
Docker and FluentdDocker and Fluentd
Docker and Fluentd
 
Cooking a rabbit pie
Cooking a rabbit pieCooking a rabbit pie
Cooking a rabbit pie
 
september13.ppt
september13.pptseptember13.ppt
september13.ppt
 
FOSDEM2018 Janus Lua plugin presentation
FOSDEM2018 Janus Lua plugin presentationFOSDEM2018 Janus Lua plugin presentation
FOSDEM2018 Janus Lua plugin presentation
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
 
Mini-Training: TypeScript
Mini-Training: TypeScriptMini-Training: TypeScript
Mini-Training: TypeScript
 
Go at Skroutz
Go at SkroutzGo at Skroutz
Go at Skroutz
 
Besut Kode Challenge 1
Besut Kode Challenge 1Besut Kode Challenge 1
Besut Kode Challenge 1
 
DSA Day 2 PPT.pdf
DSA Day 2 PPT.pdfDSA Day 2 PPT.pdf
DSA Day 2 PPT.pdf
 
How to plan and define your CI-CD pipeline
How to plan and define your CI-CD pipelineHow to plan and define your CI-CD pipeline
How to plan and define your CI-CD pipeline
 
Ruby in office time reboot
Ruby in office time rebootRuby in office time reboot
Ruby in office time reboot
 
Great Tools Heavily Used In Japan, You Don't Know.
Great Tools Heavily Used In Japan, You Don't Know.Great Tools Heavily Used In Japan, You Don't Know.
Great Tools Heavily Used In Japan, You Don't Know.
 
Google App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGoogle App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and Gaelyk
 
The New Frontend Toolchain
The New Frontend ToolchainThe New Frontend Toolchain
The New Frontend Toolchain
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
 

Más de Yoshiki Shibukawa

Oktavia Search Engine - pyconjp2014
Oktavia Search Engine - pyconjp2014Oktavia Search Engine - pyconjp2014
Oktavia Search Engine - pyconjp2014
Yoshiki Shibukawa
 
JavaScriptゲーム制作勉強会
JavaScriptゲーム制作勉強会JavaScriptゲーム制作勉強会
JavaScriptゲーム制作勉強会
Yoshiki Shibukawa
 
ドキュメントを作りたくなってしまう魔法のツール「Sphinx」
ドキュメントを作りたくなってしまう魔法のツール「Sphinx」ドキュメントを作りたくなってしまう魔法のツール「Sphinx」
ドキュメントを作りたくなってしまう魔法のツール「Sphinx」
Yoshiki Shibukawa
 
つまみぐい勉強法。その後。
つまみぐい勉強法。その後。つまみぐい勉強法。その後。
つまみぐい勉強法。その後。
Yoshiki Shibukawa
 

Más de Yoshiki Shibukawa (20)

技術書執筆のススメ 〜Only1なエンジニアになるためのセルフブランディング〜の発表資料
技術書執筆のススメ 〜Only1なエンジニアになるためのセルフブランディング〜の発表資料技術書執筆のススメ 〜Only1なエンジニアになるためのセルフブランディング〜の発表資料
技術書執筆のススメ 〜Only1なエンジニアになるためのセルフブランディング〜の発表資料
 
GO本執筆者が語る、2064年もITで仕事し続けるためのキャリアプランの発表資料
GO本執筆者が語る、2064年もITで仕事し続けるためのキャリアプランの発表資料GO本執筆者が語る、2064年もITで仕事し続けるためのキャリアプランの発表資料
GO本執筆者が語る、2064年もITで仕事し続けるためのキャリアプランの発表資料
 
Golang tokyo #7 qtpm
Golang tokyo #7 qtpmGolang tokyo #7 qtpm
Golang tokyo #7 qtpm
 
Chunked encoding を使った高速化の考察
Chunked encoding を使った高速化の考察Chunked encoding を使った高速化の考察
Chunked encoding を使った高速化の考察
 
Excelの話
Excelの話Excelの話
Excelの話
 
FINAL FANTASY Record Keeperを支えたGolang
FINAL FANTASY Record Keeperを支えたGolangFINAL FANTASY Record Keeperを支えたGolang
FINAL FANTASY Record Keeperを支えたGolang
 
アンラーニング
アンラーニングアンラーニング
アンラーニング
 
東京Node学園 今できる通信高速化にトライしてみた
東京Node学園 今できる通信高速化にトライしてみた東京Node学園 今できる通信高速化にトライしてみた
東京Node学園 今できる通信高速化にトライしてみた
 
Oktavia全文検索エンジン - SphinxCon JP 2014
Oktavia全文検索エンジン - SphinxCon JP 2014Oktavia全文検索エンジン - SphinxCon JP 2014
Oktavia全文検索エンジン - SphinxCon JP 2014
 
Oktavia Search Engine - pyconjp2014
Oktavia Search Engine - pyconjp2014Oktavia Search Engine - pyconjp2014
Oktavia Search Engine - pyconjp2014
 
大規模JavaScript開発
大規模JavaScript開発大規模JavaScript開発
大規模JavaScript開発
 
Xpjug基調lt2011
Xpjug基調lt2011Xpjug基調lt2011
Xpjug基調lt2011
 
Expert JavaScript Programming
Expert JavaScript ProgrammingExpert JavaScript Programming
Expert JavaScript Programming
 
JavaScriptゲーム制作勉強会
JavaScriptゲーム制作勉強会JavaScriptゲーム制作勉強会
JavaScriptゲーム制作勉強会
 
Pomodoro technique
Pomodoro techniquePomodoro technique
Pomodoro technique
 
ドキュメントを作りたくなってしまう魔法のツール「Sphinx」
ドキュメントを作りたくなってしまう魔法のツール「Sphinx」ドキュメントを作りたくなってしまう魔法のツール「Sphinx」
ドキュメントを作りたくなってしまう魔法のツール「Sphinx」
 
Bitbucket&mercurial
Bitbucket&mercurialBitbucket&mercurial
Bitbucket&mercurial
 
つまみぐい勉強法。その後。
つまみぐい勉強法。その後。つまみぐい勉強法。その後。
つまみぐい勉強法。その後。
 
Erlang and I and Sphinx.
Erlang and I and Sphinx.Erlang and I and Sphinx.
Erlang and I and Sphinx.
 
Sphinx Tutorial at BPStudy#30
Sphinx Tutorial at BPStudy#30Sphinx Tutorial at BPStudy#30
Sphinx Tutorial at BPStudy#30
 

Último

Último (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

Go & multi platform GUI Trials and Errors

  • 1. Go & multi platform GUI Trials and Errors Go Conference 2016 sprint @ 4/23/2016 @shibukawa (Twitter) github.com/shibukawa Yoshiki Shibukawa
  • 2. Who Are You? • Programmer in Mobile Game Department – http://www.slideshare.net/dena_study/final- fantasy-record-keeper Yoshiki Shibukawa  Languages  C++/JavaScript/Python/Golang etc  Japanese/English/Español (studying with Duolingo)  Books  Translations: Expert Python/Pomodoro Technique/The Art of community  Original: Mithril, つまみぐい勉強 etc
  • 3. Before talking my presentation… • Machine readable docs for web service API
  • 4. Before talking my presentation… • Machine readable docs for web service API YES!
  • 5. • https://shibukawa.github.io/curl_as_dsl/ • I will add net/http, fasthttp server code generate in future • Welcome Ruby/Perl/emacs lisp pull request
  • 6. Conclusion • This presentation doesn’t show the best solution for multi platform GUI • I am exploring possibility about Go and GUI and creating experimental codes. • GUI programming is not easy • C++ is required
  • 7. Solutions I tried Pros Cons Toolkit Wrapper The most intuitive solution Maintaining wrappers is extremely hard job Can’t use deploy support tool Create new Toolkit in Go Perfect matching with golang Supporting multi platform is very tough Hybrid (C++ for GUI, Go for logic)
  • 9. Toolkit Wrapper • I used wxPython, Qt for JavaScript etc… • The most intuitive solution – You can use it in same methodology with original native language
  • 11. Toolkit Wrapper Cons (1) • Qt provides deployment helper tool – macdeployqt, windeployqt etc – They collects required .dll/.framework and rewrite dependency paths and create installer etc – This tool works only for Pre build Qt/C++ project • Few documents/examples – We reinterpret original toolkit documents – C++ knowledge is required • Debug is very hard – Where does this panic come from?
  • 12. Toolkit Wrapper Cons (2) • Maintaining toolkit wrapper is hard work – GUI toolkit is contains many C++ classes • Qt has more than 1200 classes – Many wrappers were discarded • QtJS, QtJambi, ruby qtbindings, go-qml etc… – GUI toolkits update continuously • Basically newer version is better • Almost all toolkit gave up updating • I have to update wrapper by myself to use newer future – Languages update too
  • 15. Not all GUI toolkit wrappers are bad PyQt Commercial (Qt 5.5 supports) wxPython Nightly build still supports latest Python(2.7/3.5) GTK# Xamarin supports? pygobject or some libs gobject introspection is good for keeping fresh Swing from Jython/JRuby Using toolkit directly tkinter / Qt Quick Official wrapper provided by suppliers • Some wrappers provide updates continuously • Maintaining is too heavy for individual developer • Community/Organizational support is required
  • 16. Solution 2 Create New Toolkit in Go
  • 17. Implement GUI toolkit in Go • There are many small GUI toolkits in C/C++ – http://qiita.com/shimacpyon/items/e5d2a4e2019273345c37 • Port one of them to Go! – NanoGUI seems good to port ※ When start porting, I didn’t the existence of Shiny
  • 18. GUI toolkit on GL building blocks Font Loader Font Renderer Texture Management Font Texture Management Event Handling Vector GraphicsImage Loader Widget Drawing OpenGLOS Window System Widget Management
  • 19. NanoGUI toolkit on GL building blocks Font Loader Font Renderer Texture Management Font Texture Management Event Handling Vector GraphicsImage Loader Widget Drawing OpenGLOS Window System Widget Management stb_truetype.h stb_image.h NanoVG GLFW NanoGUI fontstash
  • 20. My toolkit on GL building blocks Font Loader Font Renderer Texture Management Font Texture Management Event Handling Vector GraphicsImage Loader Widget Drawing OpenGLOS Window System Widget Management go’s image NanoVGo goxjs/glfw goxjs/gl NanoGUI.go
  • 23. Input Method Editor issue • IME support is needed to input Asian chars • Now IME becomes more generic than before – Voice / pen input uses same infrastructure – Modern OS treats IMEs as keyboards • This is processed in GLFW (C++ layer) Japanese IME English Speech Input Handwriting Input Operating System Application ※On Windows, Handwriting features seem to be a part of MS IMEs
  • 24. IME support levels • Level 1: Root window mode • Level 2: Over the spot Images from http://www.mozilla-japan.org/projects/intl/input-method-spec.html ※This is not common classify. My original.
  • 25. • Level 3: On the spot • Level 4: Context aware conversion Image from http://nyaruru.hatenablog.com/entry/20070309/p1
  • 26. IME tasks viewed from Application Level 1 Level 2 Level 3 Level 4 Receive multi byte input ✔ ✔ ✔ ✔ Send cursor position ✔ ✔ ✔ React to preedit text ✔ ✔ Send surrounding text around cursor ✔ • To achieve higher level IME support, applications should communicate with IME more • Each OS provides each API for IME. I should add new method to GLFW to absorb OS layers
  • 28. Current Status • Windows – Level 3. Now I use IMM32(old), but Text Services Framework (TSF) is preferred. – Old Chrome and Firefox use TSF (but MPL is not good for GLFW) • MacOS X – Level 3. Applications should implement NSTextInputClient protocol. I don’t implement Level 4 feature yet. https://github.com/glfw/glfw/pull/658
  • 29. Current Status • X11 – Level 3. XIM protocol doesn’t support level 4. – On Linux/BSDs, there many input method frameworks (UIM, SCIM, ibus, fcitx etc) and Qt/GTK communicate with them directly, but don’t use them (not to introduce new dependency to GLFW) • Wayland – Not yet • Mir – Not yet https://github.com/glfw/glfw/pull/658
  • 30. Future Plan • Improve GLFW more to support level 4 and Wayland, Mir • Reconstruct NanoVGo – Cache geometry – Now it redraw from scratch on every frame • Reconstruct NanoGUI.go – ListView support like QAbstractItemView / QAbstractItemModel – Better image resource handling
  • 33. C++ is not so fear than before • Use Qt via C++ directly – No wrapper issues – Using C++ is not tough anymore – C++11 is much better than 20 years ago – Qt5 supports C++11 (C++11 is required from 5.7) • But building code in Golang is still faster than C++ for me
  • 34. C++ support tool • Go is easy to build. C++ is boring • I made helper tool to make C++ easy – https://github.com/qtpm/qtpm • Generate CMakeLists.txt. Support following IDEs: – Qt Creator – CLion (thank you for Jetbrains OSS support program) • It support the following commands like go: – qtpm get – qtpm build – qtpm vet – qtpm fmt
  • 35. How to communicate? Thin GUI Logic ??? • I am trying several solutions for communication
  • 36. Qt’s thread model • You should understand it if use Go with Qt • http://doc.qt.io/qt-5/threads-qobject.html • All Qt’s objects are belonging to thread – Calling object’s method from non-owner thread causes panic – To call other thread’s method, QMetaObject::invokeMethod is needed (signal/slot uses this behind it) – Each thread has event loop – Of course, blocking main thread is not preferred
  • 37. 3.1: QProcess • Create standalone CUI program in Golang and call via QProcess class – If the job is simple, it is the best (it becomes simple code) • Bi-directional communication is tough – Receiving message in SLOT (callback) – No fluent code
  • 38. 3.2: QLocalServer/QLocalSocket • Qt provides special wrapper to provides high performance inter process communication – On Windows, it uses named pipe – On other environment, it uses UNIX domain socket • Go implementation is ready – I tested on Windows and Mac • How to manage process? – I need to implement some process supervisor https://github.com/shibukawa/localsocket
  • 39. 3.3: c-archive • Creating c-archive and link with Qt application • Go 1.7 will support it on Windows too
  • 40. • If the API is simple, it is the best • All method is called synchronous by default • If callback from Golang to C++, it is little messy – Polling is easy, but not beautiful – Pass function pointer from C++ and call it in Go • https://gist.github.com/shibukawa/ab516964b0390cb2 34c7c42e5c9bfda1 • How to specify “-mmacosx-version- min=10.x”?
  • 41. 3.4: dRuby style • dRuby is a my favorite API in Ruby • dRuby hooks method call and transfers method name and parameters via TCP/IP – Go: https://github.com/shibukawa/tobubus – C++: https://github.com/qtpm/QtTobubus DRbObjectClient hello(“world”) method_missing() DRbServer Actual Instance hello(“world”)
  • 42. tobubus • Now it works on QLocalSocket/Server • It uses Qt reflection(QMetaObject/QMetaMethod) and Go’s reflect • Method call is serialized by CBOR – CBOR is almost RFC version of MessagePacktobubusC++/Go Client hello(“world”) Proxy C++/Go Actual Instance hello(“world”) tobubus CBOR on local socket
  • 43. 3.5: gRPC • I didn’t try it – I don’t want to create extra interface definitions for communication • It is suitable for loose coupling of micro services – It seems difficult to use with Qt threading model • I may need create wrappers for all interfaces in Qt
  • 44. Combinations of my solutions Infrastructur e Connect Pros/Cons Simple Teste d QProcess stdin/std out bi-direction is difficult Go is always running in other process (should take care QThread) S ✔ tobubus Not implemented yet A QProcess + QLocalSocket /Server tobubus It needs process supervisor C++ client code is not clean because of Qt thread model Go is always running in other process (should take care QThread) B ✔ c-archive linker Writing callback is little messy Windows doesn’t support until 1.7 It works synchronously S ✔
  • 45. Which is better? • QProcess is the most simple now • tobubus + QLocalSocket/Server was originally designed for generic plug-in system. I already implemented but I feel too heavy now. • c-archive is a stable way. It is not bad if you can wait by 1.7 release.
  • 46. Conclusion • This presentation doesn’t show the best solution for multi platform GUI • I am exploring possibility about Go and GUI and creating experimental codes. – I will still improve GLFW IME support to realize pure Go solution – If you can wait by Go 1.7, c-archive is better • GUI programming is not easy • C++ is required
  • 48. In future I want to achieve Hours Create My Application Maintaining Toolkit