C application server vs ruby on rails or turbogears

G

gavino

Is there something one can use when leanring c to do the web or are
scripting languages going to dominate the web?
along w java perl ruby ptython tcl etcetc?

I have net seen an open source c application server.....

i saw cserverpages but its $$ for commercial use.....
 
M

martdi

Since web developpment uses a lot of string manipulation, scripting
langage are more appropriate than c for that task.

It is also easier to debug scripting languages, since you can modify
the code and run the page without needs to recompile after modifying
it.

Unless your web site has *really* *really* *really* *really* specific
needs, i would advise not to use C for web development.
 
P

Paul Connolly

martdi said:
It is also easier to debug scripting languages, since you can modify
the code and run the page without needs to recompile after modifying
it.
It is harder to debug scripting languages - type-safe compiled languages
provide you with automatic checking, showing errors and warnings, before
you even run the program.

C programs with CGI (Common Gateway Interface) can serve web pages, but for
three (AFAIK) reasons C programs are not commonly used to serve pages:

1. Scripting languages running under the supervision of a web-server and
"virtual machine" make it easier for the server to recover from errors - the
site stays up

2. scalability - with CGI a new C process is created for every request - a
web server can put less strain on the OS (theoretically I don't see any
problem with C and scalability)

3. web programmers aren't real programmers :)

I'd be very interested in knowing about ways of serving web pages with C -
anyone?
 
W

websnarf

martdi said:
Since web developpment uses a lot of string manipulation, scripting
langage are more appropriate than c for that task.

I dispute this. Please take a look at: http://bstring.sf.net/ and
http://pcre.sf.net/ . With the combination of those two libraries, you
can make C comparable in functionality on strings to any scripting
language in existence.
It is also easier to debug scripting languages, since you can modify
the code and run the page without needs to recompile after modifying
it.

But the C language typically offers better debugging tools. Scripting
language may offer a safer environment that insulates you from the
worst kinds of errors, but on the other hand they often drop things
like "type checking".

An example of this happened to me recently when I was programming some
python and had accidentally used "len" as a variable -- when later on
in the same routine I tried to use it as the default function that it
is, the program just threw an error at run time. This was complicated
by the fact that I was wrapping the whole thing in a try: except: block
to capture other kinds of errors. It was by back peddalling and
literally comparing my code to earlier versions that I was able to
determine what the problem was. The point is that the error was me
redefining the function "len" as a variable, but the interpretor didn't
even offer a warning about this.

So I don't buy the idea that scripting languages are necessarily easier
to debug.
Unless your web site has *really* *really* *really* *really* specific
needs, i would advise not to use C for web development.

Like, performance and/or surviving a slashdot/digg effect?
 
I

Ian Collins

Paul said:
It is harder to debug scripting languages - type-safe compiled languages
provide you with automatic checking, showing errors and warnings, before
you even run the program.

C programs with CGI (Common Gateway Interface) can serve web pages, but for
three (AFAIK) reasons C programs are not commonly used to serve pages:

1. Scripting languages running under the supervision of a web-server and
"virtual machine" make it easier for the server to recover from errors - the
site stays up
CGI completely decouples the CGI process.
2. scalability - with CGI a new C process is created for every request - a
web server can put less strain on the OS (theoretically I don't see any
problem with C and scalability)
Probably no worse than loading/interpreting a script.
3. web programmers aren't real programmers :)
That's changing!
I'd be very interested in knowing about ways of serving web pages with C -
anyone?
The most common use would be as extensions for the likes of PHP.
 
I

Ian Collins

martdi wrote:
Please don't top post.
Since web developpment uses a lot of string manipulation, scripting
langage are more appropriate than c for that task.
Does it? Looking though my last couple of web projects, I see very
little string processing and plenty of data manipulation. I only used
PHP at my client's request.
It is also easier to debug scripting languages, since you can modify
the code and run the page without needs to recompile after modifying
it.
That's just plain wrong.
Unless your web site has *really* *really* *really* *really* specific
needs, i would advise not to use C for web development.
This is probably true, but not for the reasons listed above. The main
reason is library support.
 
I

Ian Collins

gavino said:
Is there something one can use when leanring c to do the web or are
scripting languages going to dominate the web?

The (very brief) CGI specification.
along w java perl ruby ptython tcl etcetc?

I have net seen an open source c application server.....
Apache?
 
P

Paul Connolly

Ian Collins said:
CGI completely decouples the CGI process.
excellent point. Thank you for correcting me.
Probably no worse than loading/interpreting a script.
not sure that is true in practice - or am I just a fool for the IIS
"marketecture"?
That's changing!
yes it is!
The most common use would be as extensions for the likes of PHP.
I haven't done PHP (my employers uses ASP - but I might be able to influence
them otherwise - if I'm convinced myself) - can you recommend a good book to
read? or good URL? (ideally an example of read from db - put it on the
page - retrieve edited data - write to db).
 
G

Gordon Burditt

C programs with CGI (Common Gateway Interface) can serve web pages, but for
three (AFAIK) reasons C programs are not commonly used to serve pages:

1. Scripting languages running under the supervision of a web-server and
"virtual machine" make it easier for the server to recover from errors - the
site stays up

It's hard to imagine a non-malicious CGI program, written in any
language, that will take down the web server for reasons other than
taking too many resources. (I consider kill(getppid(), 9) malicious).
And C programs tend to take fewer resources than scripting languages
for a given task. CGI runs in a separate process.

Something like PHP run as an Apache module CAN take down the web server,
since it's capable of scribbling on memory where it shouldn't. I've
had this happen (I think it was incompatible module versions). It's
very rare, though.
2. scalability - with CGI a new C process is created for every request - a
web server can put less strain on the OS (theoretically I don't see any
problem with C and scalability)

C processes, although separate, tend to take up a lot less memory than
a scripting language PLUS a webserver in the same process.

3. web programmers aren't real programmers :)

I'd be very interested in knowing about ways of serving web pages with C -
anyone?

Sometimes it's as simple as taking an existing C program that outputs
something useful on stdout and having it add a Content-type: text/plain
header at the beginning of its output. I've even done that with a
shell-script wrapper.

The advantage of web-based scripting language is that they've already
got the infrastructure for things like accepting input variables and
cookies done for you, and throwing something together quickly is much
easier to do.
 
P

Paul Connolly

Gordon Burditt said:
The advantage of web-based scripting language is that they've already
got the infrastructure for things like accepting input variables and
cookies done for you, and throwing something together quickly is much
easier to do.
a web page written by a C program could preserve a (suitably encripted and
verifiable) identification of session state, input is easily parsable from
the environment or stdin - this infrastructure could be written easily in
C - there are already libraries in C for doing it
http://cgi.resourceindex.com/Programs_and_Scripts/C_and_C++/Libraries_and_Classes/
It looks to me that there is little extra work to get started with C, but
not much.
(I know this sounds mad but I was wondering about developing a web-site in
assemler).
 
G

Gordon Burditt

The advantage of web-based scripting language is that they've already
a web page written by a C program could preserve a (suitably encripted and

There's a lot of things a C program *COULD* do, but that doesn't
come with C. Not even the basics like separating out the values of
GET or POST variables, to say nothing of handling sessions. And
chances are you won't find the third-party libraries for this already
installed on the servers you want to use them on.
verifiable) identification of session state, input is easily parsable from
the environment or stdin - this infrastructure could be written easily in
C - there are already libraries in C for doing it
http://cgi.resourceindex.com/Programs_and_Scripts/C_and_C++/Libraries_and_Classes/
It looks to me that there is little extra work to get started with C, but
not much.
(I know this sounds mad but I was wondering about developing a web-site in
assemler).

After all, you *CAN* write something like PHP or Perl in C and/or C++.
 
S

sjdevnull

I dispute this. Please take a look at: http://bstring.sf.net/ and
http://pcre.sf.net/ . With the combination of those two libraries, you
can make C comparable in functionality on strings to any scripting
language in existence.

bstring is awesome but it's still behind the functionality of most
modern scripting languages. e.g. there's no support for character
encodings, many of the lib functions are very specialized (there's
btrimws but no generalized strip/lstrip/rstrip that lets the user
select what characters to strip), and it lacks things like tab
expansion, console text justification, etc. I didn't even see a simple
reverse function but I might've missed it.

That's not necessarily a knock; if you're going with C, you probably
want a leaner API. But scripting languages tend to have tons of little
helper functions that can make life easier on the programmer.
But the C language typically offers better debugging tools. Scripting
language may offer a safer environment that insulates you from the
worst kinds of errors, but on the other hand they often drop things
like "type checking".

Python and Ruby are both much more strongly typechecked than C.
Whether static or dynamic typing is better is an argument that's been
had out a million times and is off-topic anyway (certainly if you're
used to one it takes a while to adjust to the other).
Like, performance and/or surviving a slashdot/digg effect?

We had no problems serving 300 pages/second from a python-based
solution when I was working at a large web company, and the servers
weren't breathing hard (We were, in fact, slashdotted but the traffic
spike just isn't very noticeable to a larger site). CPU usage was only
in the 10% range, we had 4 servers (moderately sized intel or amd
boxes) for redundancy but 1 was an offline backup. That was peak
traffic in special events; average peak daily was significantly lower.

CPUs are fast and putting together web pages isn't very
compute-intensive; the problem tends to be (1) the network being
saturated; (2) running out of file descriptors or other resources if
your server architecture is poor or (3) the database falling over,
again normally an architecture/design problem.

That said, the dynamic content server which had to serve several
requests for each page view was a custom C solution. It handled
probably 1500-2000 requests/second during peak special traffic with
next to no CPU usage, but it also had the luxury of having persistant
connections to the web farm (they obviously had to set up and tear down
TCP connections for most incoming web requests).

FWIW, it was entirely written in ANSI C except for network socket calls
and file descriptor passing so that it could be upgraded seamlessly
without losing connections to the web servers--all the logic for
parsing and processing a request and determining a response was
bog-standard. It was taken out of production some time this year but
by then had served several billion requests with no unscheduled
downtime.

So for certain types of web solutions, C can work very well indeed.
 
C

Charlton Wilbur

Paul Connolly said:
C programs with CGI (Common Gateway Interface) can serve web pages, but for
three (AFAIK) reasons C programs are not commonly used to serve pages:

1. Scripting languages running under the supervision of a web-server and
"virtual machine" make it easier for the server to recover from errors - the
site stays up

CGI decouples the CGI-spawned process from the web server process.
This is not a problem.
2. scalability - with CGI a new C process is created for every request - a
web server can put less strain on the OS (theoretically I don't see any
problem with C and scalability)

With any programming language used through the CGI a new process is
created for each request. There are ways of getting around this
(FastCGI, Apache modules), but they're either "as-if" extensions to
the CGI spec or they don't use the CGI at all.
3. web programmers aren't real programmers :)

This is a major reason -- most of the HTML or Dreamweaver monkeys
calling themselves web programmers couldn't handle C.

You also missed out

4. effort/reward ratio

The principal advantage of using C is its tight coupling with the
machine and its close mapping to actual machine language. In the web
environment, this isn't nearly as useful, because network bandwidth
and latency are more of a constraint. And so it's acceptable to trade
away performance for ease of development, and a language that has
strings as a first-class data type has big wins here.
I'd be very interested in knowing about ways of serving web pages
with C - anyone?

Read the CGI spec. If you can parse the contents of environment
variables and spit out plain text, you can write CGI code in C. It's
not done much because it's a poor tool for the job.

Alternately, take a look at the Apache source, and learn how to write
Apache modules to handle different phases of the request.

Charlton
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top