Apache "mod_d" needs C to instantiate D interpreter?

Nick Sabalausky a at a.a
Tue Nov 9 16:25:22 PST 2010


"Eric Poggel" <dnewsgroup2 at yage3d.net> wrote in message 
news:ibcn72$2u3r$1 at digitalmars.com...
> On 11/9/2010 12:17 AM, Nick Sabalausky wrote:
>> "Andrei Alexandrescu"<SeeWebsiteForEmail at erdani.org>  wrote in message
>> news:ibaepi$vfh$1 at digitalmars.com...
>>>
>>> People at Facebook told me that the adoption of D inside the company 
>>> might
>>> be helped if they could simply write<?d ... ?>  to insert D code into a
>>> page. I'm not sure how difficult such a plugin would be to implement.
>>
>> I'm very suprised by that. That's become considered very bad style by 
>> most
>> of the [professional] web dev world quite awhile ago, and for very good
>> reason. Rails-, django- and even ASP.NET-style "pass variables into an 
>> HTML
>> template" approaches have proven to be...well...frankly, much less 
>> shitty.
>>
>>
>
> I've always felt the opposite way.  It's been a while since I've worked 
> with Asp.net controls, but I remember something like this:
>
> <ul id="List"></ul>
> .....
> // Later, in C#
> for (int i=0; i<10; i++)
>     List.innerHtml += "<li>" + sanitize(someArray[i]) + "</li>"
>

Ouch, yea, that is awful (but I've done worse - I once tried to build HTML 
buy manually adding nodes to an XML DOM...it seemed like a good idea until I 
actually started doing it). I've done very little with ASP.NET, and it's 
been awhile since I've even looked at it, but my understanding is that 
you're supposed to do it more like this:

<!-- template for defining a List here -->
<ul id="List"></ul>

<!-- template for defining a ListElem here -->
<li id="ListElem"></li>

someListElem.innerHtml = sanitize(someArray[i])

Or something vaguely like that anyway. Yea, it's definitely still not as 
good as rails/django/haxeIgniter/etc, though. A good HTML templating system 
like what those use won't lead you to HTML-string-concatenation. I just 
mentioned ASP.NET because I seemed to remember it being template-based in 
some way.

> While php would do something like:
>
> <ul id="List">
>     <?php foreach($someArray as $item):?>
>         <li><?=sanitize($item)?></li>
>     <?php endforeach?>
> </ul>
>
> Granted, C# is a much nicer language than php, and when in php, I always 
> separate model and controller logic from the html view, but the "immediate 
> mode" of php embedding helps me avoid the awkwardness of building html 
> through string concatenations in another file.  I get to see the html 
> structure exactly as it is.
>

I could probably live with that as long as the "PHP template" stayed 
view-only and didn't grow too much logic.

> This is where people usually jump in and suggest a templating system, but 
> I think it's silly to invent a second language when the first is more than 
> up to the task.  I always find myself thinking:  I know how to do this in 
> php or java, but how do I do this in the templating language?
>
> I welcome counter-arguments.  Maybe I can be enlightened?

If you look up StringTemplate (related to ANTLR), there was a fairly 
convincing explanation, although the more I think about it, I can't remember 
what the hell it was (something about forcing excess logic to stay out of 
the view, I guess, maybe...honestly I totally forget).




More information about the Digitalmars-d mailing list