SlideShare ist ein Scribd-Unternehmen logo
1 von 37
RubyGoLightly
    Porting TinyRb to Google Go
         Eleanor McHugh
 http://slides.games-with-brains.net
Hi I’m Eleanor...
...and I Love Ruby!
but it’s sometimes a bit heavy
which is why I also like
TinyRb
         Marc-Andre Cournoyer
A Subset of Ruby 1.8 in maybe 2k lines of code
  http://github.com/macourneyer/tinyrb
TinyRb
It’s not quite the next JRuby, but it’s clever and elegant.
TinyRb
   Based on a virtual machine design inspired by Lua which places the
   emphasis on register operations rather than stack manipulation with
potential for performance gains. It also features a packrat parser, Boehm
     garbage collector and perl-compatible regular expression library.
TinyRb
   Of course it’s only a proof of concept and would need dedicated work to
develop it into a general Ruby implementation. But then again, as a testbed
 for experimentation it’s ideal. Alas C is lousy at the one thing that’s really
     desirable in a modern Ruby - writing pervasively concurrent systems.
I Want Simple
 Concurrency...
...And I Know I’m
    Not Alone!
Does This Sound Familiar?
   Elric sent his mind into twisting tunnels of logic, across endless plains of
ideas, through mountains of symbolism and endless universes of alternate truths;
 he sent his mind out further and further and as it went he sent with it the words
which issued from his writhing lips--words that few of his contemporaries would
                                   understand...
                  - Elric of Melniboné, Michael Moorcock
We’re Coders Dammit
  So why does every systems language insist we have to be wizards?
And not just any wizards at that, the criminally insane kind who cavort
 with Daemons and understand non-linear hypertemporal dynamics!
No Wonder We’re
 Lousy At Concurrency
And that includes you Erlang, Goddess of the Cult of Immutable State.
   You’ll have to rip state mutability from my cold dead hands!!!
But There Is
Another Way!
Google Go
Robert Griesemer, Rob Pike, Ken Thompson, et al.
A Systems Language for Multi-Core Development
               http://golang.org/
A Modern Language
Go is a statically typed compiled language designed from the ground up to
be simple to parse and effective for parallel computation. It also features a
  novel form of object orientation designed to capture the feel of dynamic
      programming languages. Oh, and it’s garbage collected too!
A Procedural Language
  Go is based on Hoare’s CSP algebra so it models concurrency as
synchronous and asynchronous communication between processes rather
          than common access to a shared memory resource.
A Grounded Language
Rob Pike and Ken Thompson worked at Bell Labs on Unix and its
 successors Plan9 and Inferno, developing the procedural concurrent
                languages newsqueak, alef and limbo.
A Fun Language
Like Ruby it aims to be fun and to aid programmer productivity by
removing the artificial relationships between types which dog many
          traditional object-oriented systems languages.
It’s All About Methods
Ruby dynamically infers type     Go dynamically infers class

superclass              type       type              class
  class                 module                       interface


             instance                        value
Some Simple Building Blocks
  structs and interfaces are values
  arrays have a fixed dimension and are values
  strings are immutable values
  slices are references to sections of an array
  maps are references to hash tables
  channels are references to communication pipes
And A Unique Approach
pointers to variables not memory locations
declaration initialises memory
functions can return multiple values
interfaces define objects based upon methods supported
channels provide synchronised concurrency
goroutines pool concurrency over threads of execution
At Last, Some Code
 The following slides cover many of the basic features of Go syntax whilst
outlining a basic Actor library for writing concurrent applications. None of
                   this code has been tested, so go test it!
Type Declaration
1.    package actors
                                                         A package groups related code.
3.    type Request struct {
4.     message string;
5.     author chan string;
6.    }
                                                  Several files can be part of the same package.
7.    type MessageQueue chan *Request
8.    type Communicator struct {
                                          A type is specified in terms of another type and responds to the
9.     messages MessageQueue;
10.    terminate chan bool;
                                           methods of that type. It can also be specialised further with
11.   }
12.   type Action func() string
                                                                    new methods.
13.   type Actor struct {
14.    name string;
15.    Communicator;
16.    actions map[string] *Action;
                                              Note how functions, structures and channels can all be
17.   }
18.   type Stage struct {
                                                           subtyped in this manner.
19.    actors map[string] MessageQueue;
20.   }
21.   type Interface canAct {
22.    Listen();
                                           An interface is a type specifying a set of functions - more on
23.    Enter(s *Stage);
24.    Respond(r *Request);
                                                                    these later.
25.   }
Functions & Methods
1.    package actor
                                                               Methods are functions which are defined for a type.
3.    func NewActor() {
4.     a := new(Actor);
5.     a.messages = make(MessageQueue);
6.     a.deactivate = make(chan bool);
                                                            Methods are called by applying a selector to a value of the
7.     go a.Listen();
8.     return Communicator{ a.messages, a.terminate };
                                                             type for which they are defined or of a compatible type.
9.    }
10.   func (a *Actor) Listen() {
11.    for {
12.       select {
                                                               Both methods and functions are visible outside their
13.       case request := <- a.messages: go a.respond(r);
14.       case <-a.terminate: return;
                                                              package if their name starts with an uppercase letter,
15.       }
16.    }
                                                                   otherwise they are private to the package.
17.   }



                                                            A method or function can be launched in a goroutine with
                                                             the go statement, creating an asynchronous coroutine
                                                                       which is managed by the runtime.
Functions & Methods
1.    func (a *Actor) unknownAction(m string) { }
2.    func (a *Actor) Respond(r *Request) {
3.     if action, ok := actions[r.message]; ok {
4.        r.author <- action
5.     } else {
6.        a.unknownAction(r.message)
7.     }
8.    }
9.    func (s *Stage) entered(a *Actor) bool {
10.    if a, ok := s.actors[a.name]; ok { return false }
11.    s.actors[a.name] = a.messages;
12.    return true;
13.   }
14.   func (a *Actor) Enter(s *Stage) bool {
15.    return s.entered(self);
16.   }
You Mean I Can Have...
Readability
Type Safety
Resource Efficiency
Garbage Collection
Concurrency
Multi-Core
So Here’re My Thoughts...
 Ruby rocks
 but is resource heavy
 TinyRb is light
 but also experimental
 and written in C
 Go is cleverer than C
Ladies & Gentlemen
   please allow me to introduce you to...
RubyGoLightly
              Eleanor McHugh
           A Port of TinyRb to Go
http://github.com/feyeleanor/RubyGoLightly
RubyGoLightly
The goal of the RubyGoLightly project is to develop a modern credible
virtual machine and runtime for Ruby, or a significant subset of Ruby,
  without the runtime weight of Java or the maintenance issues of C.
Recipe
take a small C codebase
rewrite it in idiomatic Go
simmer in pervasive goroutine stock
drizzle a jus of native garbage collection
and season to taste
serve à la mode
RubyGoLightly
A virtual machine which is light and flexible to encourage experimentation,
   particularly experimentation geared to exploiting modern multi-core
                     hardware and using it efficiently.
RubyGoLightly
 Everywhere Ruby’s landed it’s been disruptive and transformative, so why
not inject it into the Google ecosystem? With Native Client developers could
be using Ruby for high-performance in-browser clients whilst with Android
       they could be running Ruby code natively on embedded devices.
Desperately Seeking...
    If this sounds like the kind of fun you’d like to be involved with we’re
actively looking for sponsors to help fund development and contributors to...
     well contribute. Coders to code, testers to test, documenters to write
                    documents - come one, come all and...
Join Us On Github
  http://github.com/feyeleanor/RubyGoLightly

Weitere ähnliche Inhalte

Was ist angesagt?

Playfulness at Work
Playfulness at WorkPlayfulness at Work
Playfulness at WorkErin Dees
 
Greach 2014 - Metaprogramming with groovy
Greach 2014 - Metaprogramming with groovyGreach 2014 - Metaprogramming with groovy
Greach 2014 - Metaprogramming with groovyIván López Martín
 
How to create a programming language
How to create a programming languageHow to create a programming language
How to create a programming languageRobert Mamore
 
Pré Descobrimento Do Brasil
Pré Descobrimento Do BrasilPré Descobrimento Do Brasil
Pré Descobrimento Do Brasilecsette
 
14.jun.2012
14.jun.201214.jun.2012
14.jun.2012Tech_MX
 
Prototype-based Programming with JavaScript
Prototype-based Programming with JavaScriptPrototype-based Programming with JavaScript
Prototype-based Programming with JavaScriptlienhard
 
P4 P Update January 2009
P4 P Update January 2009P4 P Update January 2009
P4 P Update January 2009vsainteluce
 
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.pptcallroom
 
name name2 n2
name name2 n2name name2 n2
name name2 n2callroom
 

Was ist angesagt? (13)

Playfulness at Work
Playfulness at WorkPlayfulness at Work
Playfulness at Work
 
Greach 2014 - Metaprogramming with groovy
Greach 2014 - Metaprogramming with groovyGreach 2014 - Metaprogramming with groovy
Greach 2014 - Metaprogramming with groovy
 
How to create a programming language
How to create a programming languageHow to create a programming language
How to create a programming language
 
Pré Descobrimento Do Brasil
Pré Descobrimento Do BrasilPré Descobrimento Do Brasil
Pré Descobrimento Do Brasil
 
14.jun.2012
14.jun.201214.jun.2012
14.jun.2012
 
Prototype-based Programming with JavaScript
Prototype-based Programming with JavaScriptPrototype-based Programming with JavaScript
Prototype-based Programming with JavaScript
 
P4 P Update January 2009
P4 P Update January 2009P4 P Update January 2009
P4 P Update January 2009
 
Ebay News 2000 10 19 Earnings
Ebay News 2000 10 19 EarningsEbay News 2000 10 19 Earnings
Ebay News 2000 10 19 Earnings
 
Ebay News 2001 4 19 Earnings
Ebay News 2001 4 19 EarningsEbay News 2001 4 19 Earnings
Ebay News 2001 4 19 Earnings
 
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.ppt
 
ppt9
ppt9ppt9
ppt9
 
ppt18
ppt18ppt18
ppt18
 
name name2 n2
name name2 n2name name2 n2
name name2 n2
 

Andere mochten auch

The Ruby Plumber's Guide to *nix
The Ruby Plumber's Guide to *nixThe Ruby Plumber's Guide to *nix
The Ruby Plumber's Guide to *nixEleanor McHugh
 
Finding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in goFinding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in goEleanor McHugh
 
Anonymity, trust, accountability
Anonymity, trust, accountabilityAnonymity, trust, accountability
Anonymity, trust, accountabilityEleanor McHugh
 
Implementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & CImplementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & CEleanor McHugh
 
Going Loopy: Adventures in Iteration with Go
Going Loopy: Adventures in Iteration with GoGoing Loopy: Adventures in Iteration with Go
Going Loopy: Adventures in Iteration with GoEleanor McHugh
 
Implementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & CImplementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & CEleanor McHugh
 

Andere mochten auch (6)

The Ruby Plumber's Guide to *nix
The Ruby Plumber's Guide to *nixThe Ruby Plumber's Guide to *nix
The Ruby Plumber's Guide to *nix
 
Finding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in goFinding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in go
 
Anonymity, trust, accountability
Anonymity, trust, accountabilityAnonymity, trust, accountability
Anonymity, trust, accountability
 
Implementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & CImplementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & C
 
Going Loopy: Adventures in Iteration with Go
Going Loopy: Adventures in Iteration with GoGoing Loopy: Adventures in Iteration with Go
Going Loopy: Adventures in Iteration with Go
 
Implementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & CImplementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & C
 

Ähnlich wie Porting TinyRb to Google Go with RubyGoLightly

Lambda Expressions in Java 8
Lambda Expressions in Java 8Lambda Expressions in Java 8
Lambda Expressions in Java 8icarter09
 
(6) c sharp introduction_advanced_features_part_i
(6) c sharp introduction_advanced_features_part_i(6) c sharp introduction_advanced_features_part_i
(6) c sharp introduction_advanced_features_part_iNico Ludwig
 
Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)Muhammad Haseeb Shahid
 
Workin ontherailsroad
Workin ontherailsroadWorkin ontherailsroad
Workin ontherailsroadJim Jones
 
WorkinOnTheRailsRoad
WorkinOnTheRailsRoadWorkinOnTheRailsRoad
WorkinOnTheRailsRoadwebuploader
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answersRojaPriya
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answerskavinilavuG
 
Promoting Polymorphism
Promoting PolymorphismPromoting Polymorphism
Promoting PolymorphismKevlin Henney
 
whats new in java 8
whats new in java 8 whats new in java 8
whats new in java 8 Dori Waldman
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Mark Menard
 
The JavaScript You Wished You Knew
The JavaScript You Wished You KnewThe JavaScript You Wished You Knew
The JavaScript You Wished You KnewTroy Miles
 
Perfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standardsPerfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standardsPerfomatix Solutions
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 

Ähnlich wie Porting TinyRb to Google Go with RubyGoLightly (20)

Lambda Expressions in Java 8
Lambda Expressions in Java 8Lambda Expressions in Java 8
Lambda Expressions in Java 8
 
Designing Better API
Designing Better APIDesigning Better API
Designing Better API
 
(6) c sharp introduction_advanced_features_part_i
(6) c sharp introduction_advanced_features_part_i(6) c sharp introduction_advanced_features_part_i
(6) c sharp introduction_advanced_features_part_i
 
Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)
 
Workin ontherailsroad
Workin ontherailsroadWorkin ontherailsroad
Workin ontherailsroad
 
WorkinOnTheRailsRoad
WorkinOnTheRailsRoadWorkinOnTheRailsRoad
WorkinOnTheRailsRoad
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Promoting Polymorphism
Promoting PolymorphismPromoting Polymorphism
Promoting Polymorphism
 
Intervies
InterviesIntervies
Intervies
 
whats new in java 8
whats new in java 8 whats new in java 8
whats new in java 8
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1
 
The JavaScript You Wished You Knew
The JavaScript You Wished You KnewThe JavaScript You Wished You Knew
The JavaScript You Wished You Knew
 
Perfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standardsPerfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standards
 
ppt7
ppt7ppt7
ppt7
 
ppt2
ppt2ppt2
ppt2
 
name name2 n
name name2 nname name2 n
name name2 n
 
test ppt
test ppttest ppt
test ppt
 
name name2 n
name name2 nname name2 n
name name2 n
 
ppt21
ppt21ppt21
ppt21
 

Mehr von Eleanor McHugh

[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdfEleanor McHugh
 
Generics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsGenerics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsEleanor McHugh
 
The Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data IntegrityThe Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data IntegrityEleanor McHugh
 
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]Eleanor McHugh
 
The Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveThe Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveEleanor McHugh
 
Go for the paranoid network programmer, 3rd edition
Go for the paranoid network programmer, 3rd editionGo for the paranoid network programmer, 3rd edition
Go for the paranoid network programmer, 3rd editionEleanor McHugh
 
An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]Eleanor McHugh
 
An introduction to functional programming with go
An introduction to functional programming with goAn introduction to functional programming with go
An introduction to functional programming with goEleanor McHugh
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxEleanor McHugh
 
Identity & trust in Monitored Spaces
Identity & trust in Monitored SpacesIdentity & trust in Monitored Spaces
Identity & trust in Monitored SpacesEleanor McHugh
 
Don't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By DesignDon't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By DesignEleanor McHugh
 
Don't ask, don't tell the virtues of privacy by design
Don't ask, don't tell   the virtues of privacy by designDon't ask, don't tell   the virtues of privacy by design
Don't ask, don't tell the virtues of privacy by designEleanor McHugh
 
Anonymity, identity, trust
Anonymity, identity, trustAnonymity, identity, trust
Anonymity, identity, trustEleanor McHugh
 
Going Loopy - Adventures in Iteration with Google Go
Going Loopy - Adventures in Iteration with Google GoGoing Loopy - Adventures in Iteration with Google Go
Going Loopy - Adventures in Iteration with Google GoEleanor McHugh
 
Distributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at ScaleDistributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at ScaleEleanor McHugh
 
Go for the paranoid network programmer, 2nd edition
Go for the paranoid network programmer, 2nd editionGo for the paranoid network programmer, 2nd edition
Go for the paranoid network programmer, 2nd editionEleanor McHugh
 
Implementing Software Machines in C and Go
Implementing Software Machines in C and GoImplementing Software Machines in C and Go
Implementing Software Machines in C and GoEleanor McHugh
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and CEleanor McHugh
 
Encrypt all transports
Encrypt all transportsEncrypt all transports
Encrypt all transportsEleanor McHugh
 

Mehr von Eleanor McHugh (20)

[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf
 
Generics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsGenerics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient Collections
 
The Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data IntegrityThe Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data Integrity
 
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
 
The Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveThe Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's Perspective
 
Go for the paranoid network programmer, 3rd edition
Go for the paranoid network programmer, 3rd editionGo for the paranoid network programmer, 3rd edition
Go for the paranoid network programmer, 3rd edition
 
An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]
 
An introduction to functional programming with go
An introduction to functional programming with goAn introduction to functional programming with go
An introduction to functional programming with go
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 redux
 
Identity & trust in Monitored Spaces
Identity & trust in Monitored SpacesIdentity & trust in Monitored Spaces
Identity & trust in Monitored Spaces
 
Don't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By DesignDon't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By Design
 
Don't ask, don't tell the virtues of privacy by design
Don't ask, don't tell   the virtues of privacy by designDon't ask, don't tell   the virtues of privacy by design
Don't ask, don't tell the virtues of privacy by design
 
Anonymity, identity, trust
Anonymity, identity, trustAnonymity, identity, trust
Anonymity, identity, trust
 
Going Loopy - Adventures in Iteration with Google Go
Going Loopy - Adventures in Iteration with Google GoGoing Loopy - Adventures in Iteration with Google Go
Going Loopy - Adventures in Iteration with Google Go
 
Distributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at ScaleDistributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at Scale
 
Hello Go
Hello GoHello Go
Hello Go
 
Go for the paranoid network programmer, 2nd edition
Go for the paranoid network programmer, 2nd editionGo for the paranoid network programmer, 2nd edition
Go for the paranoid network programmer, 2nd edition
 
Implementing Software Machines in C and Go
Implementing Software Machines in C and GoImplementing Software Machines in C and Go
Implementing Software Machines in C and Go
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and C
 
Encrypt all transports
Encrypt all transportsEncrypt all transports
Encrypt all transports
 

Kürzlich hochgeladen

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
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
 
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
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 

Kürzlich hochgeladen (20)

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
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
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.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
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
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!
 
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
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 

Porting TinyRb to Google Go with RubyGoLightly

  • 1. RubyGoLightly Porting TinyRb to Google Go Eleanor McHugh http://slides.games-with-brains.net
  • 4. but it’s sometimes a bit heavy
  • 5. which is why I also like
  • 6. TinyRb Marc-Andre Cournoyer A Subset of Ruby 1.8 in maybe 2k lines of code http://github.com/macourneyer/tinyrb
  • 7. TinyRb It’s not quite the next JRuby, but it’s clever and elegant.
  • 8. TinyRb Based on a virtual machine design inspired by Lua which places the emphasis on register operations rather than stack manipulation with potential for performance gains. It also features a packrat parser, Boehm garbage collector and perl-compatible regular expression library.
  • 9. TinyRb Of course it’s only a proof of concept and would need dedicated work to develop it into a general Ruby implementation. But then again, as a testbed for experimentation it’s ideal. Alas C is lousy at the one thing that’s really desirable in a modern Ruby - writing pervasively concurrent systems.
  • 10. I Want Simple Concurrency...
  • 11. ...And I Know I’m Not Alone!
  • 12. Does This Sound Familiar? Elric sent his mind into twisting tunnels of logic, across endless plains of ideas, through mountains of symbolism and endless universes of alternate truths; he sent his mind out further and further and as it went he sent with it the words which issued from his writhing lips--words that few of his contemporaries would understand... - Elric of Melniboné, Michael Moorcock
  • 13. We’re Coders Dammit So why does every systems language insist we have to be wizards? And not just any wizards at that, the criminally insane kind who cavort with Daemons and understand non-linear hypertemporal dynamics!
  • 14. No Wonder We’re Lousy At Concurrency And that includes you Erlang, Goddess of the Cult of Immutable State. You’ll have to rip state mutability from my cold dead hands!!!
  • 16. Google Go Robert Griesemer, Rob Pike, Ken Thompson, et al. A Systems Language for Multi-Core Development http://golang.org/
  • 17. A Modern Language Go is a statically typed compiled language designed from the ground up to be simple to parse and effective for parallel computation. It also features a novel form of object orientation designed to capture the feel of dynamic programming languages. Oh, and it’s garbage collected too!
  • 18. A Procedural Language Go is based on Hoare’s CSP algebra so it models concurrency as synchronous and asynchronous communication between processes rather than common access to a shared memory resource.
  • 19. A Grounded Language Rob Pike and Ken Thompson worked at Bell Labs on Unix and its successors Plan9 and Inferno, developing the procedural concurrent languages newsqueak, alef and limbo.
  • 20. A Fun Language Like Ruby it aims to be fun and to aid programmer productivity by removing the artificial relationships between types which dog many traditional object-oriented systems languages.
  • 21. It’s All About Methods Ruby dynamically infers type Go dynamically infers class superclass type type class class module interface instance value
  • 22. Some Simple Building Blocks structs and interfaces are values arrays have a fixed dimension and are values strings are immutable values slices are references to sections of an array maps are references to hash tables channels are references to communication pipes
  • 23. And A Unique Approach pointers to variables not memory locations declaration initialises memory functions can return multiple values interfaces define objects based upon methods supported channels provide synchronised concurrency goroutines pool concurrency over threads of execution
  • 24. At Last, Some Code The following slides cover many of the basic features of Go syntax whilst outlining a basic Actor library for writing concurrent applications. None of this code has been tested, so go test it!
  • 25. Type Declaration 1. package actors A package groups related code. 3. type Request struct { 4. message string; 5. author chan string; 6. } Several files can be part of the same package. 7. type MessageQueue chan *Request 8. type Communicator struct { A type is specified in terms of another type and responds to the 9. messages MessageQueue; 10. terminate chan bool; methods of that type. It can also be specialised further with 11. } 12. type Action func() string new methods. 13. type Actor struct { 14. name string; 15. Communicator; 16. actions map[string] *Action; Note how functions, structures and channels can all be 17. } 18. type Stage struct { subtyped in this manner. 19. actors map[string] MessageQueue; 20. } 21. type Interface canAct { 22. Listen(); An interface is a type specifying a set of functions - more on 23. Enter(s *Stage); 24. Respond(r *Request); these later. 25. }
  • 26. Functions & Methods 1. package actor Methods are functions which are defined for a type. 3. func NewActor() { 4. a := new(Actor); 5. a.messages = make(MessageQueue); 6. a.deactivate = make(chan bool); Methods are called by applying a selector to a value of the 7. go a.Listen(); 8. return Communicator{ a.messages, a.terminate }; type for which they are defined or of a compatible type. 9. } 10. func (a *Actor) Listen() { 11. for { 12. select { Both methods and functions are visible outside their 13. case request := <- a.messages: go a.respond(r); 14. case <-a.terminate: return; package if their name starts with an uppercase letter, 15. } 16. } otherwise they are private to the package. 17. } A method or function can be launched in a goroutine with the go statement, creating an asynchronous coroutine which is managed by the runtime.
  • 27. Functions & Methods 1. func (a *Actor) unknownAction(m string) { } 2. func (a *Actor) Respond(r *Request) { 3. if action, ok := actions[r.message]; ok { 4. r.author <- action 5. } else { 6. a.unknownAction(r.message) 7. } 8. } 9. func (s *Stage) entered(a *Actor) bool { 10. if a, ok := s.actors[a.name]; ok { return false } 11. s.actors[a.name] = a.messages; 12. return true; 13. } 14. func (a *Actor) Enter(s *Stage) bool { 15. return s.entered(self); 16. }
  • 28. You Mean I Can Have... Readability Type Safety Resource Efficiency Garbage Collection Concurrency Multi-Core
  • 29. So Here’re My Thoughts... Ruby rocks but is resource heavy TinyRb is light but also experimental and written in C Go is cleverer than C
  • 30. Ladies & Gentlemen please allow me to introduce you to...
  • 31. RubyGoLightly Eleanor McHugh A Port of TinyRb to Go http://github.com/feyeleanor/RubyGoLightly
  • 32. RubyGoLightly The goal of the RubyGoLightly project is to develop a modern credible virtual machine and runtime for Ruby, or a significant subset of Ruby, without the runtime weight of Java or the maintenance issues of C.
  • 33. Recipe take a small C codebase rewrite it in idiomatic Go simmer in pervasive goroutine stock drizzle a jus of native garbage collection and season to taste serve à la mode
  • 34. RubyGoLightly A virtual machine which is light and flexible to encourage experimentation, particularly experimentation geared to exploiting modern multi-core hardware and using it efficiently.
  • 35. RubyGoLightly Everywhere Ruby’s landed it’s been disruptive and transformative, so why not inject it into the Google ecosystem? With Native Client developers could be using Ruby for high-performance in-browser clients whilst with Android they could be running Ruby code natively on embedded devices.
  • 36. Desperately Seeking... If this sounds like the kind of fun you’d like to be involved with we’re actively looking for sponsors to help fund development and contributors to... well contribute. Coders to code, testers to test, documenters to write documents - come one, come all and...
  • 37. Join Us On Github http://github.com/feyeleanor/RubyGoLightly

Hinweis der Redaktion