C ++ server scripts

This time I came across a lot of questions that using C ++ is not recommended for SSS and recommends using so-called interpreted languages ​​such as PERL and PHP for them. But I need advanced OO features and C ++ flexibility to provide scalable and manageable code.

I tried a lot of online articles and searches, and it wasn’t useful anywhere since I still don’t know if it is possible to write SS scripts in C ++, and if so, how.

I thought of a couple of ideas, including writing a web server in C ++ and responding accordingly after parsing the HTTP request. But it would be to reinvent the wheel, and I eventually deviated from my main project and devoted a lot of work to provide a functional, secure HTTP server.

I also looked at PHP extensions, but again this approach also has its own baggage and overhead.

My questions:

  • Is it possible to program SSS in C ++?
  • If so, what are the approaches at my disposal.

Thanks!

+7
source share
6 answers

Ignoring at the moment the usefulness of using C ++ for SSS, your first choice is likely to be Wt . Contrary to the consequences in some other answers, development time is unlikely to increase by 10x (or anywhere near it). No, you will not miss all the nice infrastructure features that you expect from things like PHP, Perl, or Python.

In fact, my own experience is rather the opposite: while PHP (for example) makes it quick and easy to start a website, creating a website that is truly stable, secure and responsive is a whole different story. With Wt, it’s rather the other way around (at least in my admittedly limited experience). Obtaining an initial site and launching it will probably take a little longer - but as soon as it looks, acts and feels the way you want it, most likely, only minor changes will be required to be ready for public use.

Returning to the question of appropriateness: development in C ++ may be a little more complicated than in some languages ​​that are more common in the SSS market, but this is still a piece of cake compared to security. If someone even writes C ++ with difficulty (for example, monitors and frees up memory when it is no longer needed), I definitely do not want them to come close to the code for my website.

+6
source

I would not recommend it, but you can write CGI scripts in C ++ (either in C, or in FORTRAN). But why bother? Languages ​​like PHP work a lot easier, and they seem to scale well for some fairly large sites.

+3
source

CGI is the "standard" way of handling web requests in C or C ++, but you can also explore the possibility of creating a module that gets connected to the web server at runtime. Google for "apache module API" (if using Apache) or "IIS module" (when using IIS).

+2
source

Can you afford 10x development time? All bits of the ish infrastructure that you take for granted in php, perl, python do not exist or it is much more difficult to use in C ++. I see only two reasons: 1. You only have C ++ on your platform. 2. The server really has very high performance requirements that could benefit from specific optimization tasks.

0
source

You can write a CGI application in C ++ using the appropriate framework (like this one ). But I would recommend just switching from perl or php. This will save you a lot of time. These tools are better suited for this type of work.

EDIT : fixed link

0
source

I could not understand your exact requirements (license, etc.), but it may be what you are looking for http://cppcms.sourceforge.net .

0
source

All Articles