开发者

C++ Server-Side-Scripting

开发者 https://www.devze.com 2023-02-26 06:02 出处:网络
For once, I have come across a lot of stuff about the use of C++ being not advisable for SSS and rec开发者_C百科ommending the use of so called interpreted languages like PERL and PHP for the same. But

For once, I have come across a lot of stuff about the use of C++ being not advisable for SSS and rec开发者_C百科ommending the use of so called interpreted languages like PERL and PHP for the same. But I need the advanced OO features and flexibility of C++ to ensure a scalable and more manageable code.

I have tried many internet articles and searches and none where helpful to the point that I still have no idea if it is possible to write SS-Scripts in C++ and if yes, then how.

I have thought of couple ideas, including writing a web-server in C++ and responding accordingly after parsing the HTTP request. But it would be re-inventing the wheel and I'll end up deviating from my main project and dedicating a lot of work to ensure a functional-cum-secure HTTP server.

I have also considered PHP extensions but again the approach also comes with its own baggage and overhead.

My questions are:

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

Thanks!


Ignoring, for the moment, the advisability of using C++ for SSS, your first choice would probably be Wt. Contrary to the implications in some of the other answers, no development time is not likely to increase by 10x (or anywhere close to it). No, you're not missing all the nice infrastructure features you'd expect in things like PHP, Perl or Python either.

In fact, my own experience is rather the opposite: while PHP (for example) makes it pretty easy to get a web site up and running fairly quickly, producing a web site that's really stable, secure, and responsive is a whole different story. With Wt, rather the opposite seems to be the case (at least in my, admittedly limited, experience). Getting the initial site up and running will probably take a little longer -- but about as soon as it looks, acts, and feels the way you want, it's likely to need only rather minor tweaks to be ready for public use.

Getting back to the advisability question: developing in C++ may be a bit more complex than in some languages that are more common in the SSS market -- but it's still a piece of cake compared to doing security well. If somebody has even the slightest difficulty writing C++ (e.g., tracking and freeing memory when it's no longer needed), I definitely don't want them getting close to the code for my web site.


I wouldn't recommend it, but you can certainly write CGI scripts in C++ (or in C, or in FORTRAN). But why bother? Languages like PHP do a much better job more easily, and they seem to scale well for some pretty major sites.


CGI is the "standard" way to have C or C++ code handling web requests, but you might also look into writing a module that gets linked into the web server at runtime. Google for "apache module API" (if using Apache) or "IIS module" (if using IIS).


Can you afford 10x as much development time? All the infrastructure-ish bits that you take for granted in php, perl, python are non existent or much harder to use in C++. I see only two valid reasons to do this: 1. You only have C++ on your platform. 2. The server really has very high performance needs that would benefit from problem specific optimizations.


You can write a CGI application in C++ using an appropriate framework (like this one). But I'd recommend just going with perl or php. It will save you much time. Those tools are just better suited for this kind of job.

EDIT: corrected the link


I couldn't understand your exact requirements (license, etc) but this might be what you are looking for http://cppcms.sourceforge.net.

0

精彩评论

暂无评论...
验证码 换一张
取 消