\section{Introduction}
\label{sec:introduction}
A fundamental challenge in modern computing is the
establishment of effective and widely applicable
development methodologies for 
distributed applications, comparable in their
usability to the traditional methodologies for
non-distributed software built on, among others,
core UML diagrams and object-oriented programming
languages. Though a middle-to-large-scale
application is almost always distributed nowadays,
and in spite of the presence of an accelerating
infrastructural support for portable and reliable
distributed components through e.g. clouds,
software developers (including architects,
designers and programmers alike) are still lacking
well-established development methodologies for
building systems centring on distributed processes
and their interactions. For example, there is no
central computational abstractions (comparable to
classes and objects) for capturing distributed
interactions usable throughout development stages;
%, in particular for both modelling and programming; 
no UML diagrams are widely in use for modelling
distributed applications;
%  (even though a large-scale
% enterprise software {\em is} almost always
% distributed and messaging-based);
no major programming
languages offer high-level, type-safe
communication primitives,
leaving treatment of communications to
low-level APIs.
In short, we are yet to
have a general and tangible framework for
developing distributed, communication-centred
software systems.

We believe that one of the major reasons why it is
so hard to even conceive an effective software
development framework for distributed systems,
is the lack of 
a core {\em descriptive framework}, with a uniform conceptual
and 
formal foundation and usable throughout
development stages.  To illustrate this point, let us briefly examine
the descriptive framework in one of the traditional development
methodologies for non-distributed software, underpinned by UML
diagrams and object-oriented programming.  In this framework, the
description of computation centres on {\em objects} (which belong to
{\em classes}) and {\em operations on objects}, a representative
paradigm of sequential computation.
%This paradigm is at the centre of a
%central UML diagram, Class Diagram:
Class Diagram in UML and all associated core modelling diagrams such
as Sequence Diagrams and State Charts follow this paradigm; and it is
supported by many high-level programming languages, including Java,
C++, C$\sharp$ and Python.\footnote{Having a different origin,
  functional languages such as Haskell and ML share a common
  paradigm, data belonging to data types and operations on
  data.}

%% \PARA{Types and Logics in Development Methodologies.}

% In further examination, %% we may observe that
% the practical significance of this traditional (and highly
% successful) descriptive framework comes from not only its
% offering powerful abstraction but also its inducing a
% fundamental notion in modular software development, {\em
%   interface of subsystems}, in the form of the familiar
% {\em APIs} (which are essentially type signatures for
% objects), accompanied by efficient interface validation.
% On its basis, in a widely practiced modelling methodology
% known as Design-by-Contracts (DbC), this type signature is
% further enriched by {\em assertions}, using an assertion
% language such as OCL, offering a refined interface.

Types and logics, two linchpins of theories of
computing, play fundamental and mutually
enriching roles in this traditional descriptive
framework.  Types, as seen in the now familiar
APIs, offer a basic notion of {\em interface} of
subsystems, tightly coupled with the central
computational dynamics of this paradigm,
i.e.~invoking objects and
returning results. This dynamics is embodied in
high-level programming
primitives, which in turn enables cheap and
compositional static validation at the compile
time \cite{DamasMilner,MILNERpoly}, leading to
modular software development.
%%
Types are also a basis of logical specifications.  In the widely
practiced modelling framework known as Design-by-Contracts (DbC)
\cite{DbCMeyer}, assertions elaborate types with
predicates. Assertions are expressive, allowing us to pinpoint
practically any property one wishes to specify \cite{HOARE}, though
automatic validation is not always possible. Assertions offer a
refined form of modular software development through compositional
behavioural contracts \cite{Jones83,LeavensBaker99,BarnettLeino04}.

In the light of this well-established (and highly
successful) engineering framework in the
traditional development methodology, a natural
question is whether we can build its analogue in
the world of distributed processes, centred on
common high-level abstraction for modelling and
programming, and aiding modular software
development on a rigorous theoretical basis.
%% , in spite of the current
%% lack of all major elements in the development process
%% --- core modelling framework, high-level language
%% primitives, and a clear notion of interface to aid
%% modular software development.
%% \PARA{Scribbling Interaction with a Formal Foundation.}

This paper illustrates our ongoing endeavour to build a core
descriptive framework and the associated development
environment for large-scale distributed systems based on the
$\pi$-calculus \cite{MilnerR:calmp1}, centring on a simple
language for describing interactions, called \scribble.  A
key insight is that a distributed system can be naturally
and effectively articulated as a collection of possibly
overlapping structured conversations, and that the
structures of these conversations, or {\em protocols}, can
be clearly and accurately described using a type theory of
the $\pi$-calculus, called {\em session types}
\cite{THK,honda.vasconcelos.kubo:language-primitives,HYC08}.
In Section 2, we discuss how protocols
%% for structured sessions 
play a fundamental role for 
modelling and 
building
distributed applications in diverse domains.  In
Section~3, we introduce \scribble.  In Section~4, we present
larger description examples in {\scribble} from real-world
use cases. Section~5 outlines a theoretical basis of
\scribble. Section~6 discusses a development framework.
Section~7 concludes with related and
future work.

% The understanding of structured sessions and their
% protocols as key elements for modelling and
% building distributed applications has been observed
% through an extensive dialogue with the practice
% of
% large-scale distributed systems. 
% In the subsequent
% sections, we shall illustrate the background and key
% technical ideas of {\scribble} and the associated
% development framework.
% A session type describes a scenario of interactions, or
% a protocol, of a structured conversation among two or
% more parties as a type signature: if every participant
% obeys his/her constraint induced by this type signature,
% we can formally ensure their conversation as a whole
% follows the stipulated scenario.  On the basis of types,
% assertions offer more fine-grained specifications,
% constraining possible values, future branching paths in
% conversations, and recursions.  The framework promotes a
% formally founded, and highly structured, development
% methodology for distributed applications, starting from
% high-level models to design and implementation to static
% checking to runtime validation.
%% A key insight is that the execution of a large-scale
%% distributed system naturally consists of numerous
%% structured conversations (or {\em sessions}) whose
%% protocols can be clearly and accurately specified
%% using a theory of types for the $\pi$-calculus,
%% called {\em session types}.  
% Observe that it is
% generally unfeasible to divide a distributed
% application into disjoint subsytems (for example
% Alice's interactions with banks will overlap with
% mine with travel agency, obeying distinct protocols
% but overlapping at the participant Alice): a naive
% application of the divide-and-conquer method, often
% effective for simple parallel algorithms, does not
% work.
% The significance of structured sessions as a
% means to describe, build and understand distributed
% systems has been observed through an extensive
% dialogue with industry colleagues working on
% large-scale distributed systems, and will be 
% illustrated in the following sections through
% examples.
% Intuitively speaking, a session type describes a
% scenario of interactions in a logical unit of a
% conversation among two or more parties as a type
% signature: if every participant obeys his/her
% constraint induced by a global type, we can formally
% ensure their conversation as a whole follows the
% stipulated scenario.  On the basis of types,
% assertions offer more fine-grained specifications,
% constraining possible values, future branching paths
% in conversations, and recursions. Session types were
% born from a theoretical study on the
% $\pi$-calculus.~\footnote{Protocols themselves are an
%   old idea in network engineering: their
%   formalisation as types for comumunicating processes
%   is new and forms a basis of our work reported in
%   this paper.}  Their mathematical properties have
% been extensively studied during the last decade.
% %% Having a well-understood formal foundation is
% %% important since it offers a unifying and rigorous
% %% basis for diverse development efforts. For example,
% %% it
% A well-understood formal foundation
% offers a common technical footing for designing
% language primitives for modelling and programming
% languages, with clear and rigorous semantics; for
% developing compositional static checkers for
% protocols; for correct implementation of runtime and
% compilers for communications; and for vaidating the
% correspondence between specifications (or models) and
% executable programs.  %% The framework promotes a
% %% formally founded, and highly structured, development
% %% methodology for distributed applications, starting
% %% from high-level models to design and implementation
% %% to static checking to runtime validation.
% Our enterprise centres on a description language for
% communication-centred software, called {\scribble}
% \cite{ScribbleDevelopmentToolSite}, 
% with associated software tools.  {\scribble} was born
% as an expressive, formally well-founded, and
% developer-friendly descriptive language, built on 
% the session type theory and $\pi$-calculus.
%% \PARA{Outline.}
%% In the remainder,
%  we shall illustrate this language and its
% associated framework through use cases,
% including financial protocols, web services and large-scale
% cyberinfrastructure.
% Section~2 illustrates the background through
% motivating use cases from practice.
% , centring 
% on the notion of 
% {\em protocols}. 
%% a central concept of the proposed framework,
%% {\em protocols}. 
% % , cultivated through an extensive
% % dialogue with industry practice
% A key insight is that a
% distributed system can naturally be articulated as a
% collection of possibly overlapping structured
% conversations, and that the structures of these conversations,
% or {\em protocols}, can be clearly and accurately
% described using a type theory of the $\pi$-calculus,
% called {\em session types}
% \cite{THK,honda.vasconcelos.kubo:language-primitives,HYC08}.
% , cultivated through an extensive
% dialogue with industry practice
