This document summarizes a 2006 paper on Hop, a new programming language for building web applications. Hop unifies HTML, JavaScript, and server-side logic into a single stratified language based on Scheme. It allows programming interactive web UIs and AJAX functionality using a functional programming approach. Some key features include stratum-jumping between client and server, services for handling pages, lambda functions, and with-hop for asynchronous requests. The authors argue Hop provides a viable way to modernize web development.
1. 2006
Hop, a Language for
Programming the Web 2.0
Paper by
Manuel Serrano, Erick Gallesio and Florian Loitsch
Inria Sophia Antipolis
Sophia Antipolis, Cedex, France
Presentation by
Christian Funder Sommerlund
2. About the authors - Manuel Serrano
Papers: Lots of Hop stuff, some web stuff (HTML, CSS,
IMAP, …), some Scheme stuff, some functional
programming, …
Software: Bigloo/Biglook (Scheme fork), Hop (multi-tier
web programming), Skribe (functional programming), ...
3. About the authors - Erick Gallesio
Papers: Pretty much the same as Manuel
Software: Pretty much the same as Manuel + STklos
(Scheme fork)
4. About the authors - Florian Loitsch
Papers: Some Scheme stuff, some Hop stuff, some
Javascript stuff, ...
Software: Various small utility projects like compilers
between Javascript and Scheme
Bonus info: Now works on Dart at Google in Aarhus
5. Motivation
● Interactive web applications run the world
● … and is replacing traditional applications
● Problem: A lot of technologies to master
○ HTML, CSS, JS, HTTP, PHP/ASP/JSP/...
● All invented “A long time ago, in a galaxy far,
far away….”
● 15-20 years of backward compatibility
Desire for new/meaningful abstractions
6. Meet Hop - Introduction
“Hop is a new higher-order language designed
for programming interactive web applications“
Hop has two layers (it is “stratified”):
● Application logic (read: server-side)
● GUI (read: client-side)
These are separate, but communication
between them is possible.
7. Meet Hop - Points of interest
● Hop is an abstraction of the existing techs
● Hop is a de-facto distributed system
● Hop is Scheme-like (you will see this soon)
● The APIs are stratum-dependent:
○ Main stratum: Access to files, databases, threads, …
○ GUI stratum: Drawing stuff, user interaction, limited
file access
9. Did you notice something peculiar
about the Hop example?
?
10. Did you notice something peculiar
about the Hop example?
It’s code!
11. Meet Hop - Programming the web
A Hop program is a program, not a markup
document like HTML.
Hop code:
(<B> "Hitmonchan")
In Java/C syntax:
<B>(“Hitmonchan”)
Notice that ‘<’, ‘>’ (and others) are valid in
function names to mimic the HTML naming.
12. Meet Hop - Services (read: pages)
(define-service (pokedex)
(<HTML> …)) ;; Return list of all Pokémons
(define-service (pokedex-pokemon pnum)
(<HTML> …)) ;; Return info about Pokémon #pnum
(<HTML>
(<BODY>
(<A> :href pokedex "Show list of Pokémons")
(<FORM> :action pokedex-pokemon
(<INPUT> :type "number" :name "pnum")
(<INPUT> :type "submit" :value "Look up Pokémon"))))
13. Meet Hop - Stratum jumping
The tilde character (~) “jumps” from the main
stratum to the gui stratum:
(<HTML> (<BODY> (<BUTTON>
:onclick ~(alert (Pokedex.PowerCalc 25)) “Get Pika-power")))
PowerCalc sounds hard. Let’s do that on the
main stratum. The dollar sign ($) jumps back:
(<HTML> (<BODY> (<BUTTON>
:onclick ~(alert $(Pokedex.PowerCalc 25)) “Get Pika-power")))
14. Meet Hop - Lambda functions
Anonymous functions (so-called Lambda
functions) are supported in several different
formats. This is one of them:
(let
((e0 (<TR> (<TD> “Eevee evolutions:”)))
(e1 (<TR> (<TD> “Vaporeon”)))
(e2 (<TR> (<TD> “Jolteon”)))
(e3 (<TR> (<TD> “Flareon”))))
(<HTML>
(<BODY>
(<TABLE> e0 e1 e2 e3))))
15. Meet Hop - with-hop (read: AJAX)
So far, so good. Now to the juicy stuff for making
modern dynamic web applications in Hop:
(with-hop (service arg1 arg2 ...)
[(lambda (h) ...success expression...)
[(lambda (h) ...failure expression...)]])
Example using with-hop and inline lambda:
(define-service (server-date) (current-date))
(<HTML> (<BODY> (<BUTTON>
:onclick ~(with-hop ($server-date) (lambda (h) (alert h))) "Get time")))
16. Meet Hop - Other features
● Object-oriented programming
● Standard library
● Exceptions
● Modules
● Multi-threading
● Server-initiated communication
● Event loops (read: event listeners)
● Single-file packaging and deployment
● ...
17. Conclusions
We have seen:
● The authors’ take on a viable way of bringing
web development into the 21th century by...
● unifying HTML, JS and SSS into...
● stratified program code written in a…
● simple functional programming language…
● based on Scheme