Skip to main content

Lightweight Declarative Server-Side Web Programming

  • Conference paper
  • First Online:
Book cover Practical Aspects of Declarative Languages (PADL 2021)

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

Included in the following conference series:

  • 294 Accesses

Abstract

Web interfaces are an important part of many applications but their implementation is full of pitfalls due to the client/server nature of web programming. This paper presents a lightweight approach to web programming based on a standard infrastructure, in particular, the common CGI protocol between client and server. No specific additions are necessary on the server side. Our approach exploits declarative programming features to provide a high-level API for server-side web scripting. This API allows to check many programming errors at compile time by using functional (static typing, higher-order functions) as well as logic (free variables) programming features. Together with further abstractions, like session handling, persistence, and typeful database access, it is used for non-trivial web applications.

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

Institutional subscriptions

Notes

  1. 1.

    Actually, this was the approach taken in a very early continuation-based library for web programming in Curry [6]. The practical problems caused by the web-server processes motivated the current approach.

  2. 2.

    Variables and function names usually start with lowercase letters and the names of type and data constructors start with an uppercase letter. The application of f to e is denoted by juxtaposition (“f e”).

  3. 3.

    Actually, Curry is intended as an extension of Haskell although not all of the numerous features of Haskell are actually supported.

  4. 4.

    Actually, there is a simple script to wrap such web page definitions with showHtmlPage before compiling and installing it.

  5. 5.

    The actual definition in our library contains more operations which are not relevant here.

  6. 6.

    https://html.spec.whatwg.org/multipage/forms.html#the-form-element.

  7. 7.

    Of course, this game can be implemented on the client side, but a realistic example with database access needs too much space.

  8. 8.

    The preprocessor is used since contemporary Curry implementations do not provide access to entities of the program at run time.

  9. 9.

    https://mdb.ps.informatik.uni-kiel.de/.

  10. 10.

    https://smap.informatik.uni-kiel.de/.

References

  1. Antoy, S., Echahed, R., Hanus, M.: A needed narrowing strategy. J. ACM 47(4), 776–822 (2000)

    Article  MathSciNet  Google Scholar 

  2. Antoy, S., Hanus, M.: Functional logic programming. Commun. ACM 53(4), 74–85 (2010)

    Article  Google Scholar 

  3. Cabeza, D., Hermenegildo, M.: Distributed WWW programming using (CIAO-)Prolog and the PiLLoW library. Theory Pract. Log. Program. 1(3), 251–282 (2001)

    Article  Google Scholar 

  4. 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). https://doi.org/10.1007/978-3-540-74792-5_12

    Chapter  Google Scholar 

  5. Ekblad, A., Claessen, K.: A seamless, client-centric programming model for type safe web applications. In: Proceedings of the 2014 ACM SIGPLAN Symposium on Haskell, pp. 79–89. ACM Press (2014)

    Google Scholar 

  6. Hanus, M.: High-level server side web scripting in curry. In: Ramakrishnan, I.V. (ed.) PADL 2001. LNCS, vol. 1990, pp. 76–92. Springer, Heidelberg (2001). https://doi.org/10.1007/3-540-45241-9_6

    Chapter  Google Scholar 

  7. Hanus, M.: Type-oriented construction of web user interfaces. In: Proceedings of the 8th ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming (PPDP 2006), pp. 27–38. ACM Press (2006)

    Google Scholar 

  8. Hanus, M.: Putting declarative programming into the web: translating curry to JavaScript. In: Proceedings of the 9th ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming (PPDP 2007), pp. 155–166. ACM Press (2007)

    Google Scholar 

  9. Hanus, M.: Functional logic programming: from theory to curry. In: Voronkov, A., Weidenbach, C. (eds.) Programming Logics. LNCS, vol. 7797, pp. 123–168. Springer, Heidelberg (2013). https://doi.org/10.1007/978-3-642-37651-1_6

    Chapter  MATH  Google Scholar 

  10. Hanus, M., Kluß, C.: Declarative programming of user interfaces. In: Gill, A., Swift, T. (eds.) PADL 2009. LNCS, vol. 5418, pp. 16–30. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-92995-6_2

    Chapter  Google Scholar 

  11. Hanus, M., Koschnicke, S.: An ER-based framework for declarative web programming. Theory Pract. Log. Program. 14(3), 269–291 (2014)

    Article  Google Scholar 

  12. Hanus, M., Krone, J.: A typeful integration of SQL into curry. In: Proceedings of the 24th International Workshop on Functional and (Constraint) Logic Programming, volume 234 of Electronic Proceedings in Theoretical Computer Science, pp. 104–119. Open Publishing Association (2017)

    Google Scholar 

  13. Hanus, M. (eds.): Curry: an integrated functional logic language (vers. 0.9.0) (2016). http://www.curry-lang.org

  14. Huseby, S.H.: Innocent Code: A Security Wake-Up Call for Web Programmers. Wiley (2003)

    Google Scholar 

  15. Krishnamurthi, S., McCarthy, J.A., Graunke, P.T., Pettyjohn, G., Felleisen, M.: Implementation and use of the PLT scheme web server. High. Order Symbol. Comput. 20(4), 431–460 (2007)

    Article  Google Scholar 

  16. Ladd, D.A., Ramming, J.C.: Programming the web: an application-oriented language for hypermedia service programming. World Wide Web J. 1(1) (1996)

    Google Scholar 

  17. Meijer, E.: Server side web scripting in Haskell. J. Funct. Program. 10(1), 1–18 (2000)

    Article  Google Scholar 

  18. Peyton Jones, S. (ed.) Haskell 98 Language and Libraries-The Revised Report. Cambridge University Press (2003)

    Google Scholar 

  19. Plasmeijer, R., Achten, P.: iData for the world wide web – programming interconnected web forms. In: Hagiya, M., Wadler, P. (eds.) FLOPS 2006. LNCS, vol. 3945, pp. 242–258. Springer, Heidelberg (2006). https://doi.org/10.1007/11737414_17

    Chapter  Google Scholar 

  20. Sandholm, A., Schwartzbach, M.I.: A type system for dynamic web documents. In: Proceedings of the 27th ACM Symposium on Principles of Programming Languages, pp. 290–301 (2000)

    Google Scholar 

  21. Thiemann, P.: A typed representation for HTML and XML documents in Haskell. J. Funct. Program. 12(4–5), 435–468 (2002)

    Article  MathSciNet  Google Scholar 

  22. Thiemann, P.: WASH/CGI: server-side web scripting with sessions and typed, compositional forms. In: Krishnamurthi, S., Ramakrishnan, C.R. (eds.) PADL 2002. LNCS, vol. 2257, pp. 192–208. Springer, Heidelberg (2002). https://doi.org/10.1007/3-540-45587-6_13

    Chapter  Google Scholar 

  23. Thiemann, P.: WASH server pages. In: Hagiya, M., Wadler, P. (eds.) FLOPS 2006. LNCS, vol. 3945, pp. 277–293. Springer, Heidelberg (2006). https://doi.org/10.1007/11737414_19

    Chapter  Google Scholar 

  24. Wadler, P.: How to declare an imperative. ACM Comput. Surv. 29(3), 240–263 (1997)

    Article  Google Scholar 

  25. Wadler, P., Blott, S.: How to make ad-hoc polymorphism less ad hoc. In: Proceedings of POPL 1989, pp. 60–76 (1989)

    Google Scholar 

  26. Wielemaker, J., Huang, Z., van der Meij, L.: SWI-Prolog and the web. Theory Pract. Log. Program. 8(3), 363–392 (2008)

    Article  MathSciNet  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Michael Hanus .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2021 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Hanus, M. (2021). Lightweight Declarative Server-Side Web Programming. In: Morales, J.F., Orchard, D. (eds) Practical Aspects of Declarative Languages. PADL 2021. Lecture Notes in Computer Science(), vol 12548. Springer, Cham. https://doi.org/10.1007/978-3-030-67438-0_7

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-67438-0_7

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-67437-3

  • Online ISBN: 978-3-030-67438-0

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics