www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Apache "mod_d" needs C to instantiate D interpreter?

reply JFD <jfd nospam.com> writes:
A potential "mod_d" Apache module would go a long way to promote D language to
the web application world.

But it seems that implementing a "mod_d" Apache module may require that C
instantiates a D language interpreter (similar to Py_NewInterpreter() for
Python), or do the functionality of RDMD with compiled code caching, but in C.
 Is that possible?  (Presumably it might be possible to hack up a solution,
but could there be an officially supported way?)

I know that FastCGI with RDMD can do something similar, but a "mod_d" should
have higher system performance and scalability.

Thank you.  D is the best!  Keep up the good work.
Nov 08 2010
next sibling parent reply Daniel Gibson <metalcaedes gmail.com> writes:
JFD schrieb:
 A potential "mod_d" Apache module would go a long way to promote D language to
 the web application world.
 
 But it seems that implementing a "mod_d" Apache module may require that C
 instantiates a D language interpreter (similar to Py_NewInterpreter() for
 Python), or do the functionality of RDMD with compiled code caching, but in C.
  Is that possible?  (Presumably it might be possible to hack up a solution,
 but could there be an officially supported way?)
 
 I know that FastCGI with RDMD can do something similar, but a "mod_d" should
 have higher system performance and scalability.
 
 Thank you.  D is the best!  Keep up the good work.
 

A FastCGI solution could be used with other webservers as well. I don't know how Apache modules work, but instantiating a D language interpreter sounds strange, because D isn't an interpreted language. "Interpreting" D code may work as well by compiling it when invoked (like rdmd does).. but I don't know if you wanna do something like that on a web server. It may be possible to code your web application in D and make it an apache module, so you'd have one module per application.. Or maybe one could write a module that loads shared libraries that may be written in D? Cheers, - Daniel
Nov 08 2010
next sibling parent reply JFD <jfd nospam.com> writes:
Yes, you're right.  One should implement Apache module in D.

One thing is that Apache module entry point expects a "C" function.  I've figure
that that one could just add extern(C) in front of D function to be callable
from
C, so that was easy.  Also, Apache expects .so shared library, and one could
build
it roughly like this:

Let DMD build a .a library:
dmd -fPIC -lib libhello.d

Then convert it to shared library:
gcc -shared -Wl,-soname,libhello.so.0 -o libhello.so.0.0 libhello.a

Could DMD build .so shared library directly (did I miss something)?

Then it's all D from there on.  Cool!

Thank you.
Nov 08 2010
next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 11/8/10 4:37 PM, JFD wrote:
 Yes, you're right.  One should implement Apache module in D.

 One thing is that Apache module entry point expects a "C" function.  I've
figure
 that that one could just add extern(C) in front of D function to be callable
from
 C, so that was easy.  Also, Apache expects .so shared library, and one could
build
 it roughly like this:

 Let DMD build a .a library:
 dmd -fPIC -lib libhello.d

 Then convert it to shared library:
 gcc -shared -Wl,-soname,libhello.so.0 -o libhello.so.0.0 libhello.a

 Could DMD build .so shared library directly (did I miss something)?

 Then it's all D from there on.  Cool!

 Thank you.

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. Also, D code should be able to call PHP code (which is a bit less difficult than it seems because we use HPHP, a PHP to C++ translator). Andrei
Nov 08 2010
next sibling parent reply "Nick Sabalausky" <a a.a> writes:
"Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote in message 
news:ibaepi$vfh$1 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.
Nov 08 2010
next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 11/8/10 9:17 PM, Nick Sabalausky wrote:
 "Andrei Alexandrescu"<SeeWebsiteForEmail erdani.org>  wrote in message
 news:ibaepi$vfh$1 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'm simplifying matters a fair amount. Indeed mixing php with hardcoded html has been mostly removed from the code base. The point remains that easily writing D code that gets executed to load a page would be a boon. Andrei
Nov 08 2010
parent "Nick Sabalausky" <a a.a> writes:
"Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote in message 
news:ibam3u$1b5c$1 digitalmars.com...
 On 11/8/10 9:17 PM, Nick Sabalausky wrote:
 "Andrei Alexandrescu"<SeeWebsiteForEmail erdani.org>  wrote in message
 news:ibaepi$vfh$1 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'm simplifying matters a fair amount. Indeed mixing php with hardcoded html has been mostly removed from the code base. The point remains that easily writing D code that gets executed to load a page would be a boon.

I see. Although I haven't had a chance to start on it yet, one of my top "pet project" priorities isto take Adam Rupee's web-related code and turn it into a rails/django-like thing. It's been by dream for far too long now to use D for my web development work.
Nov 08 2010
prev sibling next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 11/8/10 10:36 PM, spir wrote:
 On Tue, 9 Nov 2010 00:17:48 -0500
 "Nick Sabalausky"<a a.a>  wrote:

 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.

For sure. See "Enforcing Strict Model-View Separation in Template Engines" http://www.cs.usfca.edu/~parrt/papers/mvc.templates.pdf

Love that work. Andrei
Nov 08 2010
parent reply "Nick Sabalausky" <a a.a> writes:
"Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote in message 
news:ibark6$1k38$1 digitalmars.com...
 On 11/8/10 10:36 PM, spir wrote:
 On Tue, 9 Nov 2010 00:17:48 -0500
 "Nick Sabalausky"<a a.a>  wrote:

 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.

For sure. See "Enforcing Strict Model-View Separation in Template Engines" http://www.cs.usfca.edu/~parrt/papers/mvc.templates.pdf

Love that work.

Ahh, I see that's written by the ANTLR/StringTemplate guy. I never read that paper, but the docs for his StringTemplate were a big part of what convinced me that template engines shouldn't try to be full-fledged imperative programming languages.
Nov 08 2010
parent reply sybrandy <sybrandy gmail.com> writes:
 Ahh, I see that's written by the ANTLR/StringTemplate guy. I never read that
 paper, but the docs for his StringTemplate were a big part of what convinced
 me that template engines shouldn't try to be full-fledged imperative
 programming languages.

I've done web development for a chunk of my career and I have to agree. To me, there should be a clean separation between code and templates. Templates that have looping in them are garbage to me as now you have logic in two different places. The best templating solution that I've seen is Template::Recall for Perl (http://search.cpan.org/~gilad/Template-Recall-0.15/lib/Template/Recall.pm) In this case, there is no logic in the template. You "render" the different parts of the template as needed and you have full control within your code. To me, something like this should be part of the standard library as it would make outputting formatted text much easier in those cases where there is a standardized format, like XML or HTML. Casey
Nov 09 2010
parent "Nick Sabalausky" <a a.a> writes:
"sybrandy" <sybrandy gmail.com> wrote in message 
news:ibbkh3$fvh$1 digitalmars.com...
 Ahh, I see that's written by the ANTLR/StringTemplate guy. I never read 
 that
 paper, but the docs for his StringTemplate were a big part of what 
 convinced
 me that template engines shouldn't try to be full-fledged imperative
 programming languages.

I've done web development for a chunk of my career and I have to agree. To me, there should be a clean separation between code and templates. Templates that have looping in them are garbage to me as now you have logic in two different places. The best templating solution that I've seen is Template::Recall for Perl (http://search.cpan.org/~gilad/Template-Recall-0.15/lib/Template/Recall.pm) In this case, there is no logic in the template. You "render" the different parts of the template as needed and you have full control within your code. To me, something like this should be part of the standard library as it would make outputting formatted text much easier in those cases where there is a standardized format, like XML or HTML.

Judging by that link, yea, that sounds a lot like StringTemplate: http://www.antlr.org/wiki/display/ST/StringTemplate+Documentation
Nov 10 2010
prev sibling next sibling parent Jacob Carlborg <doob me.com> writes:
On 2010-11-09 06:17, Nick Sabalausky wrote:
 "Andrei Alexandrescu"<SeeWebsiteForEmail erdani.org>  wrote in message
 news:ibaepi$vfh$1 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.

You will always need some kind of code in the views, to print out the contents of the models, if you don't go with the Lift approach and creating new HTML tags. -- /Jacob Carlborg
Nov 09 2010
prev sibling next sibling parent reply Eric Poggel <dnewsgroup2 yage3d.net> writes:
On 11/9/2010 12:17 AM, Nick Sabalausky wrote:
 "Andrei Alexandrescu"<SeeWebsiteForEmail erdani.org>  wrote in message
 news:ibaepi$vfh$1 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>" 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. 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?
Nov 09 2010
next sibling parent reply "Nick Sabalausky" <a a.a> writes:
"Eric Poggel" <dnewsgroup2 yage3d.net> wrote in message 
news:ibcn72$2u3r$1 digitalmars.com...
 On 11/9/2010 12:17 AM, Nick Sabalausky wrote:
 "Andrei Alexandrescu"<SeeWebsiteForEmail erdani.org>  wrote in message
 news:ibaepi$vfh$1 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).
Nov 09 2010
next sibling parent reply Eric Poggel <dnewsgroup2 yage3d.net> writes:
On 11/9/2010 7:25 PM, Nick Sabalausky wrote:
 I could probably live with that as long as the "PHP template" stayed
 view-only and didn't grow too much logic.

Are there any web-friendly languages that are mature, offer the sanity and static typing of C#, and the "immediate mode" of php?
Nov 09 2010
next sibling parent reply "Nick Sabalausky" <a a.a> writes:
"Eric Poggel" <dnewsgroup2 yage3d.net> wrote in message 
news:ibd00s$dli$1 digitalmars.com...
 On 11/9/2010 7:25 PM, Nick Sabalausky wrote:
 I could probably live with that as long as the "PHP template" stayed
 view-only and didn't grow too much logic.

Are there any web-friendly languages that are mature, offer the sanity and static typing of C#, and the "immediate mode" of php?

I doubt it. The only "php immediate mode" stuff I'm aware of PHP itself, and classic-style ASP using either VBScript or JScript (And sort of ColdFusion, but you'd probably just be better off with PHP). The unpopularity of that style probably means that nothing else like that is in the works. And web-oriended languages seem to usually be dynamic aside from the Java and ASP.NET camps.
Nov 09 2010
next sibling parent Roman Ivanov <one example.com> writes:
== Quote from Nick Sabalausky (a a.a)'s article
 "Eric Poggel" <dnewsgroup2 yage3d.net> wrote in message
 news:ibd00s$dli$1 digitalmars.com...
 On 11/9/2010 7:25 PM, Nick Sabalausky wrote:
 I could probably live with that as long as the "PHP template" stayed
 view-only and didn't grow too much logic.

Are there any web-friendly languages that are mature, offer the sanity and static typing of C#, and the "immediate mode" of php?

classic-style ASP using either VBScript or JScript (And sort of ColdFusion, but you'd probably just be better off with PHP). The unpopularity of that style probably means that nothing else like that is in the works. And web-oriended languages seem to usually be dynamic aside from the Java and ASP.NET camps.

== Quote from Nick Sabalausky (a a.a)'s article
 "Eric Poggel" <dnewsgroup2 yage3d.net> wrote in message
 news:ibd00s$dli$1 digitalmars.com...
 On 11/9/2010 7:25 PM, Nick Sabalausky wrote:
 I could probably live with that as long as the "PHP template" stayed
 view-only and didn't grow too much logic.

Are there any web-friendly languages that are mature, offer the sanity and static typing of C#, and the "immediate mode" of php?

classic-style ASP using either VBScript or JScript

Ahem... http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx
Nov 10 2010
prev sibling parent Adam Ruppe <destructionator gmail.com> writes:
Eric Poggel wrote:
 Are there any web-friendly languages that are mature, offer the sanity and
 static typing of C#, and the "immediate mode" of php?

We could do it in D, somewhat easily. Here's an implementation with only mild bugginess: === import std.file; import std.string; import std.stdio; import std.process; void main(string[] args) { string imports = q{ import std.stdio; import std.string; import std.file; import std.conv; import std.algorithm; import std.date; }; string mainf = `void main(string[] args) {`; bool inD = false; string currentLiteral = ""; string currentPrinter = ""; void addToCurrentLiteral(string s) { currentLiteral ~= s.replace("`", "`~\"`\"~`"); } void outputCurrentLiteral() { if(currentLiteral.length == 0) return; mainf ~= "writef(\"%s\", `"~currentLiteral~"`);"; currentLiteral.length = 0; } void appendCode(string line) { outputCurrentLiteral; if(line.length > 6 && line[0..6] == "import") imports ~= line; else mainf ~= line; } foreach(ln; stdin.byLine) { string line = ln.idup ~ "\n"; modeSwitch: if(line.length == 0) continue; if(!inD) { int idx = line.indexOf("<?"); if(idx == -1) { addToCurrentLiteral(line); } else { char c = line[idx+2]; switch(c) { case 'd': addToCurrentLiteral(line[0..idx]); inD = true; line = line[idx + 3 .. $]; goto modeSwitch; break; case '=': addToCurrentLiteral(line[0..idx]); int end = line[idx+2..$].indexOf("?>"); if(end == -1) throw new Exception("<?= ?> must be on one line"); end += idx + 2; outputCurrentLiteral; mainf ~= `writef("%s", `~line[idx+3..end].replace(`"`, `\"`)~`);`; line = line[end+2..$]; goto modeSwitch; break; default: addToCurrentLiteral(line); } } } else { int idx = line.indexOf("?>"); if(idx == -1) { appendCode(line); } else { appendCode(line[0..idx]); line = line[idx+2..$]; inD = false; goto modeSwitch; } } } outputCurrentLiteral; mainf ~= `}`; std.file.write("/tmp/tempdprog.d", imports ~ mainf); system("dmd -run /tmp/tempdprog.d"); } === Here's an example of use: ====== $ cat test.dhp hello world <?d auto eat = "eat me!"; ?> this is awful <?=eat?> <?d string functionsWorkToo() { return "because nested functions rock!"; } writeln(functionsWorkToo()); ?> Bye! ======= And running it: ====== $ cat test.dhp | ./dhp hello world this is awful eat me! because nested functions rock! Bye! ======== Of course, you'll want to add an automatic import for a cgi module so that's available, and change the writefs to cgi.outs or whatever, but that's easy. (You could use mine: http://arsdnet.net/dcode/cgi.d or your own) The big bug I know of is if the ?> appears in a quoted string it'll screw up. But meh, it's a 15 minute implementation. A huge improvement would be to send the code to rdmd instead of a temp file then dmd like I did here. rdmd will cache the executable and give it a unique temporary name so it will be faster and less prone to overwrites. But that just now came to my mind... To use it like php, you'd just add an apache handler to treat those dhp files as a CGI application... and you might need to add a shebang to the top too so the OS knows what program to run. A tiny apache module could probably get rid of the shebang requirement. But this shows that it isn't terribly hard to make it work at least a little. btw, loops work too: === Hello <?d foreach(i; 0..5) { ?> Loops work too, like in PHP (<?= i ?>). Well, sort of; you don't have to terminate it here which might be confusing. I saw add the braces anyway. <?d } ?> Bye! ======= Prints out that inner text 5 times, as you'd expect... as long as you keep the braces. Without the braces, it will only print the first part of the literal. (Consider how the program works - take blocks of text and put out a write statement for them. A foreach without braces would only call the first write; the others are outside the loop.)
Nov 10 2010
prev sibling parent Jacob Carlborg <doob me.com> writes:
On 2010-11-10 03:28, Eric Poggel wrote:
 On 11/9/2010 7:25 PM, Nick Sabalausky wrote:
 I could probably live with that as long as the "PHP template" stayed
 view-only and didn't grow too much logic.

Are there any web-friendly languages that are mature, offer the sanity and static typing of C#, and the "immediate mode" of php?

Scala using the Lift framework perhaps. Scala has built in support for XML literals. Acutally I think Lift is more into the idea of creating new HTML-tags instead of mixing Scala and HTML. -- /Jacob Carlborg
Nov 10 2010
prev sibling next sibling parent Jacob Carlborg <doob me.com> writes:
On 2010-11-10 01:25, Nick Sabalausky wrote:
 "Eric Poggel"<dnewsgroup2 yage3d.net>  wrote in message
 news:ibcn72$2u3r$1 digitalmars.com...
 On 11/9/2010 12:17 AM, Nick Sabalausky wrote:
 "Andrei Alexandrescu"<SeeWebsiteForEmail erdani.org>   wrote in message
 news:ibaepi$vfh$1 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.

As far as I know you could create a framework using ASP.NET that is as good as rails/django/haxeIgniter/etc. You could write almost the same could as the PHP example below in ASP.NET, just replace <?php with <% and <?= with <%=. Although it will look somewhat ugly at the end with <% } %>
 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).

-- /Jacob Carlborg
Nov 10 2010
prev sibling parent Adam Ruppe <destructionator gmail.com> writes:
Nick Sabalausky wrote:
 (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).

This is actually one of the methods I've been using in my D web apps throughout the year. It's not that bad if you extend DOM with D. Compare: auto table = cast(Table) document.getElementById("mytable"); assert(table !is null); foreach(item; myArray) { table.appendRow(th(item.id), new Link(item.name, "myappurl", ["mode": "view-item-details", "id" : to!string(item.id)), item.owner, item.comments.brief); } With the godawful equivalent in Javascript. The DOM extensions also make multi-page forms trivial: auto form = cast(Form) document.getElementById("my-form"); assert(form !is null); foreach(k, v; cgi.post) form.setValue(k, v); That adds all the data POSTed in to the form. form.setValue is smart enough to work with existing fields, or add new ones as hidden inputs. (Existing fields including check boxes, selects, radio groups, etc. It Just Works with just about any html.) I used to dread having to make edit capabilities. <input type="text" name="whatever" value="<?= $myVal" /> And setting myVal and repeating over and over and over and over and over and over and over again. Then the hell: <input type="checkbox" name="sucky" <?php if(isset($_POST['sucky'])) echo 'checked="checked"; else echo ''; ?> /> Then hell isn't strong enough of a word. <select><option value="1" <?= ($value == 1) ? "selected" : ""?>>blah</option> REPEAT REPEAT REPEAT </select> Now, I can just use the two line loop and it works in all cases. Another huge benefit of the extended dom is: h2.innerText = myTitle; The innerText property, a MS extension in Javascript, automatically escapes the string for safe output (like all DOM methods, except for innerHTML itself) and is easy to use. No: h2.appendChild(document.createTextNode(myTitle)); Ugh. Anyway with a few little DOM extensions, this actually becomes quite usable. It isn't always perfect, so my code also has variables in the template: {$myVar} in the html and in the D, document.vars["myVar"] = to!string(whatever); Naturally, the template variables are all automatically escaped. The last thing I added are a could special html tags and attributes. <include file="blah" /> to share template files. <table class="striped"> <ul class="striped"> etc.etc. Elements with the striped class get every other relevant child marked with class="odd", so I can add the color or whatever in the css file: table.striped .odd { background-color: teal; color: red !important; } (lol colors) The program is smart enough to mark only the correct elements as .odd. If it is ul.striped, it gets every other immediate li child. For a table, it goes for table
 tbody > tr.odd.

(This reminds me: document.getElementsBySelector() is a godsend extension too.) But, generally, what other templates solve with loops or recursion, I try to solve with classes and css. We've been live for 8 months now, and I haven't felt the need to add looping to my template. The closest I have is: <list from="collection" format="html output format for each element" /> But even this very rarely actually specifies the format: the context-aware code does the right thing in most situations, and when it doesn't, it tends to be a one or two line DOM fixup anyway. "Doesn't this violate Model and View separation???" No, I don't think so. The HTML at this level is extremely minimal, if any is specified in the code at all. It only decorates the semantics of the data, which isn't really view related. Give it just enough markup so the stylesheet can take over without needing to pull your hair out. I wonder how many of the HTML template solutions were made by people who don't understand CSS. CSS can't really do all the work by itself, so you keep the html framework around it, but when it comes down to styling individual data elements, CSS is really very good at it. If you are changing the html to change your view at that level, I'd say you're doing it wrong, template or no template.
Nov 10 2010
prev sibling next sibling parent Jacob Carlborg <doob me.com> writes:
On 2010-11-10 00:57, Eric Poggel wrote:
 On 11/9/2010 12:17 AM, Nick Sabalausky wrote:
 "Andrei Alexandrescu"<SeeWebsiteForEmail erdani.org> wrote in message
 news:ibaepi$vfh$1 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>" While php would do something like: <ul id="List"> <?php foreach($someArray as $item):?> <li><?=sanitize($item)?></li> <?php endforeach?> </ul>

I would as well. I don't think it's wrong adding a some code to the views to help write HTML, the example above is a perfect example.
 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.

 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?

Isn't a PHP kind of a template system? It's created for web development and to be able to mix HTML and PHP out of the box. -- /Jacob Carlborg
Nov 10 2010
prev sibling parent sybrandy <sybrandy gmail.com> writes:
On 11/09/2010 06:57 PM, Eric Poggel wrote:
 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>"

 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.

 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?

No offense, but I don't even like the C# solution. It's still mixing the formatting with code. As I stated in a different reply in this thread, Perls Template::Recall on CPAN is the best templating solution I've found as it completely separates the template from the code. Also, it's not tied to just HTML/XML, so it can be used for a variety of purposes. Lastly, by having the separation of code and template, one person can be responsible for designing the HTML for the web page while another can populate the HTML. If the HTML changes, it can be done in a way that the code does not change. Casey
Nov 10 2010
prev sibling next sibling parent Roman Ivanov <isroman.DEL ETE.km.ru> writes:
On 11/9/2010 12:17 AM, Nick Sabalausky wrote:
 "Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote in message 
 news:ibaepi$vfh$1 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.

AFAIK, Ruby uses imperative erb templates. ASP.NET developers also slowly move from WebForms mess towards much more structured ASP.NET MVC, which uses executable code for templates.
Nov 09 2010
prev sibling parent Roman Ivanov <isroman.DEL ETE.km.ru> writes:
On 11/9/2010 1:36 AM, spir wrote:
 On Tue, 9 Nov 2010 00:17:48 -0500
 "Nick Sabalausky" <a a.a> wrote:
 
 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.

For sure. See "Enforcing Strict Model-View Separation in Template Engines" http://www.cs.usfca.edu/~parrt/papers/mvc.templates.pdf Denis -- -- -- -- -- -- -- vit esse estrany ☣ spir.wikidot.com

I wanted to write a long, detailed reply on this subject, but never got enough time. So I want to write a shorter reply before it's too late. Sorry for the bullet list, I had trouble making it more coherent. 1. You cannot truly enforce Model-View separation by restricting what can be done inside templates. Programmers can still put presentation code inside controllers (and inside other parts of their code), which breaks Model-View separation. 2. There have been many attempts to introduce more or less "pure" templating systems in various languages. PHP has Smarty. ASP has WebForms. The real benefits of such systems just don't live up to the expectations. WebForms, for example, is responsible for creation of many truly horrendous "legacy" systems. They were too restrictive, so programmers resolved to hackish workarounds. In the long run, the developer community responded by creating new template systems (Savant for PHP, MVC/Razor for ASP) that used the host language for templating. 3. The purpose of a templating enging shouldn't be to separate HTML from code. It should be separation of presentation logic from the rest of application logic. And yes, you can do that with restricted templates, but you also can do it with Turing-complete ones. It's possible to create a mess with both of these approaches too. 4. The particular system described in the paper relies on Turing-complete "render" (I would call it pre-render) phase for doing complex processing of data before display. This can be abused just like embedded code is abused. 5. Practical questions should be addressed. If I use templating system A vs B in a real-life environment, which one would result in a more maintainable system design overall? (Having "clean" templates and horrendous mess of hacks that supports it is hardly an achievement, right?) Which one would allow me, while creating real websites, to do my work in less time? Learning curve is not to be sneered at as well. 6. Here are couple of uses cases which I don't think the described system wouldn't handle very well. Let's say you have pagination on your website. Displaying page numbers is clearly a matter of presentation, not controller logic. However, since you can't do any computation in templates, you wouldn't be able to calculate page numbers of interest. Another case is internationalization. Internationalized strings are not "models" that you pass into templates, yet they need to be mutable. There are many solutions to this, but I don't see any of them fitting the system in the paper. ... I'm not arguing in favor of random spaghetti code, but I would argue that in many cases Turing-complete templates are simpler to use without any considerable degradation of maintainability.
Nov 24 2010
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2010-11-09 04:21, Andrei Alexandrescu wrote:
 On 11/8/10 4:37 PM, JFD wrote:
 Yes, you're right. One should implement Apache module in D.

 One thing is that Apache module entry point expects a "C" function.
 I've figure
 that that one could just add extern(C) in front of D function to be
 callable from
 C, so that was easy. Also, Apache expects .so shared library, and one
 could build
 it roughly like this:

 Let DMD build a .a library:
 dmd -fPIC -lib libhello.d

 Then convert it to shared library:
 gcc -shared -Wl,-soname,libhello.so.0 -o libhello.so.0.0 libhello.a

 Could DMD build .so shared library directly (did I miss something)?

 Then it's all D from there on. Cool!

 Thank you.

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. Also, D code should be able to call PHP code (which is a bit less difficult than it seems because we use HPHP, a PHP to C++ translator). Andrei

Can't DMD already compile D code embedded in HTML: http://www.digitalmars.com/d/2.0/html.html ? -- /Jacob Carlborg
Nov 09 2010
next sibling parent reply JFD <jfd nospam.com> writes:
 Can't DMD already compile D code embedded in HTML:
 http://www.digitalmars.com/d/2.0/html.html ?

I tried the sample at the link, but got error. I also tried it without the HTML code inside. Am I missing something? $ dmd hello.html Error: module hello html source files is deprecated hello.html hello.html: -------------- <html> <body> <code> import std.stdio; int main() { writefln("Hello world"); return 0; } </code> </body> </html> -------------- -or- -------------- import std.stdio; int main() { writefln("Hello world"); return 0; } --------------
Nov 09 2010
parent Robert Clipsham <robert octarineparrot.com> writes:
On 09/11/10 14:24, JFD wrote:
 Can't DMD already compile D code embedded in HTML:
 http://www.digitalmars.com/d/2.0/html.html ?

I tried the sample at the link, but got error. I also tried it without the HTML code inside. Am I missing something? $ dmd hello.html Error: module hello html source files is deprecated hello.html hello.html: -------------- <html> <body> <code> import std.stdio; int main() { writefln("Hello world"); return 0; } </code> </body> </html> -------------- -or- -------------- import std.stdio; int main() { writefln("Hello world"); return 0; } --------------

Which version of dmd are you using? That code is for D 1.0/Phobos. You'll need to replace writefln with writeln for D2. -- Robert http://octarineparrot.com/
Nov 09 2010
prev sibling parent reply "Nick Sabalausky" <a a.a> writes:
"Jacob Carlborg" <doob me.com> wrote in message 
news:ibbjmv$e8p$1 digitalmars.com...
 On 2010-11-09 04:21, Andrei Alexandrescu wrote:
 On 11/8/10 4:37 PM, JFD wrote:
 Yes, you're right. One should implement Apache module in D.

 One thing is that Apache module entry point expects a "C" function.
 I've figure
 that that one could just add extern(C) in front of D function to be
 callable from
 C, so that was easy. Also, Apache expects .so shared library, and one
 could build
 it roughly like this:

 Let DMD build a .a library:
 dmd -fPIC -lib libhello.d

 Then convert it to shared library:
 gcc -shared -Wl,-soname,libhello.so.0 -o libhello.so.0.0 libhello.a

 Could DMD build .so shared library directly (did I miss something)?

 Then it's all D from there on. Cool!

 Thank you.

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. Also, D code should be able to call PHP code (which is a bit less difficult than it seems because we use HPHP, a PHP to C++ translator). Andrei

Can't DMD already compile D code embedded in HTML: http://www.digitalmars.com/d/2.0/html.html ?

I seem to remember hearing that was being depricated. And it was never anything like what Andrei's describing. IIRC, all it did was completely ignore all the HTML stuff (ie, treat it like comments). It didn't send it to Stdout or anything.
Nov 09 2010
parent Walter Bright <newshound2 digitalmars.com> writes:
Nick Sabalausky wrote:
 I seem to remember hearing that was being depricated. And it was never 
 anything like what Andrei's describing. IIRC, all it did was completely 
 ignore all the HTML stuff (ie, treat it like comments). It didn't send it to 
 Stdout or anything.

Right. It was not a good idea.
Nov 09 2010
prev sibling next sibling parent Walter Bright <newshound2 digitalmars.com> writes:
JFD wrote:
 Yes, you're right.  One should implement Apache module in D.
 
 One thing is that Apache module entry point expects a "C" function.  I've
figure
 that that one could just add extern(C) in front of D function to be callable
from
 C, so that was easy.  Also, Apache expects .so shared library, and one could
build
 it roughly like this:
 
 Let DMD build a .a library:
 dmd -fPIC -lib libhello.d
 
 Then convert it to shared library:
 gcc -shared -Wl,-soname,libhello.so.0 -o libhello.so.0.0 libhello.a
 
 Could DMD build .so shared library directly (did I miss something)?
 
 Then it's all D from there on.  Cool!
 
 Thank you.

One way to make it work is to take a page from how rdmd works. Write the plugin in C, have it simply feed its arguments to the dmd compiler, execute, then collect the output of the executable.
Nov 09 2010
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2010-11-09 01:37, JFD wrote:
 Yes, you're right.  One should implement Apache module in D.

 One thing is that Apache module entry point expects a "C" function.  I've
figure
 that that one could just add extern(C) in front of D function to be callable
from
 C, so that was easy.  Also, Apache expects .so shared library, and one could
build
 it roughly like this:

 Let DMD build a .a library:
 dmd -fPIC -lib libhello.d

 Then convert it to shared library:
 gcc -shared -Wl,-soname,libhello.so.0 -o libhello.so.0.0 libhello.a

 Could DMD build .so shared library directly (did I miss something)?

 Then it's all D from there on.  Cool!

 Thank you.

Dynamic libraries doesn't work currently with DMD on Linux. They do work with DMD using Tango on Mac OS X where DMD also can build dynamic libraries directly (with the -dylib flag). -- /Jacob Carlborg
Nov 09 2010
parent JFD <jfd nospam.com> writes:
== Quote from Jacob Carlborg (doob me.com)'s article
 On 2010-11-09 01:37, JFD wrote:
 Yes, you're right.  One should implement Apache module in D.

 One thing is that Apache module entry point expects a "C" function.  I've
figure
 that that one could just add extern(C) in front of D function to be callable
from
 C, so that was easy.  Also, Apache expects .so shared library, and one could
build
 it roughly like this:

 Let DMD build a .a library:
 dmd -fPIC -lib libhello.d

 Then convert it to shared library:
 gcc -shared -Wl,-soname,libhello.so.0 -o libhello.so.0.0 libhello.a

 Could DMD build .so shared library directly (did I miss something)?

 Then it's all D from there on.  Cool!

 Thank you.

with DMD using Tango on Mac OS X where DMD also can build dynamic libraries directly (with the -dylib flag).

I did some tests, here's the result: Apache module (.so shared library) written in C is working fine when linked with D shared library built by GDC (4.3.4), as something like this: gdc -fPIC -c libfoo.d -o libfoo.o gdc -shared -Wl,-soname,libfoo.so.0 \ -o libfoo.so.0.0 libfoo.o -lc It looks like one could potentially also write the Apache module entirely in D, too, after matching some data types, but I haven't tried it yet. Too cool! Someone could start writing Apache module for D language web applications anytime... :) I can call GDC-built D shared library from C executable or C shared library without problem. And it's working with phobos. It appears that DMD currently cannot create shared library on Linux, as you said. It can however create static library (.a) as above. C executable program is working fine with it. But C shared library that calls D static library gets stack error when the shared library is loaded.
Nov 10 2010
prev sibling next sibling parent Torarin <torarind gmail.com> writes:
2010/11/9 Andrei Alexandrescu <SeeWebsiteForEmail erdani.org>:
 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. Also,
 D code should be able to call PHP code (which is a bit less difficult than
 it seems because we use HPHP, a PHP to C++ translator).

 Andrei

I got the impression that Facebook does not use Apache for serving php pages since Hiphop runs programs in their own server (using libev, I think)? And FastCGI is really just an awkward reincarnation of HTTP. So perhaps the optimal situation is to have D interface with the web not through a plugin, but rather through an HTTP server class. If necessary, it can then sit behind an Apache proxy.
Nov 08 2010
prev sibling parent reply spir <denis.spir gmail.com> writes:
On Tue, 9 Nov 2010 00:17:48 -0500
"Nick Sabalausky" <a a.a> wrote:

 People at Facebook told me that the adoption of D inside the company mi=


 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. =


=20
 I'm very suprised by that. That's become considered very bad style by mos=

 of the [professional] web dev world quite awhile ago, and for very good=20
 reason. Rails-, django- and even ASP.NET-style "pass variables into an HT=

 template" approaches have proven to be...well...frankly, much less shitty.

For sure. See "Enforcing Strict Model-View Separation in Template Engines" = http://www.cs.usfca.edu/~parrt/papers/mvc.templates.pdf Denis -- -- -- -- -- -- -- vit esse estrany =E2=98=A3 spir.wikidot.com
Nov 08 2010
parent "Nick Sabalausky" <a a.a> writes:
"spir" <denis.spir gmail.com> wrote in message 
news:mailman.201.1289284596.21107.digitalmars-d puremagic.com...
 On Tue, 9 Nov 2010 00:17:48 -0500
 "Nick Sabalausky" <a a.a> wrote:

 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.

For sure. See "Enforcing Strict Model-View Separation in Template Engines" http://www.cs.usfca.edu/~parrt/papers/mvc.templates.pdf

The funny thing is, ColdFusion actually came pretty close (at least in general concept). It had mostly the right idea (DBMS for the model and HTML templates for the view), but where it shot itself in the foot was giving little-to-no control over the "Controller" part of MVC.
Nov 08 2010
prev sibling parent reply Radu <rr foo.bar> writes:
On 11/8/2010 11:45 PM, JFD wrote:
 A potential "mod_d" Apache module would go a long way to promote D language to
 the web application world.

 But it seems that implementing a "mod_d" Apache module may require that C
 instantiates a D language interpreter (similar to Py_NewInterpreter() for
 Python), or do the functionality of RDMD with compiled code caching, but in C.
   Is that possible?  (Presumably it might be possible to hack up a solution,
 but could there be an officially supported way?)

 I know that FastCGI with RDMD can do something similar, but a "mod_d" should
 have higher system performance and scalability.

 Thank you.  D is the best!  Keep up the good work.

My experience with Wt ( http://www.webtoolkit.eu/wt ) was quite nice. Mind that its more than a simple template system and brings quite a few advanced idioms to the table like signal/slots, components, adaptive degradation for rendering ( uses Ajax and server push were available ). They also have a nice set of ports for Java and Ruby, maybe D would fit nicely among them. /Radu
Nov 10 2010
parent reply "Nick Sabalausky" <a a.a> writes:
"Radu" <rr foo.bar> wrote in message news:ibe95h$gld$1 digitalmars.com...
 On 11/8/2010 11:45 PM, JFD wrote:
 A potential "mod_d" Apache module would go a long way to promote D 
 language to
 the web application world.

 But it seems that implementing a "mod_d" Apache module may require that C
 instantiates a D language interpreter (similar to Py_NewInterpreter() for
 Python), or do the functionality of RDMD with compiled code caching, but 
 in C.
   Is that possible?  (Presumably it might be possible to hack up a 
 solution,
 but could there be an officially supported way?)

 I know that FastCGI with RDMD can do something similar, but a "mod_d" 
 should
 have higher system performance and scalability.

 Thank you.  D is the best!  Keep up the good work.

My experience with Wt ( http://www.webtoolkit.eu/wt ) was quite nice. Mind that its more than a simple template system and brings quite a few advanced idioms to the table like signal/slots, components, adaptive degradation for rendering ( uses Ajax and server push were available ). They also have a nice set of ports for Java and Ruby, maybe D would fit nicely among them.

Very interesting. Reminds me of ASP.NET in that it tries to work at "stateful widget" level, except (from a brief glance at the homepage) it looks like it may actually pull it off and be something I could actually trust. I'm definitely going to dig further into that.
Nov 10 2010
parent reply "Nick Sabalausky" <a a.a> writes:
"Nick Sabalausky" <a a.a> wrote in message 
news:ibev09$1vf5$1 digitalmars.com...
 "Radu" <rr foo.bar> wrote in message news:ibe95h$gld$1 digitalmars.com...
 On 11/8/2010 11:45 PM, JFD wrote:
 A potential "mod_d" Apache module would go a long way to promote D 
 language to
 the web application world.

 But it seems that implementing a "mod_d" Apache module may require that 
 C
 instantiates a D language interpreter (similar to Py_NewInterpreter() 
 for
 Python), or do the functionality of RDMD with compiled code caching, but 
 in C.
   Is that possible?  (Presumably it might be possible to hack up a 
 solution,
 but could there be an officially supported way?)

 I know that FastCGI with RDMD can do something similar, but a "mod_d" 
 should
 have higher system performance and scalability.

 Thank you.  D is the best!  Keep up the good work.

My experience with Wt ( http://www.webtoolkit.eu/wt ) was quite nice. Mind that its more than a simple template system and brings quite a few advanced idioms to the table like signal/slots, components, adaptive degradation for rendering ( uses Ajax and server push were available ). They also have a nice set of ports for Java and Ruby, maybe D would fit nicely among them.

Very interesting. Reminds me of ASP.NET in that it tries to work at "stateful widget" level, except (from a brief glance at the homepage) it looks like it may actually pull it off and be something I could actually trust. I'm definitely going to dig further into that.

Hmm, I see it's GPL, though. Maybe it's unwarranted, but GPL makes me *really* nervous.
Nov 10 2010
parent Radu <rr foo.bar> writes:
On 11/10/2010 10:47 PM, Nick Sabalausky wrote:
 "Nick Sabalausky"<a a.a>  wrote in message
 news:ibev09$1vf5$1 digitalmars.com...
 "Radu"<rr foo.bar>  wrote in message news:ibe95h$gld$1 digitalmars.com...
 On 11/8/2010 11:45 PM, JFD wrote:
 A potential "mod_d" Apache module would go a long way to promote D
 language to
 the web application world.

 But it seems that implementing a "mod_d" Apache module may require that
 C
 instantiates a D language interpreter (similar to Py_NewInterpreter()
 for
 Python), or do the functionality of RDMD with compiled code caching, but
 in C.
    Is that possible?  (Presumably it might be possible to hack up a
 solution,
 but could there be an officially supported way?)

 I know that FastCGI with RDMD can do something similar, but a "mod_d"
 should
 have higher system performance and scalability.

 Thank you.  D is the best!  Keep up the good work.

My experience with Wt ( http://www.webtoolkit.eu/wt ) was quite nice. Mind that its more than a simple template system and brings quite a few advanced idioms to the table like signal/slots, components, adaptive degradation for rendering ( uses Ajax and server push were available ). They also have a nice set of ports for Java and Ruby, maybe D would fit nicely among them.

Very interesting. Reminds me of ASP.NET in that it tries to work at "stateful widget" level, except (from a brief glance at the homepage) it looks like it may actually pull it off and be something I could actually trust. I'm definitely going to dig further into that.

Hmm, I see it's GPL, though. Maybe it's unwarranted, but GPL makes me *really* nervous.

This wasn't a show stopper for me, but I can see your point. There are quite a few of nice things engineered in that framework and usually delivers what it claims. If license is an issue a similar D framework can mimic those nice traits Wt has. /Radu
Nov 10 2010