Domain-Specific Languages with Scala

  • Cyrille ArthoEmail author
  • Klaus Havelund
  • Rahul Kumar
  • Yoriyuki Yamagata
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 9407)


Domain-Specific Languages (DSLs) are often classified into external and internal DSLs. An external DSL is a stand-alone language with its own parser. An internal DSL is an extension of an existing programming language, the host language, offering the user of the DSL domain-specific constructs as well as the constructs of the host language, thus providing a richer language than the DSL itself. In this paper we report on experiences implementing external as well as internal formal modeling DSLs with the Scala programming language, known in particular for its support for defining DSLs. The modeling languages include monitoring logics, a testing language, and a general purpose SysML inspired modeling language. We present a systematic overview of advantages and disadvantages of each option.


External and internal domain-specific language DSL Scala Modeling Programming Language design Evaluation 


  1. 1.
  2. 2.
    Artho, C.V., Biere, A., Hagiya, M., Platon, E., Seidl, M., Tanabe, Y., Yamamoto, M.: Modbat: A model-based API tester for event-driven systems. In: Bertacco, V., Legay, A. (eds.) HVC 2013. LNCS, vol. 8244, pp. 112–128. Springer, Heidelberg (2013) CrossRefGoogle Scholar
  3. 3.
    Barringer, H., Groce, A., Havelund, K., Smith, M.: Formal analysis of log files. J. Aerosp. Comput. Inf. Commun. 7(11), 365–390 (2010)CrossRefGoogle Scholar
  4. 4.
    Barringer, H., Havelund, K.: TraceContract: A scala DSL for trace analysis. In: Butler, M., Schulte, W. (eds.) FM 2011. LNCS, vol. 6664, pp. 57–72. Springer, Heidelberg (2011) CrossRefGoogle Scholar
  5. 5.
    Barringer, H., Havelund, K., Kurklu, E., Morris, R.: Checking flight rules with TraceContract: Application of a Scala DSL for trace analysis. In: Scala Days 2011. Stanford University, California (2011)Google Scholar
  6. 6.
    Bodden, E.: MOPBox: A library approach to runtime verification. In: Khurshid, S., Sen, K. (eds.) RV 2011. LNCS, vol. 7186, pp. 365–369. Springer, Heidelberg (2012) CrossRefGoogle Scholar
  7. 7.
    Bray, T., Paoli, J., Sperberg-McQueen, M., Maler, E., Yergeau, F.: Extensible markup language (XML). World Wide Web Consortium Recommendation REC-xml-19980210 (1998)Google Scholar
  8. 8.
    Bruneton, E., Lenglet, R., Coupaye, T.: ASM: a code manipulation tool to implement adaptable systems. In: Adaptable and Extensible Component Systems, Grenoble, France (2002)Google Scholar
  9. 9.
    Forgy, C.: Rete: A fast algorithm for the many pattern/many object pattern match problem. Artif. Intell. 19, 17–37 (1982)CrossRefGoogle Scholar
  10. 10.
    Fowler, M., Parsons, R.: Domain-Specific Languages. Addison-Wesley, Boston (2010)Google Scholar
  11. 11.
    Fusco, M.: Hammurabi–a Scala rule engine. In: Scala Days 2011. Stanford University, California (2011)Google Scholar
  12. 12.
    Gansner, E., North, S.: An open graph visualization system and its applications to software engineering. Softw. Pract. Exper. 30(11), 1203–1233 (2000)CrossRefzbMATHGoogle Scholar
  13. 13.
  14. 14.
    Havelund, K.: Data automata in Scala. In: Leucker, M., Wang, J. (eds.) Proceedings of 8th International Symposium on Theoretical Aspects of Software Engineering (TASE 2014), Changsha, China. IEEE Computer Society Press (2014)Google Scholar
  15. 15.
    Havelund, K.: Monitoring with data automata. In: Margaria, T., Steffen, B. (eds.) ISoLA 2014, Part II. LNCS, vol. 8803, pp. 254–273. Springer, Heidelberg (2014) Google Scholar
  16. 16.
    Havelund, K.: Rule-based runtime verification revisited. Softw. Tools Technol. Transf. (STTT) 17(2), 143–170 (2015)CrossRefGoogle Scholar
  17. 17.
    Havelund, K., Joshi, R.: Experience with rule-based analysis of spacecraft logs. In: Artho, C., Ölveczky, P.C. (eds.) FTSCS 2014. CCIS, vol. 476, pp. 1–16. Springer, Heidelberg (2015) Google Scholar
  18. 18.
    Hoare, C.: Communicating sequential processes. Commun. ACM 26(1), 100–106 (1983)CrossRefGoogle Scholar
  19. 19.
    Jakob, F.: SugarScala: Syntactic extensibility for Scala. Master’s thesis, Technische Universität Darmstadt (2014)Google Scholar
  20. 20.
    Link, J., Fröhlich, P.: Unit Testing in Java: How Tests Drive the Code. Morgan Kaufmann Publishers Inc., Sebastopol (2003)Google Scholar
  21. 21.
    Mernik, M., Heering, J., Sloane, A.: When and how to develop domain-specific languages. ACM Comput. Surv. 37(4), 316–344 (2005)CrossRefGoogle Scholar
  22. 22.
    Odersky, M., Spoon, L., Venners, B.: Programming in Scala: A Comprehensive Step-by-step Guide, 2nd edn. Artima Inc., USA (2010)Google Scholar
  23. 23.
  24. 24.
  25. 25.
    Rompf, T., Amin, N., Moors, A., Haller, P., Odersky, M.: Scala-virtualized: linguistic reuse for deep embeddings. High. Order Symbolic Comput. 25, 1–43 (2013)Google Scholar
  26. 26.
  27. 27.
  28. 28.
    Scala macros:
  29. 29.
    Stolz, V., Huch, F.: Runtime verification of concurrent Haskell programs. In: Proceedings of the 4th International Workshop on Runtime Verification (RV 2004), ENTCS, vol. 113, pp. 201–216. Elsevier (2005)Google Scholar
  30. 30.
    Venners, B.: ScalaTest (2014).

Copyright information

© Springer International Publishing Switzerland 2015

Authors and Affiliations

  • Cyrille Artho
    • 1
    Email author
  • Klaus Havelund
    • 2
  • Rahul Kumar
    • 2
  • Yoriyuki Yamagata
    • 1
  1. 1.AISTAmagasakiJapan
  2. 2.Jet Propulsion LaboratoryCalifornia Institute of TechnologyPasadenaUSA

Personalised recommendations