[erlang-questions] Thoughts on EHE - the PHP killer

Joe Armstrong erlang@REDACTED
Sat Feb 18 12:13:19 CET 2012

Thoughts on EHE

I'm playing with a little language for writing web applications.
It's called EHE. All it is HTML with embedded Erlang

I like EHE very much since it is the simplest possible way of embedding
Erlang in a web page - I can think of no simpler method - the learning
gap (if you know Erlang and HTML) is pretty near zero. For me
simple = good.

What is EHE?

An EHE script is just a file with the extension .ehe. The file
contains HTML or XHTML with embedded Erlang.

The embedding syntax is

    <?e ....... ?>

This syntax is chosen since this notation corresponds to an XML processing

Inside the block is sequence of Erlang expressions.

The replacement value of the block is the last value of the sequence is
just the last value in the sequence, which must be an IO list.

Binding are propagated forwards between blocks.

Here's an example


     <?e Name ="joe", "" ?>

    <p> Hello <?e Name ?>

The first block binds the variable Name and injects "" into the text
The second block injects "joe" into the text.

Communicating with the environment:

  Inside EHE the global variable SYS provides a bridge to the outside world.

  We can imagine a library of useful functions that change the state of the
  environment - like:

     <?e SYS:get_db(Key) ?>
     <?e SYS:put_db(Key, Value) ?>

     <?e SYS:set_header(Header, Value) ?>

     and so on

  SYS is a parametrised module that is configured *outside* EHE - so
we can change
the database later *without* changing the EHE code.

   There is an implementation of EHE at


      (actually there is no SYS module in the git hub code, just an
object called Req)

   Question: Do we need more than this in an embedded language.

   On part of me says NO WAY - you have the full power of erlang at
your disposal.

   Another part says

      <? if_true_skip_block(X), ""?>
      <? ... ?>

     Might mean if X is true then omit the block of HTML immediately following
the erlang code block.

     The problem with this is that it leads to a half-baked badly thought out
mess of language and a slippery slope where we want to add just one
more feature.

     For this reason I would suggest that EHE only has the semantics I
have suggested
and nothing else.

     Note - while EHE is interpreted it can easily be compiled if efficiency
is a problem.

     Now the next question - what are the SYS functions:

     SYS:lookup(Key) -> {ok, Value} | error

SYS is a parametric module that bridges you into Erlang - but what
functions should it


More information about the erlang-questions mailing list