SlideShare a Scribd company logo
1 of 20
Download to read offline
Embracing
                                    Concurrency
                     for Fun, Utility & Simpler Code




Michael Sparks
BBC R&D, http://www.kamaelia.org/Home    Ignite Leeds, Jan 2009
Embracing
                                     Concurrency
                     for Fun, Utility & Simpler Code
                                    Or “what we've learnt as a part of the
                                     Kamaelia project about making concurrency
                                  something that's fun and useful, and usable by
                                     novice and advanced developers alike...
                                     ...rather than a pain in the neck”




Michael Sparks
BBC R&D, http://www.kamaelia.org/Home                     Ignite Leeds, Jan 2009
Why?                             Hardware finally going
                                  massively concurrent                                       ...
              Opportunity!        .... PS3, high end servers, trickling down to desktops, laptops)



“many hands make light
work” but Viewed as Hard
... do we just have crap tools?


                         “And one language to in
                         the darkness bind them”
    Problems
                         ... can just we REALLY abandon 50 years of code for Erlang, Haskell
                         and occam?

Michael Sparks
BBC R&D, http://www.kamaelia.org/Home
Missing Something?
  Fundamental Control Structures
  ... in imperative languages number greater than 3! (despite what you get taught...!)

       Control Structure         Traditional Abstraction         Biggest Pain Points

        Sequence                       Function                    Global Var
        Selection                      Function                    Global Var
         Iteration                     Function                    Global Var
          Parallel                      Thread                    Shared Data
                          Usually Skipped            Lost or duplicate update
                                                     are most common bugs
   This slide raises the point that
  teaching of imperative languages often
misses out concurrency as a fundamental
 Michael Sparks
 construct, leaving a conceptual gap
 BBC R&D, http://www.kamaelia.org/Home
           for most developers
Regarding using
concurrency, what sort
 of applications are we
  talking about here?


                                        Desktop            gsoc


                                                  Novice
                          Media

                                       APPS                trainee



                                                  3rd Party
                                  Network




Michael Sparks
BBC R&D, http://www.kamaelia.org/Home
Speak 'n Write
Think backend               P2P Whiteboard Programming
                                                               Simple
needed for                                    (logo)
                        ER DB Modeller                                             P2P Radio
                                                               Games
                                                       Kids
youtube/flickr                                                                     Torrent
                                                                                   3D Systems
type systems                Compose                                                Realtime Music
                                             Desktop                     gsoc
          UGC                                                                      Paint App
                                                                                   P2P Web Server
        Backend
                                                                                   Secure “phone”
       Transcoder                                                                  Social Net Vis
                                                            Novice
                      Media                                                        ...
Shot Change
                                            APPS
Detection                                                                            MiniAxon
                                                                     trainee         ScriptReader
    Mobile        DVB                                                                MediaPreview
    Reframing                                                                        on Mobile
                                                                                     Reliable
                                                           3rd Party
                 Podcasts                                                            Multicast
                                  Network
     Macro
                                                                                       Sedna
    “record
                                                                                 XMPP XMLDB
  everything”
                                                          AWS
                        Email &                                                 pubsub
                                               Web      (Amazon)
                        Spam                                              Qt
      SMTP                            IRC
                                              Serving              Gtk
  Greylisting
                        ClientSide                                               microblogging
                                            AIM
          Pop3Proxy
                        Spam Tools

Michael Sparks
BBC R&D, http://www.kamaelia.org/Home
Core Approach:
   Concurrent things with comms points
   Generally send messages
   Keep data private, don't share



                                                  outbox
                                        inbox
                           outbox
   inbox
                                                  signal
                                        control
                           signal
  control
                                                    ...
                                          ...
                             ...
    ...



Michael Sparks
BBC R&D, http://www.kamaelia.org/Home
But I must share data?
Use Software Transactional Memory
ie version control for variables.
                        1. Check out the collection
                           of values you wish to
                           work on
                        2. Change them
                        3. Check them back in
                        4. If conflict/clash, go
                           back to 1



Michael Sparks
BBC R&D, http://www.kamaelia.org/Home
Perspectives in APIs! (1/2)
    If you have concurrency it becomes
 natural to think in terms of 1st 2nd and 3rd
                                                1st Person - I change my state
  person. This affects an API's structure,
   and can be vital for understanding it!
 This is one we've found that makes sense



2nd Person – YOU                                               3rd Person –
want to me to do                                               Bla should
something                                                      do something
(you send                                                      (I send a message)
                                                     outbox
                                    inbox
me a message)
                                                      signal
                                   control

                                                       ...
                                     ...




Michael Sparks
BBC R&D, http://www.kamaelia.org/Home
Perspectives in APIs! (2/2)
    If you have concurrency it becomes
 natural to think in terms of 1st 2nd and 3rd
                                                   private real methods
  person. This affects an API's structure,
   and can be vital for understanding it!
 This is one we've found that makes sense



                                                         Messages sent
 Messages
                                                         to public outboxes
 from public
 inboxes
                                                outbox
                                    inbox
                                                signal
                                   control
                                                             Also, think
Also, think                                       ...
                                     ...
                                                             about stdout
about stdin

Michael Sparks
BBC R&D, http://www.kamaelia.org/Home
Actor Systems
         Distinction can be unclear,
                                          private real methods
         potential source of ambiguity*


 Messages
                                           No outbox concept
 from public
                                           Possible issues with
 inboxes
                                           rate limiting*
                      inbox

                                           Hardcodes recipient
                     control


                                           in the sender
                       ...


*system dependent issue
Michael Sparks
BBC R&D, http://www.kamaelia.org/Home
Advantages of outboxes
                                    No hardcoding of recipient
                                    allows:
                                      - Late Binding
                                      - Dynamic rewiring

                                    Concurrency Patterns as
                          outbox
  inbox
                                    Reusable Code
                           signal
  control
                                    ... a concurrency DSL
                            ...
    ...




Michael Sparks
BBC R&D, http://www.kamaelia.org/Home
A Core Concurrency DSL
    Pipeline(A,B,C)
    Graphline(A=A,B=B, C=C, linkages = {})
    Tpipe(cond, C)
    Seq(A,B,C), PAR(), ALT()
    Backplane(“name”), PublishTo(“name”), SubscribeTo(“name”)
    Carousel(...)
    PureTransformer(...)
    StatefulTransformer(...)
    PureServer(...)
    MessageDemuxer(...)
    Source(*messages)
    NullSink
                                        Some of these are work in progress
                                        – they've been identified as useful,
                                        but not implemented as chassis, yet
Michael Sparks
BBC R&D, http://www.kamaelia.org/Home
Pipeline Example
    Pipeline(
        MyGamesEventsComponent(up=quot;pquot;, down=quot;lquot;, left=quot;aquot;, right=quot;squot;),
        BasicSprite(quot;cat.pngquot;, name = quot;catquot;, border=40),
    ).activate()                                            MyGames
                                                             Events
                                                           Component




                                                             Basic
                                                             Sprite




Michael Sparks
BBC R&D, http://www.kamaelia.org/Home
Graphline Example
    Graphline(
      NEXT = Button(...),
      PREVIOUS = Button(...),                  PREVIOUS       NEXT
      FIRST = Button(...),                      (button)     (button)
      LAST = Button(...),
      CHOOSER = Chooser(...),
                                         FIRST                            LAST
      IMAGE = Image(...),
                                        (button)                        (button)
      ...
    ).run()

                                                       Chooser




                                                                    Image
Michael Sparks
BBC R&D, http://www.kamaelia.org/Home
Server Example

                              data
                              from
                              user                      data
                                     Socket handler
         Main
                                                         to
      Server Core
                                                        user

                                                      Created at runtime
                                                      to handle the
                                                      connection           Remote
   Protocol Handler Factory
                                                                            User
                                 Protocol handler


Michael Sparks
BBC R&D, http://www.kamaelia.org/Home
Server Example

                                        You therefore
                                        need to provide
                                        this bit.
         Main
      Server Core




   Protocol Handler Factory



Michael Sparks
BBC R&D, http://www.kamaelia.org/Home
Server Example
    from Kamaelia.Chassis.ConnectedServer import ServerCore
    from Kamaelia.Util.PureTransformer import PureTransformer

    def greeter(*argv, **argd):
        return PureTransformer(lambda x: quot;helloquot; +x)

    class GreeterServer(ServerCore):
        protocol=greeter
        port=1601

    GreeterServer().run()




Michael Sparks
BBC R&D, http://www.kamaelia.org/Home
Backplane Example
    # Streaming Server for raw DVB of Radio 1
    Backplane(“Radio”).activate()

    Pipeline(
       DVB_Multiplex(850.16, [6210], feparams), # RADIO ONE
       PublishTo(quot;RADIOquot;),
    ).activate()

    def radio(*argv,**argd):
         return SubscribeTo(“RADIO”)

    ServerCore(protocol=radio, port=1600).run()




Michael Sparks
BBC R&D, http://www.kamaelia.org/Home
Thank you for listening!

            If you have questions, grab me later :-)




Michael Sparks
BBC R&D, http://www.kamaelia.org/Home

More Related Content

Viewers also liked

Photoshop Club
Photoshop ClubPhotoshop Club
Photoshop ClubKitara
 
Kamaelia Grey
Kamaelia GreyKamaelia Grey
Kamaelia Greykamaelian
 
Managing Creativity
Managing CreativityManaging Creativity
Managing Creativitykamaelian
 
The Selfish Programmer
The Selfish ProgrammerThe Selfish Programmer
The Selfish Programmerkamaelian
 
Timeshift Everything, Miss Nothing - Mashup your PVR with Kamaelia
Timeshift Everything, Miss Nothing - Mashup your PVR with KamaeliaTimeshift Everything, Miss Nothing - Mashup your PVR with Kamaelia
Timeshift Everything, Miss Nothing - Mashup your PVR with Kamaeliakamaelian
 
RabbitMQ with python and ruby RuPy 2009
RabbitMQ with python and ruby RuPy 2009RabbitMQ with python and ruby RuPy 2009
RabbitMQ with python and ruby RuPy 2009Paolo Negri
 
Descriptors In Python
Descriptors In PythonDescriptors In Python
Descriptors In PythonAmit Upadhyay
 
Messaging with RabbitMQ and AMQP
Messaging with RabbitMQ and AMQPMessaging with RabbitMQ and AMQP
Messaging with RabbitMQ and AMQPEberhard Wolff
 
Data Analysis and Statistics in Python using pandas and statsmodels
Data Analysis and Statistics in Python using pandas and statsmodelsData Analysis and Statistics in Python using pandas and statsmodels
Data Analysis and Statistics in Python using pandas and statsmodelsWes McKinney
 
Django for Beginners
Django for BeginnersDjango for Beginners
Django for BeginnersJason Davies
 
Introduction To Django
Introduction To DjangoIntroduction To Django
Introduction To DjangoJay Graves
 
Python for Financial Data Analysis with pandas
Python for Financial Data Analysis with pandasPython for Financial Data Analysis with pandas
Python for Financial Data Analysis with pandasWes McKinney
 
Advance OOP concepts in Python
Advance OOP concepts in PythonAdvance OOP concepts in Python
Advance OOP concepts in PythonSujith Kumar
 
Python Advanced – Building on the foundation
Python Advanced – Building on the foundationPython Advanced – Building on the foundation
Python Advanced – Building on the foundationKevlin Henney
 
Python Tricks That You Can't Live Without
Python Tricks That You Can't Live WithoutPython Tricks That You Can't Live Without
Python Tricks That You Can't Live WithoutAudrey Roy
 
Improving Python and Spark Performance and Interoperability: Spark Summit Eas...
Improving Python and Spark Performance and Interoperability: Spark Summit Eas...Improving Python and Spark Performance and Interoperability: Spark Summit Eas...
Improving Python and Spark Performance and Interoperability: Spark Summit Eas...Spark Summit
 
Web Development with Python and Django
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and DjangoMichael Pirnat
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsLinkedIn
 

Viewers also liked (19)

Photoshop Club
Photoshop ClubPhotoshop Club
Photoshop Club
 
Kamaelia Grey
Kamaelia GreyKamaelia Grey
Kamaelia Grey
 
Managing Creativity
Managing CreativityManaging Creativity
Managing Creativity
 
The Selfish Programmer
The Selfish ProgrammerThe Selfish Programmer
The Selfish Programmer
 
Timeshift Everything, Miss Nothing - Mashup your PVR with Kamaelia
Timeshift Everything, Miss Nothing - Mashup your PVR with KamaeliaTimeshift Everything, Miss Nothing - Mashup your PVR with Kamaelia
Timeshift Everything, Miss Nothing - Mashup your PVR with Kamaelia
 
RabbitMQ with python and ruby RuPy 2009
RabbitMQ with python and ruby RuPy 2009RabbitMQ with python and ruby RuPy 2009
RabbitMQ with python and ruby RuPy 2009
 
Descriptors In Python
Descriptors In PythonDescriptors In Python
Descriptors In Python
 
Messaging with RabbitMQ and AMQP
Messaging with RabbitMQ and AMQPMessaging with RabbitMQ and AMQP
Messaging with RabbitMQ and AMQP
 
Django introduction
Django introductionDjango introduction
Django introduction
 
Data Analysis and Statistics in Python using pandas and statsmodels
Data Analysis and Statistics in Python using pandas and statsmodelsData Analysis and Statistics in Python using pandas and statsmodels
Data Analysis and Statistics in Python using pandas and statsmodels
 
Django for Beginners
Django for BeginnersDjango for Beginners
Django for Beginners
 
Introduction To Django
Introduction To DjangoIntroduction To Django
Introduction To Django
 
Python for Financial Data Analysis with pandas
Python for Financial Data Analysis with pandasPython for Financial Data Analysis with pandas
Python for Financial Data Analysis with pandas
 
Advance OOP concepts in Python
Advance OOP concepts in PythonAdvance OOP concepts in Python
Advance OOP concepts in Python
 
Python Advanced – Building on the foundation
Python Advanced – Building on the foundationPython Advanced – Building on the foundation
Python Advanced – Building on the foundation
 
Python Tricks That You Can't Live Without
Python Tricks That You Can't Live WithoutPython Tricks That You Can't Live Without
Python Tricks That You Can't Live Without
 
Improving Python and Spark Performance and Interoperability: Spark Summit Eas...
Improving Python and Spark Performance and Interoperability: Spark Summit Eas...Improving Python and Spark Performance and Interoperability: Spark Summit Eas...
Improving Python and Spark Performance and Interoperability: Spark Summit Eas...
 
Web Development with Python and Django
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and Django
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
 

Similar to Embracing Concurrency for Fun and Simpler Code

Embracing Concurrency: For Fun, Utility & Simpler Code (Michael Sparks)
Embracing Concurrency: For Fun, Utility & Simpler Code (Michael Sparks)Embracing Concurrency: For Fun, Utility & Simpler Code (Michael Sparks)
Embracing Concurrency: For Fun, Utility & Simpler Code (Michael Sparks)LSx Festival of Technology
 
JSUG - Cocoon3 Student Project Idea by Reinhard Poetz and Steven Dolg
JSUG - Cocoon3 Student Project Idea by Reinhard Poetz and Steven DolgJSUG - Cocoon3 Student Project Idea by Reinhard Poetz and Steven Dolg
JSUG - Cocoon3 Student Project Idea by Reinhard Poetz and Steven DolgChristoph Pickl
 
Champ Pitch Celtic-Plus Event 2011
Champ Pitch Celtic-Plus Event 2011Champ Pitch Celtic-Plus Event 2011
Champ Pitch Celtic-Plus Event 2011vrt-medialab
 
respond_to :voice - the convergence of voice and web interfaces with Rails an...
respond_to :voice - the convergence of voice and web interfaces with Rails an...respond_to :voice - the convergence of voice and web interfaces with Rails an...
respond_to :voice - the convergence of voice and web interfaces with Rails an...jpalley
 
Multimedia Broadcasting Platform
Multimedia Broadcasting PlatformMultimedia Broadcasting Platform
Multimedia Broadcasting PlatformFrancois Lefebvre
 
What Mobile Developers Should Know
What Mobile Developers Should KnowWhat Mobile Developers Should Know
What Mobile Developers Should KnowMobiVentures
 
Http Jaoo.Com.Au Sydney 2008 File Path= Jaoo Aus2008 Slides Dave Thomas Lif...
Http   Jaoo.Com.Au Sydney 2008 File Path= Jaoo Aus2008 Slides Dave Thomas Lif...Http   Jaoo.Com.Au Sydney 2008 File Path= Jaoo Aus2008 Slides Dave Thomas Lif...
Http Jaoo.Com.Au Sydney 2008 File Path= Jaoo Aus2008 Slides Dave Thomas Lif...qedanne
 
Varkon Semiconductor
Varkon Semiconductor Varkon Semiconductor
Varkon Semiconductor Rajiv Parmar
 
Adobe MAX 2009: Design Considerations for Contextually Aware Solutions
Adobe MAX 2009: Design Considerations for Contextually Aware SolutionsAdobe MAX 2009: Design Considerations for Contextually Aware Solutions
Adobe MAX 2009: Design Considerations for Contextually Aware SolutionsAli Ivmark
 
Maemo 5 Architecture by Tapio Tolvanen
Maemo 5 Architecture by Tapio TolvanenMaemo 5 Architecture by Tapio Tolvanen
Maemo 5 Architecture by Tapio TolvanenAshley Walker
 
Internet Programming With Python Presentation
Internet Programming With Python PresentationInternet Programming With Python Presentation
Internet Programming With Python PresentationAkramWaseem
 
AppSalute & Marmalade SDK: одна игра на все платформы за 6 минут
AppSalute & Marmalade SDK: одна игра на все платформы за 6 минутAppSalute & Marmalade SDK: одна игра на все платформы за 6 минут
AppSalute & Marmalade SDK: одна игра на все платформы за 6 минутDevGAMM Conference
 
TheTrendwatch #06
TheTrendwatch #06TheTrendwatch #06
TheTrendwatch #06damoncb
 
Mozilla In Malaysia
Mozilla In MalaysiaMozilla In Malaysia
Mozilla In MalaysiaGen Kanai
 
Any DVD Converter for iPod
 Any DVD Converter for iPod Any DVD Converter for iPod
Any DVD Converter for iPodcrysatal16
 
Valtech Days 2009 Paris Presentation: WCM in 2010 and an intro to CQ5
Valtech Days 2009 Paris Presentation: WCM in 2010 and an intro to CQ5Valtech Days 2009 Paris Presentation: WCM in 2010 and an intro to CQ5
Valtech Days 2009 Paris Presentation: WCM in 2010 and an intro to CQ5David Nuescheler
 

Similar to Embracing Concurrency for Fun and Simpler Code (20)

Embracing Concurrency: For Fun, Utility & Simpler Code (Michael Sparks)
Embracing Concurrency: For Fun, Utility & Simpler Code (Michael Sparks)Embracing Concurrency: For Fun, Utility & Simpler Code (Michael Sparks)
Embracing Concurrency: For Fun, Utility & Simpler Code (Michael Sparks)
 
JSUG - Cocoon3 Student Project Idea by Reinhard Poetz and Steven Dolg
JSUG - Cocoon3 Student Project Idea by Reinhard Poetz and Steven DolgJSUG - Cocoon3 Student Project Idea by Reinhard Poetz and Steven Dolg
JSUG - Cocoon3 Student Project Idea by Reinhard Poetz and Steven Dolg
 
Champ Pitch Celtic-Plus Event 2011
Champ Pitch Celtic-Plus Event 2011Champ Pitch Celtic-Plus Event 2011
Champ Pitch Celtic-Plus Event 2011
 
respond_to :voice - the convergence of voice and web interfaces with Rails an...
respond_to :voice - the convergence of voice and web interfaces with Rails an...respond_to :voice - the convergence of voice and web interfaces with Rails an...
respond_to :voice - the convergence of voice and web interfaces with Rails an...
 
Multimedia Broadcasting Platform
Multimedia Broadcasting PlatformMultimedia Broadcasting Platform
Multimedia Broadcasting Platform
 
What Mobile Developers Should Know
What Mobile Developers Should KnowWhat Mobile Developers Should Know
What Mobile Developers Should Know
 
Http Jaoo.Com.Au Sydney 2008 File Path= Jaoo Aus2008 Slides Dave Thomas Lif...
Http   Jaoo.Com.Au Sydney 2008 File Path= Jaoo Aus2008 Slides Dave Thomas Lif...Http   Jaoo.Com.Au Sydney 2008 File Path= Jaoo Aus2008 Slides Dave Thomas Lif...
Http Jaoo.Com.Au Sydney 2008 File Path= Jaoo Aus2008 Slides Dave Thomas Lif...
 
Varkon Semiconductor
Varkon Semiconductor Varkon Semiconductor
Varkon Semiconductor
 
Adobe MAX 2009: Design Considerations for Contextually Aware Solutions
Adobe MAX 2009: Design Considerations for Contextually Aware SolutionsAdobe MAX 2009: Design Considerations for Contextually Aware Solutions
Adobe MAX 2009: Design Considerations for Contextually Aware Solutions
 
Maemo 5 Architecture by Tapio Tolvanen
Maemo 5 Architecture by Tapio TolvanenMaemo 5 Architecture by Tapio Tolvanen
Maemo 5 Architecture by Tapio Tolvanen
 
Internet Programming With Python Presentation
Internet Programming With Python PresentationInternet Programming With Python Presentation
Internet Programming With Python Presentation
 
AppSalute & Marmalade SDK: одна игра на все платформы за 6 минут
AppSalute & Marmalade SDK: одна игра на все платформы за 6 минутAppSalute & Marmalade SDK: одна игра на все платформы за 6 минут
AppSalute & Marmalade SDK: одна игра на все платформы за 6 минут
 
TheTrendwatch #06
TheTrendwatch #06TheTrendwatch #06
TheTrendwatch #06
 
Mozilla In Malaysia
Mozilla In MalaysiaMozilla In Malaysia
Mozilla In Malaysia
 
Any DVD Converter for iPod
 Any DVD Converter for iPod Any DVD Converter for iPod
Any DVD Converter for iPod
 
m4-out-20027
m4-out-20027m4-out-20027
m4-out-20027
 
m4-out-20027
m4-out-20027m4-out-20027
m4-out-20027
 
m4-out-20027
m4-out-20027m4-out-20027
m4-out-20027
 
Valtech Days 2009 Paris Presentation: WCM in 2010 and an intro to CQ5
Valtech Days 2009 Paris Presentation: WCM in 2010 and an intro to CQ5Valtech Days 2009 Paris Presentation: WCM in 2010 and an intro to CQ5
Valtech Days 2009 Paris Presentation: WCM in 2010 and an intro to CQ5
 
CRC MMB Projects and Tools
CRC MMB Projects and ToolsCRC MMB Projects and Tools
CRC MMB Projects and Tools
 

More from kamaelian

Sharing Data and Services Safely in Concurrent Systems using Kamaelia
Sharing Data and Services Safely in Concurrent Systems using KamaeliaSharing Data and Services Safely in Concurrent Systems using Kamaelia
Sharing Data and Services Safely in Concurrent Systems using Kamaeliakamaelian
 
Sociable Software
Sociable SoftwareSociable Software
Sociable Softwarekamaelian
 
Open Source at the BBC: When, Why, Why not & How
Open Source at the BBC: When, Why, Why not & HowOpen Source at the BBC: When, Why, Why not & How
Open Source at the BBC: When, Why, Why not & Howkamaelian
 
Open Source at the BBC
Open Source at the BBCOpen Source at the BBC
Open Source at the BBCkamaelian
 
Kamaelia - Fave 2005
Kamaelia - Fave 2005Kamaelia - Fave 2005
Kamaelia - Fave 2005kamaelian
 
SWP - A Generic Language Parser
SWP - A Generic Language ParserSWP - A Generic Language Parser
SWP - A Generic Language Parserkamaelian
 
Kamaelia - Networking Using Generators
Kamaelia - Networking Using GeneratorsKamaelia - Networking Using Generators
Kamaelia - Networking Using Generatorskamaelian
 
Scaling Streaming - Concepts, Research, Goals
Scaling Streaming - Concepts, Research, GoalsScaling Streaming - Concepts, Research, Goals
Scaling Streaming - Concepts, Research, Goalskamaelian
 
Kamaelia Internals
Kamaelia InternalsKamaelia Internals
Kamaelia Internalskamaelian
 
Building systems with Kamaelia
Building systems with KamaeliaBuilding systems with Kamaelia
Building systems with Kamaeliakamaelian
 
Free software: How does it work?
Free software: How does it work?Free software: How does it work?
Free software: How does it work?kamaelian
 

More from kamaelian (11)

Sharing Data and Services Safely in Concurrent Systems using Kamaelia
Sharing Data and Services Safely in Concurrent Systems using KamaeliaSharing Data and Services Safely in Concurrent Systems using Kamaelia
Sharing Data and Services Safely in Concurrent Systems using Kamaelia
 
Sociable Software
Sociable SoftwareSociable Software
Sociable Software
 
Open Source at the BBC: When, Why, Why not & How
Open Source at the BBC: When, Why, Why not & HowOpen Source at the BBC: When, Why, Why not & How
Open Source at the BBC: When, Why, Why not & How
 
Open Source at the BBC
Open Source at the BBCOpen Source at the BBC
Open Source at the BBC
 
Kamaelia - Fave 2005
Kamaelia - Fave 2005Kamaelia - Fave 2005
Kamaelia - Fave 2005
 
SWP - A Generic Language Parser
SWP - A Generic Language ParserSWP - A Generic Language Parser
SWP - A Generic Language Parser
 
Kamaelia - Networking Using Generators
Kamaelia - Networking Using GeneratorsKamaelia - Networking Using Generators
Kamaelia - Networking Using Generators
 
Scaling Streaming - Concepts, Research, Goals
Scaling Streaming - Concepts, Research, GoalsScaling Streaming - Concepts, Research, Goals
Scaling Streaming - Concepts, Research, Goals
 
Kamaelia Internals
Kamaelia InternalsKamaelia Internals
Kamaelia Internals
 
Building systems with Kamaelia
Building systems with KamaeliaBuilding systems with Kamaelia
Building systems with Kamaelia
 
Free software: How does it work?
Free software: How does it work?Free software: How does it work?
Free software: How does it work?
 

Recently uploaded

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 

Recently uploaded (20)

Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 

Embracing Concurrency for Fun and Simpler Code

  • 1. Embracing Concurrency for Fun, Utility & Simpler Code Michael Sparks BBC R&D, http://www.kamaelia.org/Home Ignite Leeds, Jan 2009
  • 2. Embracing Concurrency for Fun, Utility & Simpler Code Or “what we've learnt as a part of the Kamaelia project about making concurrency something that's fun and useful, and usable by novice and advanced developers alike... ...rather than a pain in the neck” Michael Sparks BBC R&D, http://www.kamaelia.org/Home Ignite Leeds, Jan 2009
  • 3. Why? Hardware finally going massively concurrent ... Opportunity! .... PS3, high end servers, trickling down to desktops, laptops) “many hands make light work” but Viewed as Hard ... do we just have crap tools? “And one language to in the darkness bind them” Problems ... can just we REALLY abandon 50 years of code for Erlang, Haskell and occam? Michael Sparks BBC R&D, http://www.kamaelia.org/Home
  • 4. Missing Something? Fundamental Control Structures ... in imperative languages number greater than 3! (despite what you get taught...!) Control Structure Traditional Abstraction Biggest Pain Points Sequence Function Global Var Selection Function Global Var Iteration Function Global Var Parallel Thread Shared Data Usually Skipped Lost or duplicate update are most common bugs This slide raises the point that teaching of imperative languages often misses out concurrency as a fundamental Michael Sparks construct, leaving a conceptual gap BBC R&D, http://www.kamaelia.org/Home for most developers
  • 5. Regarding using concurrency, what sort of applications are we talking about here? Desktop gsoc Novice Media APPS trainee 3rd Party Network Michael Sparks BBC R&D, http://www.kamaelia.org/Home
  • 6. Speak 'n Write Think backend P2P Whiteboard Programming Simple needed for (logo) ER DB Modeller P2P Radio Games Kids youtube/flickr Torrent 3D Systems type systems Compose Realtime Music Desktop gsoc UGC Paint App P2P Web Server Backend Secure “phone” Transcoder Social Net Vis Novice Media ... Shot Change APPS Detection MiniAxon trainee ScriptReader Mobile DVB MediaPreview Reframing on Mobile Reliable 3rd Party Podcasts Multicast Network Macro Sedna “record XMPP XMLDB everything” AWS Email & pubsub Web (Amazon) Spam Qt SMTP IRC Serving Gtk Greylisting ClientSide microblogging AIM Pop3Proxy Spam Tools Michael Sparks BBC R&D, http://www.kamaelia.org/Home
  • 7. Core Approach: Concurrent things with comms points Generally send messages Keep data private, don't share outbox inbox outbox inbox signal control signal control ... ... ... ... Michael Sparks BBC R&D, http://www.kamaelia.org/Home
  • 8. But I must share data? Use Software Transactional Memory ie version control for variables. 1. Check out the collection of values you wish to work on 2. Change them 3. Check them back in 4. If conflict/clash, go back to 1 Michael Sparks BBC R&D, http://www.kamaelia.org/Home
  • 9. Perspectives in APIs! (1/2) If you have concurrency it becomes natural to think in terms of 1st 2nd and 3rd 1st Person - I change my state person. This affects an API's structure, and can be vital for understanding it! This is one we've found that makes sense 2nd Person – YOU 3rd Person – want to me to do Bla should something do something (you send (I send a message) outbox inbox me a message) signal control ... ... Michael Sparks BBC R&D, http://www.kamaelia.org/Home
  • 10. Perspectives in APIs! (2/2) If you have concurrency it becomes natural to think in terms of 1st 2nd and 3rd private real methods person. This affects an API's structure, and can be vital for understanding it! This is one we've found that makes sense Messages sent Messages to public outboxes from public inboxes outbox inbox signal control Also, think Also, think ... ... about stdout about stdin Michael Sparks BBC R&D, http://www.kamaelia.org/Home
  • 11. Actor Systems Distinction can be unclear, private real methods potential source of ambiguity* Messages No outbox concept from public Possible issues with inboxes rate limiting* inbox Hardcodes recipient control in the sender ... *system dependent issue Michael Sparks BBC R&D, http://www.kamaelia.org/Home
  • 12. Advantages of outboxes No hardcoding of recipient allows: - Late Binding - Dynamic rewiring Concurrency Patterns as outbox inbox Reusable Code signal control ... a concurrency DSL ... ... Michael Sparks BBC R&D, http://www.kamaelia.org/Home
  • 13. A Core Concurrency DSL Pipeline(A,B,C) Graphline(A=A,B=B, C=C, linkages = {}) Tpipe(cond, C) Seq(A,B,C), PAR(), ALT() Backplane(“name”), PublishTo(“name”), SubscribeTo(“name”) Carousel(...) PureTransformer(...) StatefulTransformer(...) PureServer(...) MessageDemuxer(...) Source(*messages) NullSink Some of these are work in progress – they've been identified as useful, but not implemented as chassis, yet Michael Sparks BBC R&D, http://www.kamaelia.org/Home
  • 14. Pipeline Example Pipeline( MyGamesEventsComponent(up=quot;pquot;, down=quot;lquot;, left=quot;aquot;, right=quot;squot;), BasicSprite(quot;cat.pngquot;, name = quot;catquot;, border=40), ).activate() MyGames Events Component Basic Sprite Michael Sparks BBC R&D, http://www.kamaelia.org/Home
  • 15. Graphline Example Graphline( NEXT = Button(...), PREVIOUS = Button(...), PREVIOUS NEXT FIRST = Button(...), (button) (button) LAST = Button(...), CHOOSER = Chooser(...), FIRST LAST IMAGE = Image(...), (button) (button) ... ).run() Chooser Image Michael Sparks BBC R&D, http://www.kamaelia.org/Home
  • 16. Server Example data from user data Socket handler Main to Server Core user Created at runtime to handle the connection Remote Protocol Handler Factory User Protocol handler Michael Sparks BBC R&D, http://www.kamaelia.org/Home
  • 17. Server Example You therefore need to provide this bit. Main Server Core Protocol Handler Factory Michael Sparks BBC R&D, http://www.kamaelia.org/Home
  • 18. Server Example from Kamaelia.Chassis.ConnectedServer import ServerCore from Kamaelia.Util.PureTransformer import PureTransformer def greeter(*argv, **argd): return PureTransformer(lambda x: quot;helloquot; +x) class GreeterServer(ServerCore): protocol=greeter port=1601 GreeterServer().run() Michael Sparks BBC R&D, http://www.kamaelia.org/Home
  • 19. Backplane Example # Streaming Server for raw DVB of Radio 1 Backplane(“Radio”).activate() Pipeline( DVB_Multiplex(850.16, [6210], feparams), # RADIO ONE PublishTo(quot;RADIOquot;), ).activate() def radio(*argv,**argd): return SubscribeTo(“RADIO”) ServerCore(protocol=radio, port=1600).run() Michael Sparks BBC R&D, http://www.kamaelia.org/Home
  • 20. Thank you for listening! If you have questions, grab me later :-) Michael Sparks BBC R&D, http://www.kamaelia.org/Home