Welcome to WebmasterWorld Guest from 126.96.36.199
Forum Moderators: phranque
A compiled .exe file could be downloaded from a server, but that is not the same as using it "in" a website.
A compiled C++ program could be installed on a server to perform tasks related to the website delivered to the broweser, but again that is not the same as using it "in" a website. An entire CMS could be written in C++ and installed on the server, but in the end, the server will deliver the page in good old fashioned HTML, and the browser will parse and render that HTML for the site's visitor(s)
Is there any way I can use C++ in my website?
Quite a number of ways.
In almost all cases, any component that might be written in PHP, Perl, etc. could also be written in C++. Any component that is an executable, a DLL (Windows), or .so (Linux) could be written in C++, and the rest of the system would be none the wiser. Apache modules can certainly be written in C++, and are a great way to extend the functionality of your website which are often ignored, and not at all as scary as they might seem.
Further, almost all scripting languages can call functions written in C++, so you could create a library or libraries of functions to use in your code.
The advantage one might gain is that the code MIGHT be able to run much faster. Though I'd also look at solutions for compiling code written in scripting languages if that is your goal.
Probably the most practical way to use C++ is for selective speed enhancement. Once you know where the bottlenecks are, replace those bottlenecks with carefully-optimized C++ code.
One could of course go one step further and write in assembly code. But programmers who are able to do much better than well-optimized C++ code are probably few and far between nowadays. Still, if you want to squeeze every last bit - this is an option, particular with small, tight functions.
OK, assuming that - if you have to ask this question - then you are likely to get more bang for your buck investigating better algorithms than by switching languages.
That is - an experienced programmer would already know when and where to apply a different language. If you (or your programer(s) don't have the experience to know this - then you (or they) probably also lack the experience to select appropriate algorithms and techniques.
As an extreme over-simplification: if you are sorting something with a bubble-sort, you are going to get way more improvement by using a more advanced sorting technique than by switching from an interpreted language to a compiled one. Way, way, way more.
On the other hand, you might be asking because you want to hire somebody for a project, they know C++, and so of course you are hoping that every nail requires a C++ hammer. While a C++ hammer is useful in web development, it's not often the primary tool of choice.
It's generally a MUCH more expensive way to go than scripting languages, and requires MUCH greater skill on the part of the programmer.
But, I will repeat my own favorite quote (that is, from my own mouth) when asked by project managers "can we do such and such?":
"Sure, we can DOOOOOO anything!"
I don't mention the "but perhaps not at an acceptable cost" part. That's implied in the word emphasis. ;)