Skip to main content

Declarative Programming with Algebra

  • Conference paper
  • First Online:
  • 647 Accesses

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 9613))

Abstract

The Algebra of Communicating Processes (ACP) is a theory that views sequences and choices as mathematical operations: multiplication and addition. Based on these base constructs others are defined, such as parallel merge, interruption and disruption.

Conventional programming languages may be enriched with ACP features, to gain declarative expressiveness. We have done this in SubScript, an extension to the Scala language. SubScript has high level support for sequences, choices and iterations in a style similar to parser generator languages. It also offers parallel composition operations, such as and- and or- parallelism, and dataflow.

The declarative style is also present in the way various execution modes are supported. Conventional programming languages often require some boilerplate code to run things in the background, in the GUI thread, or as event handlers. SubScript supports the same execution modes, but with minimal boilerplate. It is also easy to compose programs from blocks having different execution modes.

This paper introduces ACP and SubScript; it briefly describes the current implementation, and gives several examples.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Notes

  1. 1.

    This paper contains some text fragments literally copied or adapted from the predecessor paper.

  2. 2.

    This description of ACP has largely been taken from Wikipedia.

  3. 3.

    There is also a semicolon to denote sequences. SubScript has a similar semicolon inference for line breaks as Scala.

  4. 4.

    We can combine this way any kind of item for which implicit conversions to scripts are in scope; this yields an algebra of general items rather than just of processes.

  5. 5.

    In general Scala’s operator precedence rules are followed, except for the dataflow operators; in Scala white space denotes function application; in SubScript it is sequential composition.

  6. 6.

    Library scripts that refine into such special processes, may be more readable. For the time being we want a minimal set of new keywords.

  7. 7.

    For convenience here is an implicit value so that it may be left out of parameter lists that have an implicit formal parameter of the node’s type.

  8. 8.

    In annotations there is implicit instead of here. Thus @gui: is equivalent to @gui(there).

  9. 9.

    These operators start with a percent sign; they are members of a larger family of operators that can suspend and resume operands. These operators are not meant to be memorized; rather they may be encapsulated in higher level scripts with descriptive names.

  10. 10.

    is also valid syntax; this requires an implicit conversion to be in scope that turns the number into a script call.

  11. 11.

    A useful definition for (see Sect. 4.9) triggered several syntax changes. E.g. rectangular brackets replaced parentheses to delimit process expressions. Script lambda’s are now also written between rectangular brackets. Script terms may now have the form (s) or {s}, with s a Scala value; such terms are method calls or script calls, possibly after implicit conversion. Normal code fragments had the form {s}; this became {!s!}.

  12. 12.

    http://lihaoyi.github.io/fastparse/.

  13. 13.

    Subscript web site: http://subscript-lang.org.

References

  1. Thati, P., Agha, G.: An algebraic theory of actors and its application to a simple object-based language. In: Owe, O., Krogdahl, S., Lyche, T. (eds.) From Object-Orientation to Formal Methods. LNCS, vol. 2635, pp. 26–57. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

  2. Baeten, J.C.M.: A brief history of process algebra. Theor. Comput. Sci. 335, 131–146 (2005)

    Article  MathSciNet  MATH  Google Scholar 

  3. Boussinot, F.: Reactive c: an extension of c to program reactive systems. Softw. Pract. Experiance 21(4), 401–428 (1991)

    Article  Google Scholar 

  4. Boussinot, F., Susini, J.F.: The sugarcubes tool box. In: Nets of Reactive Processes Implementation

    Google Scholar 

  5. van Delft, A.: Dataflow constructs for a language extension based on the algebra of communicating processes. In: Proceedings of 4th Workshop on Scala, SCALA 2013. ACM (2013)

    Google Scholar 

  6. van Delft, A.: Some new directions for ACP research. CoRR abs/1504.03719 (2015). http://arxiv.org/abs/1504.03719

  7. Gaspari, M., Zavattaro, G.: An algebra of actors. In: Ciancarini, P., Fantechi, A., Gorrieri, R. (eds.) FMOODS, IFIP Conference Proceedings, vol. 139. Kluwer (1999)

    Google Scholar 

  8. Goeman, H.: Towards a theory of (self) applicative communicating processes: a short note. Inf. Process. Lett. 34(3), 139–142 (1990)

    Article  MathSciNet  MATH  Google Scholar 

  9. Hoare, C.: Communicating sequential processes. ACM Comput. Surv. 7(1), 80–112 (1985)

    MathSciNet  MATH  Google Scholar 

  10. Johnson, S.: Yacc: Yet another compiler- compiler. Technical report, Bell Laboratories (1979)

    Google Scholar 

  11. Milner, R.: A Calculus of Communicating Systems. Springer-Verlag New York Inc., Secaucus (1982)

    MATH  Google Scholar 

  12. Milner, R., Parrow, J., Walker, D.: A calculus of mobile processes, part i. Inf. Comput. 100, 1–40 (1989)

    Article  MathSciNet  MATH  Google Scholar 

  13. Wang, Y.: Fully abstract game semantics for actors. CoRR abs/1403.6563 (2014)

    Google Scholar 

  14. Wills, P.: No more regular expressions. Scala Exchange, Skills Matter, London (2014)

    Google Scholar 

Download references

Acknowledgement

We thank the referees and especially the shepherd for their useful suggestions and other comments.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Andre van Delft .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2016 Springer International Publishing Switzerland

About this paper

Cite this paper

van Delft, A., Kmetyuk, A. (2016). Declarative Programming with Algebra. In: Kiselyov, O., King, A. (eds) Functional and Logic Programming. FLOPS 2016. Lecture Notes in Computer Science(), vol 9613. Springer, Cham. https://doi.org/10.1007/978-3-319-29604-3_15

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-29604-3_15

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-29603-6

  • Online ISBN: 978-3-319-29604-3

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics