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

Hop, a language for programming the web 2.0

Embed Size (px)

Citation preview

Page 1: Hop, a language for programming the web 2.0

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

Page 2: Hop, a language for programming the web 2.0

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), ...

Page 3: Hop, a language for programming the web 2.0

About the authors - Erick Gallesio

Papers: Pretty much the same as Manuel

Software: Pretty much the same as Manuel + STklos (Scheme fork)

Page 4: Hop, a language for programming the web 2.0

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

Page 5: Hop, a language for programming the web 2.0

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

Page 6: Hop, a language for programming the web 2.0

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.

Page 7: Hop, a language for programming the web 2.0

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

Page 8: Hop, a language for programming the web 2.0

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

Page 9: Hop, a language for programming the web 2.0

Did you notice something peculiar about the Hop example?

?

Page 10: Hop, a language for programming the web 2.0

Did you notice something peculiar about the Hop example?

It’s code!

Page 11: Hop, a language for programming the web 2.0

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.

Page 12: Hop, a language for programming the web 2.0

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

Page 13: Hop, a language for programming the web 2.0

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

Page 14: Hop, a language for programming the web 2.0

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:

Page 15: Hop, a language for programming the web 2.0

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...)]])

Page 16: Hop, a language for programming the web 2.0

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

Page 17: Hop, a language for programming the web 2.0

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

Page 18: Hop, a language for programming the web 2.0

Future work

● Security (2011)● Debugging utilities (2014)● Handling network failure● Faster interpretation/compiling (2011)● Process orchestration (2014)● and...

Applications

Page 19: Hop, a language for programming the web 2.0

Thanks for listening + Questions

???