Upload
imds2014
View
152
Download
4
Embed Size (px)
Citation preview
Hop, a Language for Programming the Web 2.0
Paper byManuel Serrano, Erick Gallesio and Florian Loitsch
Inria Sophia AntipolisSophia Antipolis, Cedex, France
Presentation byChristian Funder Sommerlund
2006
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), ...
About the authors - Erick Gallesio
Papers: Pretty much the same as Manuel
Software: Pretty much the same as Manuel + STklos (Scheme fork)
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
Motivation
● Interactive web applications run the world● … and is replacing traditional applications
Desire for new/meaningful abstractions
● 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
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.
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
Meet Hop - Simple exampleHTML:
<HTML><BODY>
<TABLE width="100%"><TD>Bulbasaur</TD><TD>Charmander</TD><TD>Squirtle</TD>
</TABLE></BODY>
</HTML>
HOP:
(<HTML>(<BODY>
(<TABLE> :width "100%"(<TD> “Bulbasaur”)(<TD> “Charmander”)(<TD> “Squirtle”))))
Did you notice something peculiar about the Hop example?
?
Did you notice something peculiar about the Hop example?
It’s code!
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.
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"))))
Meet Hop - Stratum jumping
(<HTML> (<BODY> (<BUTTON>:onclick ~(alert (Pokedex.PowerCalc 25)) “Get Pika-power")))
The tilde character (~) “jumps” from the main stratum to the gui stratum:
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")))
Meet Hop - Lambda functions
(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))))
Anonymous functions (so-called Lambda functions) are supported in several different formats. This is one of them:
Meet Hop - with-hop (read: AJAX)
(define-service (server-date) (current-date))
(<HTML> (<BODY> (<BUTTON>:onclick ~(with-hop ($server-date) (lambda (h) (alert h))) "Get time")))
So far, so good. Now to the juicy stuff for making modern dynamic web applications in Hop:
Example using with-hop and inline lambda:
(with-hop (service arg1 arg2 ...)[(lambda (h) ...success expression...)[(lambda (h) ...failure expression...)]])
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● ...
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
Future work
● Security (2011)● Debugging utilities (2014)● Handling network failure● Faster interpretation/compiling (2011)● Process orchestration (2014)● and...
Applications
Thanks for listening + Questions
???