Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Type Me If You Can

Imperial ACM
October 25, 2013

Type Me If You Can

Imperial ACM

October 25, 2013
Tweet

More Decks by Imperial ACM

Other Decks in Research

Transcript

  1. type: me Rumyana_Neykova = {country: ‘Bulgaria’, bachelor: ‘Computer Science’, MSc:

    ‘Software Engineering’ } me.loves = [facts, racket_sports, travel]  If fact.useless and fact.funny: me.loves[facts] = fact  if you.loves.contains(‘squash’): you.contact(me)  [me.travel() for day in free_days]
  2. Observation 1: Types  One of the computing most successful

    concepts  Codify the structure of the data  Serve as a fundamental unit of compositionality  Allow easy error prevention  Appears from the oldest to the newest programming languages Robin Milner: Types are the yeast of computer programming: they make it digestible !!!
  3. Then…  Can we have types that describe the communication,

    not the computation ? Distributed Systems Types Session Types  How to formally abstract/specify and practically implement/control communications?
  4. Building blocks  Primitives – to build the types 

    send, receive (well , there are few more, but it boils down to these two )  Context – to be checked by the type system  protocols – describe the communication between processes
  5. Defining the type  Separate the communication into sessions 

    Each process has a type in a session, defined by the interactions on the session channel
  6. A Protocol Alice Seller title quote Address Date ok quit

     Protocol: Buyer-Seller  Description: Alice buying a book
  7. Wait a minute! What if it is more than 2?

    Alice Seller Bob Carol quote Address Date quote ok ok Delegate T
  8. How does it work?  Step 1: Write a Global

    Type  Step 2: Write Local Programs  Step 3: Project and Type Check Locally
  9. Session Types in a Nutshell “…Session Types structure a series

    of interactions in a simple and concise syntax and ensure type safe communication.”
  10. What is type safe communication? • Communication follow the described

    protocol • No communication mismatch Communication Safety Session Fidelity • No deadlock/ stuck in a session Progress
  11. How does it work?  Step 1: Write a Global

    Type  Step 2: Write Local Programs  Step 3: Project and Type Check Locally
  12. Session types: Implications Programming Language Runtime Architecture  Augmented with

    communication primitives (send, receive, choice…)  Messages are augmented with communication header (sender, receiver, label, conditions…)  Capture the global communication, centering on interactions
  13. Applications…food for though Type are used for early error detection

    Types are used to optimise the memory layout Types are used as a guidance when we design programs
  14. There is so much garbage here  Session types prevent

    cluttering the network with nonsense messages.
  15. Hey, same direction ..will give you a ride. Session types

    can be used to optimise the communication flow, grouping messages together
  16. Lost in Translation Session types can be used for Testable

    architectures - where the specification match the implementation
  17. Ok, let’s summarize  Organize the whole communication into sessions(communication

    protocols)  The result is that every distributed object can be given a type inside a session  A checker (a type system) can judge whether 2 or more objects are compatible to communicate
  18. Ok … why we need types again?  Having a

    context allows to control the communication  Having granularity allows to put constraints on the right place  Early error detection is much cheaper  More documented code  Nice abstraction means easy programming – you program with send and receive (no threads, sockets, channels)
  19. What my PhD is about When the endpoints are not

    typed… the communication assurance is lost 
  20. What my PhD is about? Transport Monitor Monitor Monitor PAlice

    PCarol PBob Attach(Embed) monitor to each application (CC). Monitors check that every incoming and outgoing message is correct w.r.t. the specifications via message header. ... Sender: you Receiver: me Label: Hello …
  21. Case Study: OOI Usage: Integrate real-time data acquisition, processing and

    data storage for ocean research,… OOI aims: to deploy an infrastructure (global network) to expand the scientists’ ability to remotely study the ocean
  22. Checking the ocean Challenge: It is all RPC , how

    and why to transform it into conversation Collaboration: build conversation layer on top of OOI network to guarantee global safety