Skip to main content

JavaScript as an Embedded DSL

  • Conference paper
ECOOP 2012 – Object-Oriented Programming (ECOOP 2012)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 7313))

Included in the following conference series:

Abstract

Developing rich web applications requires mastering different environments on the client and server sides. While there is considerable choice on the server-side, the client-side is tied to JavaScript, which poses substantial software engineering challenges, such as moving or sharing pieces of code between the environments. We embed JavaScript as a DSL in Scala, using Lightweight Modular Staging. DSL code can be compiled to JavaScript or executed as part of the server application. We use features of the host language to make client-side programming safer and more convenient. We use gradual typing to interface typed DSL programs with existing JavaScript APIs. We exploit a selective CPS transform already available in the host language to provide a compelling abstraction over asynchronous callback-driven programming in our DSL.

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

Access this chapter

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 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

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Abadi, M., Cardelli, L., Pierce, B., Plotkin, G.: Dynamic typing in a statically typed language. ACM Trans. Program. Lang. Syst. 13, 237–268 (1991)

    Article  Google Scholar 

  2. Ahmed, A., Findler, R.B., Matthews, J., Wadler, P.: Blame for all. In: Proceedings for the 1st Workshop on Script to Program Evolution, STOP 2009, pp. 1–13. ACM, New York (2009)

    Chapter  Google Scholar 

  3. Bierman, G., Meijer, E., Torgersen, M.: Adding Dynamic Types to C\(^\sharp\). In: D’Hondt, T. (ed.) ECOOP 2010. LNCS, vol. 6183, pp. 76–100. Springer, Heidelberg (2010)

    Chapter  Google Scholar 

  4. Brown, K., Sujeeth, A., Lee, H., Rompf, T., Chafi, H., Olukotun, K.: A heterogeneous parallel framework for domain-specific languages. In: 20th International Conference on Parallel Architectures and Compilation Techniques, PACT (2011)

    Google Scholar 

  5. Carette, J., Kiselyov, O., Shan, C.-C.: Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages. J. Funct. Program. 19, 509–543 (2009)

    Article  MathSciNet  MATH  Google Scholar 

  6. Chafi, H., DeVito, Z., Moors, A., Rompf, T., Sujeeth, A.K., Hanrahan, P., Odersky, M., Olukotun, K.: Language Virtualization for Heterogeneous Parallel Computing. Onward! (2010)

    Google Scholar 

  7. Chafi, H., Sujeeth, A.K., Brown, K.J., Lee, H., Atreya, A.R., Olukotun, K.: A domain-specific approach to heterogeneous parallelism. In: Proceedings of the 16th ACM Symposium on Principles and Practice of Parallel Programming, PPoPP (2011)

    Google Scholar 

  8. https://github.com/clojure/clojurescript/wiki

  9. http://jashkenas.github.com/coffee-script/

  10. Cooper, E., Lindley, S., Wadler, P., Yallop, J.: Links: Web Programming Without Tiers. In: de Boer, F.S., Bonsangue, M.M., Graf, S., de Roever, W.-P. (eds.) FMCO 2006. LNCS, vol. 4709, pp. 266–296. Springer, Heidelberg (2007)

    Chapter  Google Scholar 

  11. Cooper, E., Lindley, S., Wadler, P., Yallop, J.: The Essence of Form Abstraction. In: Ramalingam, G. (ed.) APLAS 2008. LNCS, vol. 5356, pp. 205–220. Springer, Heidelberg (2008)

    Chapter  Google Scholar 

  12. Danvy, O., Filinski, A.: Abstracting control. In: Proceedings of the 1990 ACM Conference on LISP and Functional Programming, LFP 1990, pp. 151–160. ACM, New York (1990)

    Chapter  Google Scholar 

  13. Danvy, O., Filinski, A.: Representing control: A study of the cps transformation. Mathematical Structures in Computer Science 2(4), 361–391 (1992)

    Article  MathSciNet  MATH  Google Scholar 

  14. http://www.dartlang.org/

  15. Flanagan, D.: (2011), https://github.com/davidflanagan/javascript6_examples/blob/master/examples/21.06.koch.js

  16. Flanagan, D.: JavaScript: The Definitive Guide, 6th edn. O’Reilly Media, Inc. (2011)

    Google Scholar 

  17. http://code.google.com/webtoolkit/

  18. Hofer, C., Ostermann, K., Rendel, T., Moors, A.: Polymorphic embedding of dsls. In: Proceedings of the 7th International Conference on Generative Programming and Component Engineering, GPCE 2008, pp. 137–148. ACM, New York (2008)

    Chapter  Google Scholar 

  19. Kats, L.C.L., Visser, E.: The Spoofax language workbench. Rules for declarative specification of languages and IDEs. In: Rinard, M. (ed.) Proceedings of the 25th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2010, Reno, NV, USA, October 17-21, pp. 444–463 (2010)

    Google Scholar 

  20. Khoo, Y.P., Hicks, M., Foster, J.S., Sazawal, V.: Directing javascript with arrows. SIGPLAN Not. 44, 49–58 (2009)

    Google Scholar 

  21. Lee, H., Brown, K., Sujeeth, A., Chafi, H., Rompf, T., Odersky, M., Olukotun, K.: Implementing domain-specific languages for heterogeneous parallel computing. IEEE Micro. 31, 42–53 (2011)

    Article  Google Scholar 

  22. Meyerovich, L.A., Guha, A., Baskin, J., Cooper, G.H., Greenberg, M., Bromfield, A., Krishnamurthi, S.: Flapjax: a programming language for ajax applications. In: Proceedings of the 24th ACM SIGPLAN Conference on Object Oriented Programming Systems Languages and Applications, OOPSLA 2009, pp. 1–20. ACM, New York (2009)

    Chapter  Google Scholar 

  23. Moors, A., Piessens, F., Odersky, M.: Generics of a Higher Kind. ACM SIGPLAN Notices 43, 423–438 (2008)

    Article  Google Scholar 

  24. Moors, A., Rompf, T., Haller, P., Odersky, M.: Scala-virtualized. In: PEPM 2012 (2012)

    Google Scholar 

  25. Odersky, M., Zenger, M.: Scalable Component Abstractions. In: Proceedings of OOPSLA 2005 (2005)

    Google Scholar 

  26. Petříček, T., Syme, D.: F# web tools: Rich client/server web applications in f#

    Google Scholar 

  27. Rompf, T., Maier, I., Odersky, M.: Implementing First-Class Polymorphic Delimited Continuations by a Type-Directed Selective CPS-Transform. In: Proceedings of the 14th ACM SIGPLAN International Conference on Functional Programming. ACM, New York (2009)

    Google Scholar 

  28. Rompf, T., Odersky, M.: Lightweight Modular Staging: A Pragmatic Approach to Runtime Code Generation and Compiled DSLs. In: GPCE (2010)

    Google Scholar 

  29. Rompf, T., Sujeeth, A.K., Lee, H., Brown, K.J., Chafi, H., Oderksy, M., Olukotun, K.: Building-blocks for performance oriented DSLs. In: Electronic Proceedings in Theoretical Computer Science (2011)

    Google Scholar 

  30. http://scalagwt.github.com/

  31. Siek, J.G., Taha, W.: Gradual typing for functional languages. In: Scheme and Functional Programming Workshop (September 2006)

    Google Scholar 

  32. Siek, J.G., Taha, W.: Gradual Typing for Objects. In: Bateni, M. (ed.) ECOOP 2007. LNCS, vol. 4609, pp. 2–27. Springer, Heidelberg (2007)

    Chapter  Google Scholar 

  33. Sujeeth, A.K., Lee, H., Brown, K.J., Rompf, T., Wu, M., Atreya, A.R., Odersky, M., Olukotun, K.: OptiML: an implicitly parallel domain-specific language for machine learning. In: Proceedings of the 28th International Conference on Machine Learning, ICML (2011)

    Google Scholar 

  34. Taha, W., Sheard, T.: Metaml and multi-stage programming with explicit annotations. Theor. Comput. Sci. 248, 211–242 (2000)

    Article  MATH  Google Scholar 

  35. Ureche, V., Rompf, T., Sujeeth, A., Chafi, H., Odersky, M.: Stagedsac: A case study in performance-oriented dsl development. In: PEPM (2012)

    Google Scholar 

  36. Visser, E.: WebDSL: A Case Study in Domain-Specific Language Engineering. In: Lämmel, R., Visser, J., Saraiva, J. (eds.) GTTSE 2007. LNCS, vol. 5235, pp. 291–373. Springer, Heidelberg (2008)

    Google Scholar 

  37. Vogt, J.C.: Type Safe Integration of Query Languages into Scala. Diplomarbeit, RWTH Aachen, Germany (2011)

    Google Scholar 

  38. Wadler, P., Findler, R.B.: Well-Typed Programs Can’t Be Blamed. In: Castagna, G. (ed.) ESOP 2009. LNCS, vol. 5502, pp. 1–16. Springer, Heidelberg (2009)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2012 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Kossakowski, G., Amin, N., Rompf, T., Odersky, M. (2012). JavaScript as an Embedded DSL. In: Noble, J. (eds) ECOOP 2012 – Object-Oriented Programming. ECOOP 2012. Lecture Notes in Computer Science, vol 7313. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-31057-7_19

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-31057-7_19

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-31056-0

  • Online ISBN: 978-3-642-31057-7

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics