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

Dmitry Kolesnikov dmkolesnikov@REDACTED
Sat Feb 18 12:52:55 CET 2012


Hello Joe,

This looks interesting! One of my worries is that it is too late for such language. 
You are absolutely right about the gap in between erlang and xHTML UI and these solution would definitely facilitate but ....

xHTML UI is not only the bindings with run time. It is important to ensure availability of templates. erlydtl addresses this issue by building a compatibility with Python Django templates. From my side, I have been investigating an option to "compile" PHP templates into Erlang code but did not progressed due to time constrains. 

If you are targeting a wide adoption of EHE then you should work out this aspect.... However, EHE looks cool and I shall try it in my UI projects... 

Best Regards, 
Dmitry

On Feb 18, 2012, at 1:13 PM, Joe Armstrong wrote:

> 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
> instruction.
> 
> 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
> 
>    <h1>Hello</h1>
> 
>     <?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
> 
>      https://github.com/joearms/adapter_pattern
> 
>      (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
> support?
> 
> /Joe
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list