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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Abadi, M., Cardelli, L., Pierce, B., Plotkin, G.: Dynamic typing in a statically typed language. ACM Trans. Program. Lang. Syst. 13, 237–268 (1991)
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)
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)
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)
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)
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)
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)
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)
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)
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)
Danvy, O., Filinski, A.: Representing control: A study of the cps transformation. Mathematical Structures in Computer Science 2(4), 361–391 (1992)
Flanagan, D.: (2011), https://github.com/davidflanagan/javascript6_examples/blob/master/examples/21.06.koch.js
Flanagan, D.: JavaScript: The Definitive Guide, 6th edn. O’Reilly Media, Inc. (2011)
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)
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)
Khoo, Y.P., Hicks, M., Foster, J.S., Sazawal, V.: Directing javascript with arrows. SIGPLAN Not. 44, 49–58 (2009)
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)
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)
Moors, A., Piessens, F., Odersky, M.: Generics of a Higher Kind. ACM SIGPLAN Notices 43, 423–438 (2008)
Moors, A., Rompf, T., Haller, P., Odersky, M.: Scala-virtualized. In: PEPM 2012 (2012)
Odersky, M., Zenger, M.: Scalable Component Abstractions. In: Proceedings of OOPSLA 2005 (2005)
Petříček, T., Syme, D.: F# web tools: Rich client/server web applications in f#
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)
Rompf, T., Odersky, M.: Lightweight Modular Staging: A Pragmatic Approach to Runtime Code Generation and Compiled DSLs. In: GPCE (2010)
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)
Siek, J.G., Taha, W.: Gradual typing for functional languages. In: Scheme and Functional Programming Workshop (September 2006)
Siek, J.G., Taha, W.: Gradual Typing for Objects. In: Bateni, M. (ed.) ECOOP 2007. LNCS, vol. 4609, pp. 2–27. Springer, Heidelberg (2007)
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)
Taha, W., Sheard, T.: Metaml and multi-stage programming with explicit annotations. Theor. Comput. Sci. 248, 211–242 (2000)
Ureche, V., Rompf, T., Sujeeth, A., Chafi, H., Odersky, M.: Stagedsac: A case study in performance-oriented dsl development. In: PEPM (2012)
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)
Vogt, J.C.: Type Safe Integration of Query Languages into Scala. Diplomarbeit, RWTH Aachen, Germany (2011)
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)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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)