Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Thoughts on EHE - the PHP killer
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 26 - 41 of 41 - Collapse all  -  Translate all to Translated (View all originals) < Older 
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tim Watson  
View profile  
 More options Feb 19 2012, 2:04 pm
From: Tim Watson <watson.timo...@gmail.com>
Date: Sun, 19 Feb 2012 19:04:32 +0000
Local: Sun, Feb 19 2012 2:04 pm
Subject: Re: [erlang-questions] Thoughts on EHE - the PHP killer
On 19 February 2012 08:42, Joe Armstrong <erl...@gmail.com> wrote:

> (( Interesting - I haven't actually tried doing it this way -
> This seems like how jquery does things only on the server

> I was wondering about viewing pages as processes and sending them messages.

> ie  <div id="mynicetag"></div>

> And in Erlang    mynicetag ! {content, "<p>hello</p>"}

> But never got round to implementing this ))

> ))

Interesting concept. Either way, I think a separation like that would
appeal to many, although I suspect templating is the popular approach
nowadays.

> To answer your question the difference is all the code is in one place - I don't
> have to go and look somewhere else to see the code.

That isn't always beneficial though is it. Simplicity is best for sure
- I'm definitely with Dijkstra on that one - but even the agile maxim
"do the simplest thing that can possibly work" has to be balanced with
the right factors. For example, you don't put all you code into just
one module, because once a module has more than one axis for change
then it becomes harder to manage and maintain. The same is true for
the UI surely?

> Anyway I write all the html and erlang myself I don't live in
> this world where one guy writes the html and another writes the code
> and another writes the css and another writes the js and another
> writes the bla bla bla

And that is quite a rare thing in most medium to large teams and
almost completely unheard of in a large enterprise.

> I'm just making a tool for me - the problem with programming is that
> solving problems is one thing but solving problems subject to the
> condition that the solution is beautiful and maintainable is really
> really difficult.

But you're not just making a tool for you if you're promoting it as
something we should standardise on for all web servers.

> My problem is not making web sites that work it's making
> them with beautiful code.

My problem is that I can make a web page functional, but making it
look 'nice' is like black magic to me. :)
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Watson  
View profile  
 More options Feb 19 2012, 2:29 pm
From: Tim Watson <watson.timo...@gmail.com>
Date: Sun, 19 Feb 2012 19:29:07 +0000
Local: Sun, Feb 19 2012 2:29 pm
Subject: Re: [erlang-questions] Thoughts on EHE - the PHP killer
On 19 February 2012 10:52, Adam Rutkowski <adam.rutkow...@jtendo.com> wrote:

> On Feb 19, 2012, at 8:37 AM, Matti Oinas wrote:

>> How come django is better than embedding PHP or erlang code into template? Django just adds one language so instead of 2 you must use 3 to get a working template.

> You can have an UI guy providing templates and he wouldn't be able to erase your hard drive with it.

More to the point, most developers I've come across seem to think that
code mixed with markup is an anti-pattern - admittedly these are
people who wouldn't touch PHP with a barge pole. I seem to remember
reading someone who compared the relationship between this and well
designed code with that of professional wrestling to real sport. The
tendency is that the 'script-let' approach makes both the code and
markup harder to read and comprehend despite their proximity and
obvious connection in context, encourages lazy developers to allow
business logic to become interspersed with presentation logic, makes
it harder to test both (certainly from a unit testing point of view)
and generally sucks from a maintenance perspective.

I mean for crying out loud, most people who're working on the pure
client side of web development with js libraries like
backbone/jQuery/etc are trying really hard not to mix up the content
and the layout, with backbone going as far as to separate the
model/backend, presentation logic (controllers) and rendering (views).
As I've said previously, I'm not a huge fan of MVC as a pattern, but
the premise upon which it is based is a good one even if the solution
is a bit over complex IMO.

Doing what's simple isn't always the same as doing what seems obvious,
which when I hear 'do the simplest thing that can possibly work' makes
me ask 'but is this *really* the simple thing to do?' Dijkstra, who
was obsessed by simplicity, also claimed that 'elegance' is not a
dispensable luxury but a quality that determines between success and
failure. I don't find anything 'elegant' about embedding code inside
of web pages, and that's not an aesthetic judgement, but one that
comes from working with medium to large, multi-disciplinary teams,
where 'sites' might have hundreds or even thousands of different views
and considerable logic behind many of them. In an environment like
that, especially when the system(s) are business critical and/or
customer facing, you fight for your life to keep a strict separation
of concerns, or you end up failing because of the inherent complexity
and loose your reputation as a team lead as well as your bonus.
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Watson  
View profile  
 More options Feb 19 2012, 2:32 pm
From: Tim Watson <watson.timo...@gmail.com>
Date: Sun, 19 Feb 2012 19:32:03 +0000
Local: Sun, Feb 19 2012 2:32 pm
Subject: Re: [erlang-questions] Thoughts on EHE - the PHP killer
To clarify...

On 19 February 2012 14:17, Tim Watson <watson.timo...@gmail.com> wrote:

> Obviously this isn't as cool as a webmachine-a-like running on YAWS,
> but I *think* I can make it work quite easily and it makes for more
> convenient mapping of URLs to controller/handler module + function.

What I meant there is a more convenient mapping than an appmod -
obviously it's not as good as the webmachine approach to routing!
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matti Oinas  
View profile  
 More options Feb 19 2012, 3:17 pm
From: Matti Oinas <matti.oi...@gmail.com>
Date: Sun, 19 Feb 2012 22:17:45 +0200
Local: Sun, Feb 19 2012 3:17 pm
Subject: Re: [erlang-questions] Thoughts on EHE - the PHP killer
On 02/19/2012 09:29 PM, Tim Watson wrote:
> I don't find anything 'elegant' about embedding code inside
> of web pages, and that's not an aesthetic judgement, but one that
> comes from working with medium to large, multi-disciplinary teams,
> where 'sites' might have hundreds or even thousands of different views
> and considerable logic behind many of them. In an environment like
> that, especially when the system(s) are business critical and/or
> customer facing, you fight for your life to keep a strict separation
> of concerns, or you end up failing because of the inherent complexity
> and loose your reputation as a team lead as well as your bonus.

That is true that you want to keep view separated but that is where
django and others fail. View still contains code like

{%  for  match  in  matches  %}
     <div  style="background-color:
         {%  ifchanged  match.ballot_id  %}
             {%  cycle  "red"  "blue"  %}
         {%  else  %}
             grey
         {%  endifchanged  %}
     ">{{  match  }}</div>
{%  endfor  %}

That is equally ugly with embedded code and it contains logic. Even
worse is that it added one extra language but still failed to separate
logic from the view.

Enlive on the other hand uses plain HTML templates which are transformed
with the help of CSS selectors. There is no logic in HTML template, only
plain old HTML. Tranformation code defines what elements will be left
and what elements contains what information.

http://cleancode.se/2011/01/04/getting-started-with-moustache-and-enl...

Now we have separated the view from logic and it is really simple to
change templates. That is a library that I would like to see written in
erlang.
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Watson  
View profile  
 More options Feb 19 2012, 4:13 pm
From: Tim Watson <watson.timo...@gmail.com>
Date: Sun, 19 Feb 2012 21:13:20 +0000
Local: Sun, Feb 19 2012 4:13 pm
Subject: Re: [erlang-questions] Thoughts on EHE - the PHP killer
On 19 February 2012 20:17, Matti Oinas <matti.oi...@gmail.com> wrote:

At least it is *presentation logic* and I could argue this both ways.
I agree that code isn't particularly elegant, but at least it is
specifically 'about' the rendering.

> Enlive on the other hand uses plain HTML templates which are transformed
> with the help of CSS selectors. There is no logic in HTML template, only
> plain old HTML. Tranformation code defines what elements will be left and
> what elements contains what information.

> http://cleancode.se/2011/01/04/getting-started-with-moustache-and-enl...

> Now we have separated the view from logic and it is really simple to change
> templates. That is a library that I would like to see written in erlang.

Yes I agree this is a far cleaner approach, and you will see that it
is very similar to what I proposed to Joe in a previous message on
this thread, although at the time I hadn't bothered to look at enlive
in any detail. Having spent a little time looking at enlive, I think
the approach is very neat and that it would be relatively easy to do
this in Erlang, although you'll need a 'non-strict' parser such as
https://github.com/massemanet/trane and of course the supporting
libraries for generating/munging HTML content using a nice API.
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve Vinoski  
View profile  
 More options Feb 20 2012, 7:23 am
From: Steve Vinoski <vino...@ieee.org>
Date: Mon, 20 Feb 2012 07:23:23 -0500
Local: Mon, Feb 20 2012 7:23 am
Subject: Re: [erlang-questions] Thoughts on EHE - the PHP killer

On Sun, Feb 19, 2012 at 9:17 AM, Tim Watson <watson.timo...@gmail.com> wrote:
> Next question I have is, how hard would it be to do something like a
> servlet filter in YAWS? I could do this quite well using annotations -
> that's how ErlangWeb does it, albeit with macros instead - but is that
> the best way? It would look something like this (and is quite easy to
> implement using annotations):

> -secured({auth_provider, oauth}).
> -controller({"/accounts/{account_type}/{account_number}/", 'GET'}).
> get_account(AccountType, AccountNum, YawsArg) -> ....

> Is there something else in YAWS like appmod that'll do a filter chain,
> or am I better off using annotations?

There's really nothing like servlet filters. I guess the closest thing
-- admittedly not very close, though -- is the ability to add a
rewriter, which sits in the dispatch path, takes in the #arg, and can
produce a modified one if it wants to.

Just off the top of my head, it seems like one could do something like
servlet filters with an appmod, I think. Register it on /, and give it
it's own dispatching configuration and allow plug-ins to register into
its request-reply path. It could then receive each request, arrange
the ultimate dispatch target (an appmod, a .yaws page, even a file) at
the end of plug-in chain, dispatch the #arg into the chain, and then
deliver the eventual reply back into Yaws. No doubt this would be
easier if it were built into Yaws, though, since reusing the existing
dispatch logic would be easier than writing your own.

--steve
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Watson  
View profile  
 More options Feb 20 2012, 12:13 pm
From: Tim Watson <watson.timo...@gmail.com>
Date: Mon, 20 Feb 2012 17:13:50 +0000
Local: Mon, Feb 20 2012 12:13 pm
Subject: Re: [erlang-questions] Thoughts on EHE - the PHP killer
On 20 February 2012 12:23, Steve Vinoski <vino...@ieee.org> wrote:

Yes and presumably to do your webmachine-a-like you'll be using the
internal dispatch like this anyway, right? But it would definitely be
better for use the internal dispatch logic. Also is there a straight
API call back into YAWS for serving a request, especially a file one
(so that sendfile will kick in if configured) ?

BTW thanks for the feedback, this has been very useful and I'm going
to start playing with YAWS properly now I think.
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Edmond Begumisa  
View profile  
 More options Feb 20 2012, 2:54 pm
From: "Edmond Begumisa" <ebegum...@hysteria-tech.com>
Date: Tue, 21 Feb 2012 06:54:00 +1100
Subject: Re: [erlang-questions] Thoughts on EHE - the PHP killer
On Mon, 20 Feb 2012 01:17:19 +1100, Tim Watson <watson.timo...@gmail.com>  
wrote:

Say you have a file:

...blah1...
<erl>.. out/1...</erl>
...blah2...
<erl>.. out/1...</erl>
...blah3...

IIRC, the individual <erl></erl> tags within the same file are compiled  
into seperate Erlang modules at runtime when the file is first requested  
and the compiled modules are cached. out/1 is then called for each module  
and the outputs combined with the text outside the <erl> tags. Something  
like...

send(Blah1),
send(mod1:out(Arg)),
send(Blah2),
send(mod2:out(Arg)),
send(Blah3)

This is a great idea. Your annotations tools would be really useful here.

What would REALLY be cool is a set of general-puprose reusable annotations  
specifically for yaws, not only for code but for default content too.

- Edmond -

> Cheers,

> Tim
> _______________________________________________
> erlang-questions mailing list
> erlang-questi...@erlang.org
> http://erlang.org/mailman/listinfo/erlang-questions

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Edmond Begumisa  
View profile  
 More options Feb 20 2012, 4:52 pm
From: "Edmond Begumisa" <ebegum...@hysteria-tech.com>
Date: Tue, 21 Feb 2012 08:52:40 +1100
Local: Mon, Feb 20 2012 4:52 pm
Subject: Re: [erlang-questions] Thoughts on EHE - the PHP killer
On Tue, 21 Feb 2012 04:13:50 +1100, Tim Watson <watson.timo...@gmail.com>  
wrote:

I presume that it's more URI-based modularity that you're looking for.  
Note that you can achieve this by using the "yapps" feature by splitting  
your web-application into small OTP applications. Actually, I find that  
this approach promotes more manageable and reusable code.

Using your first example. You could have several OTP applications handling  
auth(entic|oris)ation, accounts, payments, receipts, etc....

== yaws.conf ==
..

runmod = yapp

<server public>
   port = 8000
   listen = 0.0.0.0
   docroot = /PATH_TO_MAIN_DOC_ROOT/www
   arg_rewrite_mod = yapp
   <opaque>
     yapp_server_id = pub
     bootstrap_yapps = accounts, payments, receipts, auth
   </opaque>
</server>

<server admin>
   port = 8001
   listen = 0.0.0.0
   docroot = /PATH_TO_MAIN_DOC_ROOT/www
   arg_rewrite_mod = yapp
   <opaque>
     yapp_server_id = adm_gui
     bootstrap_yapps = yapp
   </opaque>
</server>
..

== PATH_TO_WEBAPP_OTP_APPS/accounts/ebin/accounts.app ==
..
{env, [
          {yapp_appmods,[{"show", accounts_show_controller},
                         "configure", accounts_conf_controller}]}
       ]},
..

== PATH_TO_WEBAPP_OTP_APPS/accounts/src/accounts_show_controller.erl ==
..
out(A) ->
..

== PATH_TO_WEBAPP_OTP_APPS/accounts/src/accounts_conf_controller.erl ==
..
out(A) ->
..

== PATH_TO_WEBAPP_OTP_APPS/accounts/priv/docroot/ ==
Has it's own docroot!

Now whenever http://server:8000/accounts/* is accessed, the accounts OTP  
application will handle it. If it's  
http://server:8000/accounts/configure/*, then the accounts application's  
appmod will handle it.

Then you write other OTP applications for payments, etc, etc. After a  
while, you'll find yourself moving little useful OTP yapp applications  
between projects.

> Also is there a straight
> API call back into YAWS for serving a request, especially a file one
> (so that sendfile will kick in if configured) ?

To preempt his response: the hard work has already been done...

http://steve.vinoski.net/blog/2009/01/05/sendfile-for-yaws/

- Edmond -

> BTW thanks for the feedback, this has been very useful and I'm going
> to start playing with YAWS properly now I think.
> _______________________________________________
> erlang-questions mailing list
> erlang-questi...@erlang.org
> http://erlang.org/mailman/listinfo/erlang-questions

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Watson  
View profile  
 More options Feb 20 2012, 4:59 pm
From: Tim Watson <watson.timo...@gmail.com>
Date: Mon, 20 Feb 2012 21:59:31 +0000
Local: Mon, Feb 20 2012 4:59 pm
Subject: Re: [erlang-questions] Thoughts on EHE - the PHP killer
On 20 February 2012 19:54, Edmond Begumisa <ebegum...@hysteria-tech.com> wrote:

I'd love to do that, but I actually have *no idea* when I'm actually
going to find time to even play with YAWS properly at the moment
(which I want to do) but I am making a mental note (on google :) about
this. :)
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve Vinoski  
View profile  
 More options Feb 21 2012, 7:26 am
From: Steve Vinoski <vino...@ieee.org>
Date: Tue, 21 Feb 2012 07:26:21 -0500
Local: Tues, Feb 21 2012 7:26 am
Subject: Re: [erlang-questions] Thoughts on EHE - the PHP killer

Not really, but I don't think it would be hard to add. Currently, an
out/1 function can return the {page, Page} directive to tell yaws to
re-dispatch the current request to Page, which yaws expects to be an
absolute URI path, but I think that's about it. I know for sure this
works for appmods re-dispatching to files, and looking at the code I
think it works for any general re-dispatch, but I've personally never
tried it for anything other appmods re-dispatching to files.

--steve
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Watson  
View profile  
 More options Feb 21 2012, 9:58 am
From: Tim Watson <watson.timo...@gmail.com>
Date: Tue, 21 Feb 2012 14:58:51 +0000
Local: Tues, Feb 21 2012 9:58 am
Subject: Re: [erlang-questions] Thoughts on EHE - the PHP killer
On 21 February 2012 12:26, Steve Vinoski <vino...@ieee.org> wrote:

> Not really, but I don't think it would be hard to add. Currently, an
> out/1 function can return the {page, Page} directive to tell yaws to
> re-dispatch the current request to Page, which yaws expects to be an
> absolute URI path, but I think that's about it. I know for sure this
> works for appmods re-dispatching to files, and looking at the code I
> think it works for any general re-dispatch, but I've personally never
> tried it for anything other appmods re-dispatching to files.

Ok cool that's enough to get started. Now I just need to find 30 mins
of free time at some point this year to actually play with this! :)
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
OvermindDL1  
View profile  
 More options Feb 22 2012, 11:16 pm
From: OvermindDL1 <overmind...@gmail.com>
Date: Wed, 22 Feb 2012 21:16:38 -0700
Local: Wed, Feb 22 2012 11:16 pm
Subject: Re: [erlang-questions] Thoughts on EHE - the PHP killer
/* snip */

So I am curious at all this template stuff.  For years now I have been
writing my code as code and html/css/js/whatever as
html/css/js/whatever.  My latest example here at work I needed a
python parser to parse out some nasty SOAP crap from our phone system
and it ended up growing to the point where I actually wrote in a
mini-webserver (I cannot use Erlang here... yet... I am trying!).
Even in this tiny webserver I just take a request and server out json.
 If authentication needs to happen then I just return a 'keycode' that
should be sent with every request that should be authenticated, but
everything sent back in every single request is generated/cached json,
or a file out of the ../web directory (for the html/css/js/whatever).

I do not really have to 'remember' anything on the server side, I just
send what is requested.  Only thing that I really have to remember on
the browser side is the order and entries and such that the json has
when it is sent back.  I just make heavy use of jquery.  All my code
on both the server and the client is *very* simple (practically
stupid-simple for all the 'ooo's and 'ahh's it is getting), very
self-contained, and very easy to modify, as well as it would be easy
to modify the html/css/js/whatever by someone other than me (of which
I have already done by having someone add in jquery ui themes, which
added like 6 lines to each support html file).  Plus I could always
write something to access the servers API directly if I wanted.

But really, why templates?  Just let the server do what it does best,
server dumb files and processing of data to give to those dumb files.
Leave the dumb files to process the data as they wish, there is so
much javascript code and so many pure javascript html templating
languages out there, just let the UI people work their magic on that,
they know that stuff, and they know how to parse json with a jquery
call, that is all they need.  There is even a jquery for mobile
devices.  If you really want to make javascript-less pages, well, then
fall back to the old stuff that no one really uses anymore.  ;)

P.S.  I am *so* looking forward to a REST-style interface for yaws, I
basically keep remaking one of my own for each project.  Good session
management, although the 'capabilities' are not quite powerful enough
for my usage without a *lot* of boilerplate.
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fred Hebert  
View profile  
 More options Feb 23 2012, 8:10 am
From: Fred Hebert <monon...@gmail.com>
Date: Thu, 23 Feb 2012 08:10:21 -0500
Local: Thurs, Feb 23 2012 8:10 am
Subject: Re: [erlang-questions] Thoughts on EHE - the PHP killer

You may work with government agencies or just have public websites where
regulation forces you to support things like text readers and other tools
for disabled users. These can't easily work with JS-only methods. This is
also the case of some phone browsers that just won't support Javascript, or
won't support it well. Knowing your public is also rather important. For
Learn You Some Erlang, you'd be surprised how many comments about 'please
add syntax highlighting' I had before I added a <noscript> tag telling
users syntax highlight was done with JS. Some tech crowds seem quite fond
of noscript and other JS blockers. Different audiences have different
requirements.

Another reason might be a question of speed and/or efficiency. The things
that often cost the most for a client making a call to a server aren't the
processing time on the server, but generally the connection itself (and the
roundtrips), downloading visual assets, reading and running Javascript. As
such, it is entirely logical for some sites to prefer to have the text sent
as part of a template in a single trip that requires no additional logic
client-side than have it done in many calls then rendered afterwards. This
also reduces the costs required for serving data in most cases and reduces
the bandwidth; everyone wins.

Then you might have other things, like translations. Many templating
systems allow you to have different templates or sub-templates that can be
configured and have filters (custom or not) to help with different page
translations, a thing that as far as I know, isn't very well supported in
Javascript tools (or if it is, it is a recent development).

You could do it for ideological purity: HTML is for markup, CSS is for
styling, Javascript is only for more interactive parts and shouldn't be
about the structuring of the text or the styling itself. This kind of thing
is less and less common nowadays I think, though, and people tend not to
give a crap about that one as much anymore.

Things are also simpler to test using templates: you can just remove (or
later add in) the place-holders and variables and there is no need for you
to have a server or data coming from a mock server to be able to work on
your files. It is likely simpler to develop the front-end and the back-end
in parallel working with templates than requiring the backend guys to
set-up fake data sending (or yet, real data sending) to work with a
javascript set-up. Although it is in both cases possible to build the whole
HTML and then fit them into the final system, there is less change required
to do it from HTML -> Template than HTML ->
JSON-pulling-thing-that-pushes-it-back-inside-the-DOM.

Lastly, there is no need to encrypt, filter, format, or even transmit what
could be sensitive information that might be used to decide how to display
content. This is often dependent to how clever you want your templates to
be (very dumb vs. more powerful ones), but it's easy to think of a use case
for this. Maybe you profile information coming from the database contains
the hash and salts of passwords (or if you're better geared up, your bcrypt
or scrypt-based <https://github.com/ferd/erlpass> hashes ;) ). Although
this information is somewhat safe to have around, forwarding it to the
browser is often a bad idea. Using templates, you could just push the whole
'profile' record and let the designers not use it and the filtering is
implicit. This is usually much simpler and a general no-brainer.

I'm sure there are more reasons out there that support the idea of
templates, but I figure this sample is enough to prove a point?

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Toby Thain  
View profile  
 More options Feb 23 2012, 9:23 am
From: Toby Thain <t...@telegraphics.com.au>
Date: Thu, 23 Feb 2012 09:23:11 -0500
Local: Thurs, Feb 23 2012 9:23 am
Subject: Re: [erlang-questions] Thoughts on EHE - the PHP killer
On 22/02/12 11:16 PM, OvermindDL1 wrote:

> /* snip */

> So I am curious at all this template stuff.  For years now I have been
> writing my code as code and html/css/js/whatever as
> html/css/js/whatever. ...

> I do not really have to 'remember' anything on the server side, I just
> send what is requested. ...

> But really, why templates?  Just let the server do what it does best,
> server dumb files and processing of data to give to those dumb files.
> Leave the dumb files to process the data as they wish, there is so
> much javascript code and so many pure javascript html templating
> languages out there, just let the UI people work their magic on that,

Will your site work without JavaScript?

--T

> they know that stuff, and they know how to parse json with a jquery
> call, that is all they need....

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Watson  
View profile  
 More options Feb 23 2012, 6:57 pm
From: Tim Watson <watson.timo...@gmail.com>
Date: Thu, 23 Feb 2012 23:57:19 +0000
Local: Thurs, Feb 23 2012 6:57 pm
Subject: Re: [erlang-questions] Thoughts on EHE - the PHP killer
You are both right, of course. Server side methods for generating
dynamic content, such as templating, have their place. So do client
side technologies like jQuery, backbone and pure.js (and who knows how
many others). As you say Fred, it's about knowing your audience and
the constraints your solution needs to operate within. One approach
isn't right or wrong outside of the context in which it's being used.
Having said that, your list is a pretty cool rebuttal. :)

One thing I'd point out is that javascripty, ajaxy stuff doesn't have
to be chatty or slow. I've seen a client app that pulls large (10s of
mg) chunks of xml from the server at a time and renders them on the
client using XSLT. It wasn't particularly portable across browsers,
but to the credit of the guy that wrote it, it's bloody fast at
rendering large amounts of data.

Anyway, the answer to this is that there is not 'one way to do it' and
the best approach 'just depends' on lots of factors. This is why the
servlet API is successful - it is low level enough to let you build
any kind of application on top of it, but high level enough to avoid
getting stuck in the details or be tied to one implementation.

On 23 February 2012 13:10, Fred Hebert <monon...@gmail.com> wrote:

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages < Older 
« Back to Discussions « Newer topic     Older topic »