bile phone inside a Web application.
The contents of incoming SMSs are
displayed in a browser window, letting
users choose whether or not an SMS
should be spoken aloud.
This application uses three separated tiers: a Web browser, a Web server,
and a phone server. The phone server
is responsible for receiving the SMSs
and speaking them on demand. The
Web server plays the role of orchestrator; when the phone notifies it that a
new SMS has been received, it alerts
the interested clients and, depending
on the user configuration, speaks out
the short message.
The application takes advantage
of another useful feature of Hop: allowing a server to be a new source of
program-generated Web events for
clients or other servers. In the phone
example, the server starts establishing a bridge with the phone (using the
android variable), then waits for the
notification of an SMS and accesses
the phone text-to-speech facility (
using the tts variable).
The server code registers a function
invoked each time a new SMS is received to forward a software Web event
to interested Web clients.
implementation
Hop is an open source project whose
source code can be downloaded from
the Web site http://hop.inria.fr. All the
actual source code shown in this article can also be downloaded from this
Web site. The development kit contains the compilers, interactive documentation, various tools for creating
and installing applications, and the
runtime environment, which is a dedicated Web server that runs on all Un*x
platforms—Linux, Mac OS X, and Android. It is operational on mainstream
modern architectures such as x86/32,
x86/64, PowerPC, and the ARM family.
The Hop runtime environment re-
quires only 3MB–4MB of RAM. This
small memory footprint makes it suit-
able for smartphones or even smaller
machines, such as the new ARM-
equipped computers (Phidget SBC2,
Raspberry Pi, among others) that offer
only a few megabytes to applications.
As far as speed is concerned, the Hop
Web server delivers dynamic Web
pages significantly faster than tradi-
tional servers such as Apache or Light-
tpd. The performance gain is a result
of the Hop-in-Hop implementation,
which enables the server to respond to
requests involving dynamic computa-
tions without costly execution context
switching. 4
A new Playground
Hop is the conjunction of a multitier
programming language and a runtime
environment for the Web. Its main
goals are to unify the linguistic features needed for Web applications, to
automate the physical distribution of
code in a fully transparent way, and
to help programmers in reusing and
combining external resources. All of
these are keys to program simplicity
and conciseness.
This article has presented several
complete Web application examples
written in Hop. The first example illustrates how to raise the HTML abstraction level by using an algorithmic
programming language approach. The
second example shows how to reuse
third-party code. The third example
shows that combining Web technologies with open data opens the path for
new application ideas. The last example presents a simple diffuse application on the Web. These examples have
all been chosen for their simplicity;
the same technique would be equally
effective when dealing with much bigger applications in domains such as
home automation or multimedia.
None of the applications presented
here exceeds 30 lines of Hop source
code. This is not accidental; it is the
consequence of a perception shift
where the Web is no longer regarded
as a mere platform for sharing documents but as a revolutionary runtime
environment. Note, however, that Hop
is a realistic programming language,
which implies a lot of additional bells
and whistles. This article has ignored
most of them, concentrating on multitier programming and the connection
to official Web technologies.
Finally, note that the Hop core lan-
guage is a strict functional program-
ming language, with runtime type
checking. This design choice comes
mostly from a personal bias of the
first author. Arguably, it fits well with
the current programming trends of
the Web, but other flavors should be
possible, yielding other programming
languages. We hope to see such new
languages appearing, because the
multiplicity of approaches will foster
creativity and possibly open a new era
in language and tool design.
Related articles
on queue.acm.org
There’s Still Some Life Left in Ada
Alexander Wolfe
http://queue.acm.org/detail.cfm?id=1035608
Extensible Programming
for the 21st Century
Gregory V. Wilson
http://queue.acm.org/detail.cfm?id=1039534
Purpose-Built Languages
Mike Shapiro
http://queue.acm.org/detail.cfm?id=1508217
References
1. Cooper, e., lindley, s., Wadler, p. nd yallop, j. links:
Web programming without tiers. presented at the 5th
International symposium on formal methods for
Components and objects (2006).
2. ginsberg, j., mohebbi, m., patel, r., brammer, l.,
smolinski, m. and brilliant, l. Detecting influenza
epidemics using search engine query data. Nature 457
(feb. 19, 2009), 1012–1014.
3. kelsey, r., Clinger, W. and rees, j. the revised ( 5)
report on the algorithmic language scheme.
Higher-Order and Symbolic Computation 11, 1 (1998);
http://www.sop.inria.fr/indes/fp/bigloo/doc/r5rs.html/
4. serrano, m. hop, a fast server for the diffuse Web.
In Proceedings of the 11th International Conference
on Coordination Models and Languages (lisbon,
portugal, 2009).
5. serrano, m., gallesio, e. and loitsch, f. hop,
a language for programming the Web 2.0. In
Proceedings of the First Dynamic Languages
Symposium (portland, or, 2006).
Manuel Serrano is a senior scientist at InrIa, leading
the InDes (Informatique Diffuse et sécurisée) team in
sophia-antipolis. after completing his ph.D. at the pierre
and marie Curie university (upmC) on the compilation
of functional languages, he moved to nice and created
the bigloo development environment for scheme. he
joined InrIa in 2001 and has focused on development
environments for the diffuse web since 2005.
Gérard Berry, director of research at InrIa, works on
programming languages, their mathematical semantics,
and program verification technologies. his focus has been
on the lambda-calculus and its models, reactive and
real-time programming and verification, and high-level
digital circuits specification, synthesis, and verification.
prior to joining InrIa he was chief scientist of esterel
technologies and was the main author of the esterel
language, which has been used in academia and industry
for applications ranging from complex circuit synthesis to
airplane control.