LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Programing Web with C++ (https://www.linuxquestions.org/questions/programming-9/programing-web-with-c-900563/)

jeanCarloMachado 09-01-2011 09:06 AM

Programing Web with C++
 
Hello

Sorry by the, but it is possible to program C++ for Web?
like Php I did not find anything, if it is, it is viable?
Can you point me a literature about this?

Tanks.

Proud 09-01-2011 09:27 AM

You just need to google C++ CGI.
http://en.wikipedia.org/wiki/Common_Gateway_Interface

Unless you're talking about making a HTTP/XML client, rather than server-side page generation as PHP is traditionally used.

Skyer 09-01-2011 09:36 AM

Yes it is,
and Proud is absolutely right.
I just wanted to add that you can use any language (programming or scripting), which supports I/O operations in general. (AFAIK).


Skyer

jeanCarloMachado 09-01-2011 09:50 AM

Tanks by the answers
But it's useful to make a iterative web page just with C++ excluding PHP?
In the market it is done?

Att

Proud 09-01-2011 09:58 AM

Can you clarify what you mean by "an iterative web page"?
Adding output line by line? With no use of external resources such as databases or incorporating other HTML-producing server-side code?
For an example output of
Code:

<html>
  <body>
    <h1>Hello there!</h1>
  </body>
</html>

Something similar to the below C example?
Code:

#include <stdio.h>

int main()
{
  printf("Content-type: text/html\n\n");
  printf("<html>\n");
  printf("<body>\n");
  printf("<h1>Hello there!</h1>\n");
  printf("</body>\n");
  printf("</html>\n");
  return 0;
}

Taken from http://computer.howstuffworks.com/cgi3.htm

Whether it's done (that is to say, whether C++ is used) is down to what problem people are trying to solve and what options they have available. For simple dynamic pages using common web servers, things like Perl and PHP are used as they're well suited to the task and often ready to use/easy to set up. People might use C++ due to webserver limitations or performance, or interacting with unusual resources. Or for the sake of it.

theNbomr 09-01-2011 10:13 AM

It isn't completely clear whether you want to use C++ to generate HTML, or whether you want to implement an HTTP server. In either case, the answer is yes. Since C++ can read commandline arguments, environment variables, and stdin, and can write to stdout, it can be used to write CGI applications. As far as I know, it is not the usual way to implement CGI, but there is nothing to stop you from doing so. A primitive HTTP server can be written in about a hundred lines of C. There are numerous open source examples of this, covering a fairly broad spectrum of capabilities.
--- rod.

lyle_s 09-01-2011 10:24 AM

Quote:

Originally Posted by jeanCarloMachado (Post 4458816)
Hello

Sorry by the, but it is possible to program C++ for Web?
like Php I did not find anything, if it is, it is viable?
Can you point me a literature about this?

Tanks.

Here are few things you could look at:
Lyle.

Proud 09-01-2011 10:26 AM

The only other interpretation I can think of is you want a webserver that's written in C++ and doesn't have support for any server-side languages. (Or none other than C++). You wouldn't be wanting to write it from scratch, but could understand and compile the code if your only available programmer/compiler handles C++ (perhaps for purposes of security & future fixes). But this seems an unlikely scenario.

jeanCarloMachado 09-01-2011 10:34 AM

Tanks by the answers
But it's useful to make a iterative web page just with C++ excluding PHP?
In the market it is done?

Att

jeanCarloMachado 09-01-2011 12:02 PM

Ok you answered my questions!!
I wanna know if it is possible to use C++ instead of PHP, to make normal WEB sites, but not like a HTTP server.
Tha is it!
Tanks all of you by the quick answers.
This forum is the BEST!!

dugan 09-01-2011 12:13 PM

Facebook is doing it...

http://en.wikipedia.org/wiki/HipHop_(software)

Skyer 09-01-2011 03:33 PM

Well,
the usefulness of using C++ instead of PHP depends on the purpose of web page you want to make.

PHP has grown very close to the web platform over the years, so if you don't have to use low profile language (or are not very concerned about the performance), like C++, I don't think it's a useful idea.

Good luck with it.


Skyer


All times are GMT -5. The time now is 10:14 PM.