Re: How can I use D to develop web application?

2011-09-25 Thread Jose Armando Garcia
On Tue, Sep 13, 2011 at 7:08 PM, Andrew Wiley wiley.andre...@gmail.com wrote:
 On Tue, Sep 13, 2011 at 8:54 PM, zsxxsz zsx...@263.net wrote:
 == Quote from Adam Ruppe (destructiona...@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...


Re: How can I use D to develop web application?

2011-09-25 Thread mta`chrono
 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(trtd%s/td 
td%s/td/tr,
key, value);
request.send(html);
}
request.send(/table);
});


// wait until forever
return fastcgi.exec();
}




How can I use D to develop web application?

2011-09-13 Thread zsxxsz
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


Re: How can I use D to develop web application?

2011-09-13 Thread sclytrack

https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff

cgi

== Quote from zsxxsz (zsx...@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



Re: How can I use D to develop web application?

2011-09-13 Thread zsxxsz
== Quote from sclytrack (sclytr...@idiot.com)'s article
 https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff
 cgi
 == Quote from zsxxsz (zsx...@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


Re: How can I use D to develop web application?

2011-09-13 Thread Adam Ruppe
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.


Re: How can I use D to develop web application?

2011-09-13 Thread zsxxsz
== Quote from Adam Ruppe (destructiona...@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.


Re: How can I use D to develop web application?

2011-09-13 Thread Adam Ruppe
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.


Re: How can I use D to develop web application?

2011-09-13 Thread Trass3r

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?


Re: How can I use D to develop web application?

2011-09-13 Thread Nick Sabalausky
zsxxsz zsx...@263.net wrote in message 
news:j4o0nn$2igh$1...@digitalmars.com...
 == Quote from Adam Ruppe (destructiona...@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.




Re: How can I use D to develop web application?

2011-09-13 Thread zsxxsz
== Quote from Adam Ruppe (destructiona...@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.


Re: How can I use D to develop web application?

2011-09-13 Thread zsxxsz
== Quote from Trass3r (u...@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.


Re: How can I use D to develop web application?

2011-09-13 Thread zsxxsz
== Quote from Nick Sabalausky (a@a.a)'s article
 zsxxsz zsx...@263.net wrote in message
 news:j4o0nn$2igh$1...@digitalmars.com...
  == Quote from Adam Ruppe (destructiona...@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.


Re: How can I use D to develop web application?

2011-09-13 Thread Andrew Wiley
On Tue, Sep 13, 2011 at 8:54 PM, zsxxsz zsx...@263.net wrote:
 == Quote from Adam Ruppe (destructiona...@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/


Re: How can I use D to develop web application?

2011-09-13 Thread Josh Simmons
On Wed, Sep 14, 2011 at 12:04 PM, zsxxsz zsx...@263.net wrote:
 == Quote from Nick Sabalausky (a@a.a)'s article
 zsxxsz zsx...@263.net wrote in message
 news:j4o0nn$2igh$1...@digitalmars.com...
  == Quote from Adam Ruppe (destructiona...@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.