www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - How can I use D to develop web application?

reply zsxxsz <zsxxsz 263.net> writes:
I find D is a excellent program lang. I usualy use C/C++, sometime using
Java/Php. I hate C/C++ for its lowerly effecient development, and I have
Java/Php for it virtual machine. So, I love D very much. But when I want to
write some web program, I can't find any useful resources. Anybody else can
tell me libraries for web applications?
Thanks
zsxxsz
Sep 13 2011
parent reply sclytrack <sclytrack idiot.com> writes:
https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff

cgi

== Quote from zsxxsz (zsxxsz 263.net)'s article
 I find D is a excellent program lang. I usualy use C/C++, sometime using
 Java/Php. I hate C/C++ for its lowerly effecient development, and I have
 Java/Php for it virtual machine. So, I love D very much. But when I want to
 write some web program, I can't find any useful resources. Anybody else can
 tell me libraries for web applications?
 Thanks
 zsxxsz
Sep 13 2011
parent reply zsxxsz <zsxxsz 263.net> writes:
== Quote from sclytrack (sclytrack idiot.com)'s article
 https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff
 cgi
 == Quote from zsxxsz (zsxxsz 263.net)'s article
 I find D is a excellent program lang. I usualy use C/C++, sometime using
 Java/Php. I hate C/C++ for its lowerly effecient development, and I have
 Java/Php for it virtual machine. So, I love D very much. But when I want to
 write some web program, I can't find any useful resources. Anybody else can
 tell me libraries for web applications?
 Thanks
 zsxxsz
Thank you very much. I think the cgi module is lower effecient. I found fcgi(http://www.dsource.org/projects/fastcgi4d) and mango(http://www.dsource.org/projects/mango) which support servlet. But they don't support D2, anyone else can merge them to D2? zsxxsz
Sep 13 2011
next sibling parent reply Adam Ruppe <destructionator gmail.com> writes:
zsxxsz wrote:
 I think the cgi module is lower effecient.
That's not really true. The reason CGI has a perception of being slow is because it's used by slow languages most the time, but with D, it's fast. That said, if you still want to use fast cgi, just use -version=fastcgi when compiling with that same module.
Sep 13 2011
parent reply zsxxsz <zsxxsz 263.net> writes:
== Quote from Adam Ruppe (destructionator gmail.com)'s article
 zsxxsz wrote:
 I think the cgi module is lower effecient.
That's not really true. The reason CGI has a perception of being slow is because it's used by slow languages most the time, but with D, it's fast.
I don't think so. Because I've been using C to write cgi. One http request one fork cgi which is the reason of slowly performance cgi. The fork process is expensive for any OS.
 That said, if you still want to use fast cgi, just use -version=fastcgi
 when compiling with that same module.
I feel the cgi library is too simple, so I doubt wether it supports fcgi for Apache, Nginx or other Webserver.
Sep 13 2011
next sibling parent reply Adam Ruppe <destructionator gmail.com> writes:
zsxxsz wrote:
 The fork process is expensive for any OS.
Have you actually measured this?
 I feel the cgi library is too simple, so I doubt wether it supports
 fcgi for Apache, Nginx or other Webserver.
Have you actually looked at it? I've personally used it on three web servers (IIS, Apache, and an embedded server) across two operating systems (Windows and Linux) and three protocols (CGI, FastCGI, and raw http). It'll probably work on other servers and operating systems too, but I haven't tried yet.
Sep 13 2011
parent reply zsxxsz <zsxxsz 263.net> writes:
== Quote from Adam Ruppe (destructionator gmail.com)'s article
 zsxxsz wrote:
 The fork process is expensive for any OS.
Have you actually measured this?
Yes, I'm sure. Fork on UNIX or CreateProcess on Win32 are expensive.
 I feel the cgi library is too simple, so I doubt wether it supports
 fcgi for Apache, Nginx or other Webserver.
Have you actually looked at it? I've personally used it on three web servers (IIS, Apache, and an embedded server) across two operating systems (Windows and Linux) and three protocols (CGI, FastCGI, and raw http). It'll probably work on other servers and operating systems too, but I haven't tried yet.
Is so, I'll try it, thanks.
Sep 13 2011
next sibling parent Andrew Wiley <wiley.andrew.j gmail.com> writes:
On Tue, Sep 13, 2011 at 8:54 PM, zsxxsz <zsxxsz 263.net> wrote:
 == Quote from Adam Ruppe (destructionator gmail.com)'s article
 zsxxsz wrote:
 The fork process is expensive for any OS.
Have you actually measured this?
Yes, I'm sure. Fork on UNIX or CreateProcess on Win32 are expensive.
Interestingly enough, this benchmark conducted ~10 years ago on a Pentium 3 found that Fork took less than a millisecond on Linux 2.6: http://bulk.fefe.de/scalability/
Sep 13 2011
prev sibling parent Jose Armando Garcia <jsancio gmail.com> writes:
On Tue, Sep 13, 2011 at 7:08 PM, Andrew Wiley <wiley.andrew.j gmail.com> wrote:
 On Tue, Sep 13, 2011 at 8:54 PM, zsxxsz <zsxxsz 263.net> wrote:
 == Quote from Adam Ruppe (destructionator gmail.com)'s article
 zsxxsz wrote:
 The fork process is expensive for any OS.
Have you actually measured this?
Yes, I'm sure. Fork on UNIX or CreateProcess on Win32 are expensive.
Interestingly enough, this benchmark conducted ~10 years ago on a Pentium 3 found that Fork took less than a millisecond on Linux 2.6: http://bulk.fefe.de/scalability/
Fork creates a child process with an copy of the parent process. Yes, this is very fast on any decent operating system. For cgi to work I am pretty sure you have to call execve which transform a process into another process. That link doesn't measure performance for execve...
Sep 24 2011
prev sibling parent reply "Nick Sabalausky" <a a.a> writes:
"zsxxsz" <zsxxsz 263.net> wrote in message 
news:j4o0nn$2igh$1 digitalmars.com...
 == Quote from Adam Ruppe (destructionator gmail.com)'s article
 zsxxsz wrote:
 I think the cgi module is lower effecient.
That's not really true. The reason CGI has a perception of being slow is because it's used by slow languages most the time, but with D, it's fast.
I don't think so. Because I've been using C to write cgi. One http request one fork cgi which is the reason of slowly performance cgi. The fork process is expensive for any OS.
Accessing a DB, using JS, and sending a page across the internet are all far, far slower than forking.
Sep 13 2011
parent reply zsxxsz <zsxxsz 263.net> writes:
== Quote from Nick Sabalausky (a a.a)'s article
 "zsxxsz" <zsxxsz 263.net> wrote in message
 news:j4o0nn$2igh$1 digitalmars.com...
 == Quote from Adam Ruppe (destructionator gmail.com)'s article
 zsxxsz wrote:
 I think the cgi module is lower effecient.
That's not really true. The reason CGI has a perception of being slow is because it's used by slow languages most the time, but with D, it's fast.
I don't think so. Because I've been using C to write cgi. One http request one fork cgi which is the reason of slowly performance cgi. The fork process is expensive for any OS.
Accessing a DB, using JS, and sending a page across the internet are all far, far slower than forking.
I've make a test that forking 1000 processes to execute 1000 tasks on Linux, which cost my all CPU and the load average is high. But when use thread pool to execute these same 1000 tasks, the CPU cost and load average are more slower.
Sep 13 2011
parent Josh Simmons <simmons.44 gmail.com> writes:
On Wed, Sep 14, 2011 at 12:04 PM, zsxxsz <zsxxsz 263.net> wrote:
 == Quote from Nick Sabalausky (a a.a)'s article
 "zsxxsz" <zsxxsz 263.net> wrote in message
 news:j4o0nn$2igh$1 digitalmars.com...
 == Quote from Adam Ruppe (destructionator gmail.com)'s article
 zsxxsz wrote:
 I think the cgi module is lower effecient.
That's not really true. The reason CGI has a perception of being slow is because it's used by slow languages most the time, but with D, it's fast.
I don't think so. Because I've been using C to write cgi. One http request one fork cgi which is the reason of slowly performance cgi. The fork process is expensive for any OS.
Accessing a DB, using JS, and sending a page across the internet are all far, far slower than forking.
I've make a test that forking 1000 processes to execute 1000 tasks on Linux, which cost my all CPU and the load average is high. But when use thread pool to execute these same 1000 tasks, the CPU cost and load average are more slower.
You're better off being event based than either of these options, fork per request is broken but so is thread per request.
Sep 13 2011
prev sibling next sibling parent reply Trass3r <un known.com> writes:
 Thank you very much. I think the cgi module is lower effecient. I found
 fcgi(http://www.dsource.org/projects/fastcgi4d) and
 mango(http://www.dsource.org/projects/mango) which support servlet. But  
 they don't support D2, anyone else can merge them to D2?
Why don't you port them yourself?
Sep 13 2011
parent zsxxsz <zsxxsz 263.net> writes:
== Quote from Trass3r (un known.com)'s article
 Thank you very much. I think the cgi module is lower effecient. I found
 fcgi(http://www.dsource.org/projects/fastcgi4d) and
 mango(http://www.dsource.org/projects/mango) which support servlet. But
 they don't support D2, anyone else can merge them to D2?
Why don't you port them yourself?
Yes, I want to port them from now on, maybe write another one. The projects's owner port them is the best way, because they are more familer with there programs.
Sep 13 2011
prev sibling parent mta`chrono <chrono mta-international.net> writes:
 Thank you very much. I think the cgi module is lower effecient. I found
 fcgi(http://www.dsource.org/projects/fastcgi4d) and
 mango(http://www.dsource.org/projects/mango) which support servlet. But they
don't
 support D2, anyone else can merge them to D2?
 
 zsxxsz
I've some D2 code working with fastcgi. It accepts some web request, makes live a screenshot of my environment, converts it to png, and sends it back. basically it's an own implementation of the fastcgi protocol. but I think I haven't yet covered all of it. But it's sufficant for me.... /* * main */ int main(char[][] args) { // init FcgiApplication fastcgi = new FcgiApplication(); // listen fastcgi.listen(8080); // redirection fastcgi.accept("/redirect.html", (FcgiRequest request) { request.redirect("http://www.google.de"); }); // dir fastcgi.accept("/users.html", (FcgiRequest request) { request.send("<a href=\"/\">back</a>"); request.send("directory!"); string dir = std.process.shell("ls /etc"); request.send("<pre>" ~ dir ~ "</pre>"); }); // counter int counter = 0; fastcgi.accept("/lukas.html", (FcgiRequest request) { counter++; request.send("hello world!" ~ to!string(counter)); }); // show all variables fastcgi.accept((FcgiRequest request) { request.send("<table>"); foreach(key, value; request.params) { string html = std.string.format("<tr><td>%s</td <td>%s</td></tr>", key, value); request.send(html); } request.send("</table>"); }); // wait until forever return fastcgi.exec(); }
Sep 25 2011