SlideShare a Scribd company logo
TARDIS: Go for Haxe!
A talk by Elliott Stoneham at WWX2014 on 24th May 2014
Haxe as a compilation target
for other languages
a new use-case
• 50 years ago: watched very first Dr Who episode
• 40 years ago: started programming (punch cards)
• 20 years ago: became a manager
• 10 years ago: stopped programming
• 1 year ago: discovered Go and Haxe…
Go is like the TARDIS
A small idiosyncratic exterior,
conceals large-scale quality engineering.
Haxe is like a sonic screwdriver
An easy to use tool, built on engineering excellence,
that is useful in a wide range of situations.
overview
• Introduction to Go
• TARDIS Go transpiler
• Go —> Haxe issues
• Go/Haxe interaction
• Hopes & dreams
the birth of Go in 2007
“When the three of us got started, it was pure research.
The three of us got together and decided that we hated
C++.
...we started off with the idea that all three of us had to
be talked into every feature in the language, so there
was no extraneous garbage put into the language for
any reason.”
—Ken Thompson (who designed and implemented the
original Unix operating system)
the objectives of Go
• “Readable, safe, and efficient code.
• A build system that scales.
• Good concurrency support.
• Tools that can operate at Google-scale."
— Robert Griesemer (worked on code generation for
Google's V8 JavaScript engine)
–Bruce Eckel, author and
founding member of the ANSI/ISO C++ standard committee
“Now, Go makes much more sense for the
class of problems that C++ was originally
intended to solve.”
burn those C++ manuals!
Go —> Haxe + Haxe / OpenFL
(running on neko target)
Where is Go now?
• Open-source more than 4 years, 2 official compilers
• Google-scale usage: dl.google.com, youtube.com etc.
• Non-Google: docker.com, nsq.io, juju.ubuntu.com etc.
• 800 attendees at first conference last month in Denver
Go vs Haxe
• Github repos: Go >25,600; Haxe > 1,900
• Twitter: Go >11,100; Haxe >1,700
• Google+: Go+ >13,800; Haxe >800
• TIOBE Index for March 2014: Go #36; Haxe not listed
TARDIS Go -> Haxe
transpiler
tardisgo.github.io
TARDIS Go objectives
• Go running on Haxe cross-platform targets
• Go using cross-platform UI APIs like OpenFL
• Show that Haxe is viable as an intermediate language
• Create a viable Go/Haxe programming ecosystem
• Influence the future directions of Haxe and Go
concurrency
Go provides simple concurrency primitives:
• goroutines
• lightweight threads: “go doit(a,b,c)”
• channels
• typed thread-safe communication & synchronisation
• send: “ch <- 3” receive: “x, ok = <-ch”
tardisgo.github.io
• Each of the two sprites is a Go “goroutine"
• The pile of books in the middle is a Go “channel”
The 3 phases of the
TARDIS Go transpiler
Go program to be compiled =>
(1) Use Go library packages to create an intermediate
form that entirely describes the original Go program
=> Single Static Assignment (SSA) form =>
(2) Generate new Haxe code with the same behaviour
=> Haxe =>
(3) Use normal Haxe compilation process
The 36 SSA
(Single
Static
Assignment)
Instructions
Value? Instruction? 	
*Alloc ✔ ✔	
*BinOp ✔ ✔	
*Builtin ✔ ✔	
*Call ✔ ✔	
*ChangeInterface ✔ ✔	
*ChangeType ✔ ✔	
*Convert ✔ ✔	
*DebugRef ✔	
*Defer ✔	
*Extract ✔ ✔	
*Field ✔ ✔	
*FieldAddr ✔ ✔	
*Go ✔	
*If ✔	
*Index ✔ ✔	
*IndexAddr ✔ ✔	
*Jump ✔	
*Lookup ✔ ✔	
*MakeChan ✔ ✔	
*MakeClosure ✔ ✔	
*MakeInterface ✔ ✔	
*MakeMap ✔ ✔	
*MakeSlice ✔ ✔	
*MapUpdate ✔	
*Next ✔ ✔	
*Panic ✔	
*Phi ✔ ✔	
*Range ✔ ✔	
*Return ✔	
*RunDefers ✔	
*Select ✔ ✔	
*Send ✔	
*Slice ✔ ✔	
*Store ✔	
*TypeAssert ✔ ✔	
*UnOp ✔ ✔
go -> ssa
example
# Name: main.fact	
# Package: main	
# Location: glug.go:9:6	
func fact(n int) int:	
.0.entry: P:0 S:2	
	 t0 = n == 0:int bool	
	 if t0 goto 1.if.then else 2.if.done	
.1.if.then: P:1 S:0	
	 return 1:int	
.2.if.done: P:1 S:0	
	 t1 = n - 1:int int	
	 t2 = fact(t1) int	
	 t3 = n * t2 int	
	 return t3	
!
!
func fact(n int) int {
if n == 0 {
return 1
}
return n * fact(n-1)
}
go -> ssa -> haxe
# Name: main.fact	
# Package: main	
# Location: glug.go:9:6	
func fact(n int) int:	
.0.entry:
	 t0 = n == 0:int
	 if t0 goto 1.if.then else 2.if.done	
.1.if.then:
	 return 1:int	
.2.if.done:
	 t1 = n - 1:int
	 t2 = fact(t1)
	 t3 = n * t2
	 return t3	
!
!
func fact(n int) int {
if n == 0 {
return 1
}
return n * fact(n-1)
}
!
public function run():Pogo_main_fact {	
while(true){	
switch(_Next) {	
case 0: // entry	
this.setLatest(9,0);	
this.SubFn0();	
case 1: // if.then	
this.setLatest(9,1);	
_res= 1;	
this._incomplete=false;	
Scheduler.pop(this._goroutine);	
return this; // return 1:int *ssa.Return @ glug.go:11:3	
case 2: // if.done	
this.setLatest(11,2);	
this.SubFn1();	
_SF1=Pogo_main_fact.call(this._goroutine,[],_t1);	
_Next = -1;	
return this;	
case -1:	
this.setLatest(13,-1);	
_t2=_SF1.res();	
// _t2 = fact(t1) *ssa.Call @ glug.go:13:15	
this.SubFn2();	
_res= _t3;	
this._incomplete=false;	
Scheduler.pop(this._goroutine);	
return this; // return t3 *ssa.Return @ glug.go:14:2	
default: throw "Next?";}}}	
private inline function SubFn0():Void {	
var _t0:Bool;	
_t0=(p_n==0); // _t0 = n == 0:int *ssa.BinOp @ glug.go:10:7	
_Next=_t0 ? 1 : 2; // if t0 goto 1.if.then else 2.if.done *ssa.If near glug.go:10:7	
}// end SubFn0	
private inline function SubFn1():Void {	
_t1=(p_n-1); // _t1 = n - 1:int *ssa.BinOp @ glug.go:13:17	
}// end SubFn1	
private inline function SubFn2():Void {	
_t3=(p_n*_t2); // _t3 = n * t2 *ssa.BinOp @ glug.go:13:9	
}// end SubFn2	
!
Go to compile and run all
the Haxe targets in parallel
Go/SSA -> Haxe issues
• Just a proof-of-concept at the moment
• Haxe 3.2: cross-target Haxe unicode, types & bytes
• TODO: cross-target pointers/concurrency/locking
• TODO: Go implementation of Haxe standard library
• Haxe irritation: Auto-mapping of Int “0xFFFFFFFF” into
“-1” for js and php, when they are not the same thing
• Go “string” type encoding is utf-8, but Go also has the
concept of a “rune” (a 32-bit full Unicode character)
• In Haxe, a string might be implemented as utf-8 or
utf-16, depending on the platform
• TARDIS Go uses the native string encoding (for calling
consistency) translating on the fly as required, with the
runtime distinguishing between the two encodings
based on the length of the ‘字’ character
string types
pointer emulation
• Unlike most languages, Go pointers can’t reference
outside their type, so memory can be a collection of
host objects, with garbage collection by the host
runtime
• Currently, emulated pointers are object references +
offsets into arrays of dynamic objects (a very simple
solution that works for all targets)
• TODO: generate a new Haxe type for each possible Go
pointer type so that dynamic values are not required,
thus speeding up execution
goroutines
• Implemented using co-routines, emulating multiple
stacks
• Each Go function is a Haxe class, with all the local
Go variables
• SSA block # used as the Program Counter
• Haxe timer and other events run the co-routines
goroutine TODO
• improve by using threads, for Haxe targets that
support them
• Don’t implement goroutines if not used, they add a
significant execution overhead and are not always
required
calling Haxe libs from Go
• Go packages beginning with an underscore define Haxe functionality;
they can be auto-generated from the Haxe code or library
documentation with target-specific capital letter prefixes:
s := string(_haxeapi.Xhaxe_Http_requestUrl(someURL))!
switch tardisgolib.Platform() {!
case "cpp": _haxeapi.Pcpp_Lib_println(s)!
case "php": _haxeapi.Hphp_Lib_println(s)!
default: println(s)!
}
using Go vars from Haxe
• all Go globals are pointers
• all pointer targets are Dynamic, which needs to change
• x = Go.pkgName_varName.load();
• Go.pkgName_varName.store(y);
• aPtr = Go.pkgName_varName.addr(42);
calling Go code from Haxe
• x=Go.Go_pkgNam_funcNam.callFromHaxe(y,z);
• TODO: there is a need to build a simple
“methodFromHaxe” calling interface, as using Go
methods from Haxe is currently too complex, for
example:
• _SF1=Go__star_main_dot_rect_area.call(this
._goroutine,[],_t0); // by reference
• _SF2=Go_main_dot_rect_perim.call(this._gor
outine,[],Deep.copy(_t5)); // by value
final interactive example
adapted from OpenFL handling mouse events example
Haxe calls to generated code
• Scheduler.timerEventHandler(e); //
schedule the Go code
• Go_main_MouseDown.callFromHaxe(event.stage
X,event.stageY);
• Go_main_MouseMove.callFromHaxe(event.stage
X,event.stageY);
• Go_main_MouseUp.callFromHaxe(event.stageX,
event.stageY);
Haxe -> Go
• https://code.google.com/p/haxego/ by Lee Sylvester
seems to be inactive
• Efficient server-side operation & concurrency support
• Shared runtime library with TARDIS Go
• Go style concurrency in Haxe?
? -> Haxe -> ?
• TARDIS Go
• Tarwin's AS3 to Haxe Conversion Script
• Typescript to Haxe Conversion Script
• PHP to Haxe Conversion Utility
• CS2HX - C# to haXe converter
• Write a LLVM or GCC compiler Haxe back-end?
http://tardisgo.github.io
• improve TARDIS Go to be a
usable tool
• improve automatic generation
of Go definitions for Haxe
libraries “gohaxelib” (written
in Haxe)
• Work to get Go style
concurrency into Haxe?
• Questions?
Image Sources
• Gopher Logo by Renée French
• TARDIS image (c) BBC from http://bbc.co.uk
• http://commons.wikimedia.org/
• http://www.wikipedia.org/
• http://memegenerator.net/Your-Country-Needs-You
• Project related images from relevant project sites
• Other images self-created

More Related Content

What's hot

Building Awesome CLI apps in Go
Building Awesome CLI apps in GoBuilding Awesome CLI apps in Go
Building Awesome CLI apps in Go
Steven Francia
 
Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go
Steven Francia
 
What we can learn from Rebol?
What we can learn from Rebol?What we can learn from Rebol?
What we can learn from Rebol?
lichtkind
 
Go lang introduction
Go lang introductionGo lang introduction
Go lang introduction
yangwm
 
Introduction to go language programming
Introduction to go language programmingIntroduction to go language programming
Introduction to go language programming
Mahmoud Masih Tehrani
 
PyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MorePyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and More
Matt Harrison
 
Hacking with hhvm
Hacking with hhvmHacking with hhvm
Hacking with hhvm
Elizabeth Smith
 
Python final ppt
Python final pptPython final ppt
Python final ppt
Ripal Ranpara
 
Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3
Chariza Pladin
 
Python in 30 minutes!
Python in 30 minutes!Python in 30 minutes!
Python in 30 minutes!
Fariz Darari
 
Happy Go Programming
Happy Go ProgrammingHappy Go Programming
Happy Go Programming
Lin Yo-An
 
Practicing Python 3
Practicing Python 3Practicing Python 3
Practicing Python 3
Mosky Liu
 
Why Python (for Statisticians)
Why Python (for Statisticians)Why Python (for Statisticians)
Why Python (for Statisticians)
Matt Harrison
 
Introduction to Python Pandas for Data Analytics
Introduction to Python Pandas for Data AnalyticsIntroduction to Python Pandas for Data Analytics
Introduction to Python Pandas for Data Analytics
Phoenix
 
GO programming language
GO programming languageGO programming language
GO programming language
tung vu
 
Go Language Hands-on Workshop Material
Go Language Hands-on Workshop MaterialGo Language Hands-on Workshop Material
Go Language Hands-on Workshop Material
Romin Irani
 
Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02
Fariz Darari
 
Python basics_ part1
Python basics_ part1Python basics_ part1
Python basics_ part1
Elaf A.Saeed
 
Python Seminar PPT
Python Seminar PPTPython Seminar PPT
Python Seminar PPT
Shivam Gupta
 

What's hot (19)

Building Awesome CLI apps in Go
Building Awesome CLI apps in GoBuilding Awesome CLI apps in Go
Building Awesome CLI apps in Go
 
Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go
 
What we can learn from Rebol?
What we can learn from Rebol?What we can learn from Rebol?
What we can learn from Rebol?
 
Go lang introduction
Go lang introductionGo lang introduction
Go lang introduction
 
Introduction to go language programming
Introduction to go language programmingIntroduction to go language programming
Introduction to go language programming
 
PyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MorePyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and More
 
Hacking with hhvm
Hacking with hhvmHacking with hhvm
Hacking with hhvm
 
Python final ppt
Python final pptPython final ppt
Python final ppt
 
Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3
 
Python in 30 minutes!
Python in 30 minutes!Python in 30 minutes!
Python in 30 minutes!
 
Happy Go Programming
Happy Go ProgrammingHappy Go Programming
Happy Go Programming
 
Practicing Python 3
Practicing Python 3Practicing Python 3
Practicing Python 3
 
Why Python (for Statisticians)
Why Python (for Statisticians)Why Python (for Statisticians)
Why Python (for Statisticians)
 
Introduction to Python Pandas for Data Analytics
Introduction to Python Pandas for Data AnalyticsIntroduction to Python Pandas for Data Analytics
Introduction to Python Pandas for Data Analytics
 
GO programming language
GO programming languageGO programming language
GO programming language
 
Go Language Hands-on Workshop Material
Go Language Hands-on Workshop MaterialGo Language Hands-on Workshop Material
Go Language Hands-on Workshop Material
 
Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02
 
Python basics_ part1
Python basics_ part1Python basics_ part1
Python basics_ part1
 
Python Seminar PPT
Python Seminar PPTPython Seminar PPT
Python Seminar PPT
 

Similar to WWX2014 speech : Elliott Stoneham "Tardis go"

Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
Kenneth Geisshirt
 
Getting Started with Go
Getting Started with GoGetting Started with Go
Getting Started with Go
Steven Francia
 
Go from a PHP Perspective
Go from a PHP PerspectiveGo from a PHP Perspective
Go from a PHP Perspective
Barry Jones
 
HHVM and Hack: A quick introduction
HHVM and Hack: A quick introductionHHVM and Hack: A quick introduction
HHVM and Hack: A quick introduction
Kuan Yen Heng
 
TAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith AdamsTAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith Adams
Hermes Alves
 
Golang
GolangGolang
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) Language
Aniruddha Chakrabarti
 
Introduction to Google's Go programming language
Introduction to Google's Go programming languageIntroduction to Google's Go programming language
Introduction to Google's Go programming language
Mario Castro Contreras
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
Kenneth Geisshirt
 
Go Programming language, golang
Go Programming language, golangGo Programming language, golang
Go Programming language, golang
Basil N G
 
Programming Under Linux In Python
Programming Under Linux In PythonProgramming Under Linux In Python
Programming Under Linux In Python
Marwan Osman
 
JRuby, Not Just For Hard-Headed Pragmatists Anymore
JRuby, Not Just For Hard-Headed Pragmatists AnymoreJRuby, Not Just For Hard-Headed Pragmatists Anymore
JRuby, Not Just For Hard-Headed Pragmatists Anymore
Erin Dees
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
Kenneth Geisshirt
 
Welcome to hack
Welcome to hackWelcome to hack
Welcome to hack
Timothy Chandler
 
Hadoop with Python
Hadoop with PythonHadoop with Python
Hadoop with Python
Donald Miner
 
python presntation 2.pptx
python presntation 2.pptxpython presntation 2.pptx
python presntation 2.pptx
Arpittripathi45
 
Hamamatsu.swift @浜松IT合同勉強会
Hamamatsu.swift @浜松IT合同勉強会Hamamatsu.swift @浜松IT合同勉強会
Hamamatsu.swift @浜松IT合同勉強会
Takuya Ogawa
 
Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015
Chris McEniry
 
Building Google-in-a-box: using Apache SolrCloud and Bigtop to index your big...
Building Google-in-a-box: using Apache SolrCloud and Bigtop to index your big...Building Google-in-a-box: using Apache SolrCloud and Bigtop to index your big...
Building Google-in-a-box: using Apache SolrCloud and Bigtop to index your big...
rhatr
 
Happy Go programing
Happy Go programingHappy Go programing
Happy Go programing
Pravin Mishra
 

Similar to WWX2014 speech : Elliott Stoneham "Tardis go" (20)

Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
Getting Started with Go
Getting Started with GoGetting Started with Go
Getting Started with Go
 
Go from a PHP Perspective
Go from a PHP PerspectiveGo from a PHP Perspective
Go from a PHP Perspective
 
HHVM and Hack: A quick introduction
HHVM and Hack: A quick introductionHHVM and Hack: A quick introduction
HHVM and Hack: A quick introduction
 
TAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith AdamsTAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith Adams
 
Golang
GolangGolang
Golang
 
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 Google's Go programming language
Introduction to Google's Go programming languageIntroduction to Google's Go programming language
Introduction to Google's Go programming language
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
Go Programming language, golang
Go Programming language, golangGo Programming language, golang
Go Programming language, golang
 
Programming Under Linux In Python
Programming Under Linux In PythonProgramming Under Linux In Python
Programming Under Linux In Python
 
JRuby, Not Just For Hard-Headed Pragmatists Anymore
JRuby, Not Just For Hard-Headed Pragmatists AnymoreJRuby, Not Just For Hard-Headed Pragmatists Anymore
JRuby, Not Just For Hard-Headed Pragmatists Anymore
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
Welcome to hack
Welcome to hackWelcome to hack
Welcome to hack
 
Hadoop with Python
Hadoop with PythonHadoop with Python
Hadoop with Python
 
python presntation 2.pptx
python presntation 2.pptxpython presntation 2.pptx
python presntation 2.pptx
 
Hamamatsu.swift @浜松IT合同勉強会
Hamamatsu.swift @浜松IT合同勉強会Hamamatsu.swift @浜松IT合同勉強会
Hamamatsu.swift @浜松IT合同勉強会
 
Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015
 
Building Google-in-a-box: using Apache SolrCloud and Bigtop to index your big...
Building Google-in-a-box: using Apache SolrCloud and Bigtop to index your big...Building Google-in-a-box: using Apache SolrCloud and Bigtop to index your big...
Building Google-in-a-box: using Apache SolrCloud and Bigtop to index your big...
 
Happy Go programing
Happy Go programingHappy Go programing
Happy Go programing
 

More from antopensource

Atelier node.js
Atelier node.jsAtelier node.js
Atelier node.js
antopensource
 
Créer son logo vectoriel avec Inkscape
Créer son logo vectoriel avec InkscapeCréer son logo vectoriel avec Inkscape
Créer son logo vectoriel avec Inkscape
antopensource
 
Prise en main rapide et facile de Gimp
Prise en main rapide et facile de GimpPrise en main rapide et facile de Gimp
Prise en main rapide et facile de Gimp
antopensource
 
Low fi prototype par Pol Gaosdoué
Low fi prototype par Pol GaosdouéLow fi prototype par Pol Gaosdoué
Low fi prototype par Pol Gaosdoué
antopensource
 
Atelier brand utility 03.11.2015 Silexl Labs2
Atelier brand utility 03.11.2015  Silexl Labs2Atelier brand utility 03.11.2015  Silexl Labs2
Atelier brand utility 03.11.2015 Silexl Labs2
antopensource
 
Atelier Blender Fev-2016 2/2
Atelier Blender Fev-2016  2/2Atelier Blender Fev-2016  2/2
Atelier Blender Fev-2016 2/2
antopensource
 
Atelier Blender Fev-2016 1/2
Atelier Blender Fev-2016 1/2Atelier Blender Fev-2016 1/2
Atelier Blender Fev-2016 1/2
antopensource
 
Silexlabs atelier couleurs 01
Silexlabs atelier couleurs 01Silexlabs atelier couleurs 01
Silexlabs atelier couleurs 01
antopensource
 
Jive the renovation of Aswing
Jive the renovation of AswingJive the renovation of Aswing
Jive the renovation of Aswing
antopensource
 
WWX14 speech : Justin Donaldson "Promhx : Cross-platform Promises and Reactiv...
WWX14 speech : Justin Donaldson "Promhx : Cross-platform Promises and Reactiv...WWX14 speech : Justin Donaldson "Promhx : Cross-platform Promises and Reactiv...
WWX14 speech : Justin Donaldson "Promhx : Cross-platform Promises and Reactiv...
antopensource
 
Wwx2014 - Todd Kulick "Shipping One Million Lines of Haxe to (Over) One Milli...
Wwx2014 - Todd Kulick "Shipping One Million Lines of Haxe to (Over) One Milli...Wwx2014 - Todd Kulick "Shipping One Million Lines of Haxe to (Over) One Milli...
Wwx2014 - Todd Kulick "Shipping One Million Lines of Haxe to (Over) One Milli...
antopensource
 

More from antopensource (11)

Atelier node.js
Atelier node.jsAtelier node.js
Atelier node.js
 
Créer son logo vectoriel avec Inkscape
Créer son logo vectoriel avec InkscapeCréer son logo vectoriel avec Inkscape
Créer son logo vectoriel avec Inkscape
 
Prise en main rapide et facile de Gimp
Prise en main rapide et facile de GimpPrise en main rapide et facile de Gimp
Prise en main rapide et facile de Gimp
 
Low fi prototype par Pol Gaosdoué
Low fi prototype par Pol GaosdouéLow fi prototype par Pol Gaosdoué
Low fi prototype par Pol Gaosdoué
 
Atelier brand utility 03.11.2015 Silexl Labs2
Atelier brand utility 03.11.2015  Silexl Labs2Atelier brand utility 03.11.2015  Silexl Labs2
Atelier brand utility 03.11.2015 Silexl Labs2
 
Atelier Blender Fev-2016 2/2
Atelier Blender Fev-2016  2/2Atelier Blender Fev-2016  2/2
Atelier Blender Fev-2016 2/2
 
Atelier Blender Fev-2016 1/2
Atelier Blender Fev-2016 1/2Atelier Blender Fev-2016 1/2
Atelier Blender Fev-2016 1/2
 
Silexlabs atelier couleurs 01
Silexlabs atelier couleurs 01Silexlabs atelier couleurs 01
Silexlabs atelier couleurs 01
 
Jive the renovation of Aswing
Jive the renovation of AswingJive the renovation of Aswing
Jive the renovation of Aswing
 
WWX14 speech : Justin Donaldson "Promhx : Cross-platform Promises and Reactiv...
WWX14 speech : Justin Donaldson "Promhx : Cross-platform Promises and Reactiv...WWX14 speech : Justin Donaldson "Promhx : Cross-platform Promises and Reactiv...
WWX14 speech : Justin Donaldson "Promhx : Cross-platform Promises and Reactiv...
 
Wwx2014 - Todd Kulick "Shipping One Million Lines of Haxe to (Over) One Milli...
Wwx2014 - Todd Kulick "Shipping One Million Lines of Haxe to (Over) One Milli...Wwx2014 - Todd Kulick "Shipping One Million Lines of Haxe to (Over) One Milli...
Wwx2014 - Todd Kulick "Shipping One Million Lines of Haxe to (Over) One Milli...
 

Recently uploaded

Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
Yara Milbes
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
TaghreedAltamimi
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
aymanquadri279
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 

Recently uploaded (20)

Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 

WWX2014 speech : Elliott Stoneham "Tardis go"

  • 1. TARDIS: Go for Haxe! A talk by Elliott Stoneham at WWX2014 on 24th May 2014
  • 2. Haxe as a compilation target for other languages a new use-case
  • 3. • 50 years ago: watched very first Dr Who episode • 40 years ago: started programming (punch cards) • 20 years ago: became a manager • 10 years ago: stopped programming • 1 year ago: discovered Go and Haxe…
  • 4. Go is like the TARDIS A small idiosyncratic exterior, conceals large-scale quality engineering.
  • 5. Haxe is like a sonic screwdriver An easy to use tool, built on engineering excellence, that is useful in a wide range of situations.
  • 6. overview • Introduction to Go • TARDIS Go transpiler • Go —> Haxe issues • Go/Haxe interaction • Hopes & dreams
  • 7. the birth of Go in 2007 “When the three of us got started, it was pure research. The three of us got together and decided that we hated C++. ...we started off with the idea that all three of us had to be talked into every feature in the language, so there was no extraneous garbage put into the language for any reason.” —Ken Thompson (who designed and implemented the original Unix operating system)
  • 8. the objectives of Go • “Readable, safe, and efficient code. • A build system that scales. • Good concurrency support. • Tools that can operate at Google-scale." — Robert Griesemer (worked on code generation for Google's V8 JavaScript engine)
  • 9. –Bruce Eckel, author and founding member of the ANSI/ISO C++ standard committee “Now, Go makes much more sense for the class of problems that C++ was originally intended to solve.”
  • 10. burn those C++ manuals! Go —> Haxe + Haxe / OpenFL (running on neko target)
  • 11. Where is Go now? • Open-source more than 4 years, 2 official compilers • Google-scale usage: dl.google.com, youtube.com etc. • Non-Google: docker.com, nsq.io, juju.ubuntu.com etc. • 800 attendees at first conference last month in Denver
  • 12. Go vs Haxe • Github repos: Go >25,600; Haxe > 1,900 • Twitter: Go >11,100; Haxe >1,700 • Google+: Go+ >13,800; Haxe >800 • TIOBE Index for March 2014: Go #36; Haxe not listed
  • 13. TARDIS Go -> Haxe transpiler tardisgo.github.io
  • 14. TARDIS Go objectives • Go running on Haxe cross-platform targets • Go using cross-platform UI APIs like OpenFL • Show that Haxe is viable as an intermediate language • Create a viable Go/Haxe programming ecosystem • Influence the future directions of Haxe and Go
  • 15. concurrency Go provides simple concurrency primitives: • goroutines • lightweight threads: “go doit(a,b,c)” • channels • typed thread-safe communication & synchronisation • send: “ch <- 3” receive: “x, ok = <-ch”
  • 16. tardisgo.github.io • Each of the two sprites is a Go “goroutine" • The pile of books in the middle is a Go “channel”
  • 17. The 3 phases of the TARDIS Go transpiler Go program to be compiled => (1) Use Go library packages to create an intermediate form that entirely describes the original Go program => Single Static Assignment (SSA) form => (2) Generate new Haxe code with the same behaviour => Haxe => (3) Use normal Haxe compilation process
  • 18. The 36 SSA (Single Static Assignment) Instructions Value? Instruction? *Alloc ✔ ✔ *BinOp ✔ ✔ *Builtin ✔ ✔ *Call ✔ ✔ *ChangeInterface ✔ ✔ *ChangeType ✔ ✔ *Convert ✔ ✔ *DebugRef ✔ *Defer ✔ *Extract ✔ ✔ *Field ✔ ✔ *FieldAddr ✔ ✔ *Go ✔ *If ✔ *Index ✔ ✔ *IndexAddr ✔ ✔ *Jump ✔ *Lookup ✔ ✔ *MakeChan ✔ ✔ *MakeClosure ✔ ✔ *MakeInterface ✔ ✔ *MakeMap ✔ ✔ *MakeSlice ✔ ✔ *MapUpdate ✔ *Next ✔ ✔ *Panic ✔ *Phi ✔ ✔ *Range ✔ ✔ *Return ✔ *RunDefers ✔ *Select ✔ ✔ *Send ✔ *Slice ✔ ✔ *Store ✔ *TypeAssert ✔ ✔ *UnOp ✔ ✔
  • 19. go -> ssa example # Name: main.fact # Package: main # Location: glug.go:9:6 func fact(n int) int: .0.entry: P:0 S:2 t0 = n == 0:int bool if t0 goto 1.if.then else 2.if.done .1.if.then: P:1 S:0 return 1:int .2.if.done: P:1 S:0 t1 = n - 1:int int t2 = fact(t1) int t3 = n * t2 int return t3 ! ! func fact(n int) int { if n == 0 { return 1 } return n * fact(n-1) }
  • 20. go -> ssa -> haxe # Name: main.fact # Package: main # Location: glug.go:9:6 func fact(n int) int: .0.entry: t0 = n == 0:int if t0 goto 1.if.then else 2.if.done .1.if.then: return 1:int .2.if.done: t1 = n - 1:int t2 = fact(t1) t3 = n * t2 return t3 ! ! func fact(n int) int { if n == 0 { return 1 } return n * fact(n-1) } ! public function run():Pogo_main_fact { while(true){ switch(_Next) { case 0: // entry this.setLatest(9,0); this.SubFn0(); case 1: // if.then this.setLatest(9,1); _res= 1; this._incomplete=false; Scheduler.pop(this._goroutine); return this; // return 1:int *ssa.Return @ glug.go:11:3 case 2: // if.done this.setLatest(11,2); this.SubFn1(); _SF1=Pogo_main_fact.call(this._goroutine,[],_t1); _Next = -1; return this; case -1: this.setLatest(13,-1); _t2=_SF1.res(); // _t2 = fact(t1) *ssa.Call @ glug.go:13:15 this.SubFn2(); _res= _t3; this._incomplete=false; Scheduler.pop(this._goroutine); return this; // return t3 *ssa.Return @ glug.go:14:2 default: throw "Next?";}}} private inline function SubFn0():Void { var _t0:Bool; _t0=(p_n==0); // _t0 = n == 0:int *ssa.BinOp @ glug.go:10:7 _Next=_t0 ? 1 : 2; // if t0 goto 1.if.then else 2.if.done *ssa.If near glug.go:10:7 }// end SubFn0 private inline function SubFn1():Void { _t1=(p_n-1); // _t1 = n - 1:int *ssa.BinOp @ glug.go:13:17 }// end SubFn1 private inline function SubFn2():Void { _t3=(p_n*_t2); // _t3 = n * t2 *ssa.BinOp @ glug.go:13:9 }// end SubFn2 !
  • 21.
  • 22. Go to compile and run all the Haxe targets in parallel
  • 23. Go/SSA -> Haxe issues • Just a proof-of-concept at the moment • Haxe 3.2: cross-target Haxe unicode, types & bytes • TODO: cross-target pointers/concurrency/locking • TODO: Go implementation of Haxe standard library • Haxe irritation: Auto-mapping of Int “0xFFFFFFFF” into “-1” for js and php, when they are not the same thing
  • 24. • Go “string” type encoding is utf-8, but Go also has the concept of a “rune” (a 32-bit full Unicode character) • In Haxe, a string might be implemented as utf-8 or utf-16, depending on the platform • TARDIS Go uses the native string encoding (for calling consistency) translating on the fly as required, with the runtime distinguishing between the two encodings based on the length of the ‘字’ character string types
  • 25. pointer emulation • Unlike most languages, Go pointers can’t reference outside their type, so memory can be a collection of host objects, with garbage collection by the host runtime • Currently, emulated pointers are object references + offsets into arrays of dynamic objects (a very simple solution that works for all targets) • TODO: generate a new Haxe type for each possible Go pointer type so that dynamic values are not required, thus speeding up execution
  • 26. goroutines • Implemented using co-routines, emulating multiple stacks • Each Go function is a Haxe class, with all the local Go variables • SSA block # used as the Program Counter • Haxe timer and other events run the co-routines
  • 27.
  • 28.
  • 29. goroutine TODO • improve by using threads, for Haxe targets that support them • Don’t implement goroutines if not used, they add a significant execution overhead and are not always required
  • 30. calling Haxe libs from Go • Go packages beginning with an underscore define Haxe functionality; they can be auto-generated from the Haxe code or library documentation with target-specific capital letter prefixes: s := string(_haxeapi.Xhaxe_Http_requestUrl(someURL))! switch tardisgolib.Platform() {! case "cpp": _haxeapi.Pcpp_Lib_println(s)! case "php": _haxeapi.Hphp_Lib_println(s)! default: println(s)! }
  • 31. using Go vars from Haxe • all Go globals are pointers • all pointer targets are Dynamic, which needs to change • x = Go.pkgName_varName.load(); • Go.pkgName_varName.store(y); • aPtr = Go.pkgName_varName.addr(42);
  • 32. calling Go code from Haxe • x=Go.Go_pkgNam_funcNam.callFromHaxe(y,z); • TODO: there is a need to build a simple “methodFromHaxe” calling interface, as using Go methods from Haxe is currently too complex, for example: • _SF1=Go__star_main_dot_rect_area.call(this ._goroutine,[],_t0); // by reference • _SF2=Go_main_dot_rect_perim.call(this._gor outine,[],Deep.copy(_t5)); // by value
  • 33. final interactive example adapted from OpenFL handling mouse events example
  • 34. Haxe calls to generated code • Scheduler.timerEventHandler(e); // schedule the Go code • Go_main_MouseDown.callFromHaxe(event.stage X,event.stageY); • Go_main_MouseMove.callFromHaxe(event.stage X,event.stageY); • Go_main_MouseUp.callFromHaxe(event.stageX, event.stageY);
  • 35. Haxe -> Go • https://code.google.com/p/haxego/ by Lee Sylvester seems to be inactive • Efficient server-side operation & concurrency support • Shared runtime library with TARDIS Go • Go style concurrency in Haxe?
  • 36. ? -> Haxe -> ? • TARDIS Go • Tarwin's AS3 to Haxe Conversion Script • Typescript to Haxe Conversion Script • PHP to Haxe Conversion Utility • CS2HX - C# to haXe converter • Write a LLVM or GCC compiler Haxe back-end?
  • 37. http://tardisgo.github.io • improve TARDIS Go to be a usable tool • improve automatic generation of Go definitions for Haxe libraries “gohaxelib” (written in Haxe) • Work to get Go style concurrency into Haxe? • Questions?
  • 38. Image Sources • Gopher Logo by Renée French • TARDIS image (c) BBC from http://bbc.co.uk • http://commons.wikimedia.org/ • http://www.wikipedia.org/ • http://memegenerator.net/Your-Country-Needs-You • Project related images from relevant project sites • Other images self-created