A lot of People see similarities between Java and C++ .
But when it comes to web development JavaEE is beeing used. Whereas C++ has little support on that? C++ is fast. So why it isn't used in web developement?
A lot of People see similarities between Java and C++ .
But when it comes to web development JavaEE is beeing used. Whereas C++ has little support on that? C++ is fast. So why it isn't used in web developement?
C++ may be fast in execution speed, but Java, C#, PHP, etc are faster in time to market.
C++ used to be a common language for web development. At the time, however, there were few viable alternatives. Languages such as C# and Java are designed for application development instead of being general purpose, so they're a better choice for web apps.
IMHO, it's all about the tool chain. Java, Ruby, etc. have mature tool chains for web development. The tools make development faster in most cases. There are some environments for C++ but none have widespread usage. The other major reason for this is that most of the newer languages are developed for application development first and general purpose computing second.
Imagine you need a site. There is two options available to you: 1. Pay x amount of money and develop a site within y amount of time using .net/java/python/ruby/ect. 2. Pay x*n amount of money and develop within y*m amount of time using C++ (FastCGI). Wheres n and m are 3-5+. What would you prefer?
For one thing, the java and C# libraries/frameworks are much, much bigger than C++. "Standard" C++ has almost nothing interesting for web development. THe standard C++ library does not even have the slightest thing related to network, threading or portable file system access. I doubt C++ speed is much of a factor: java and C# are generally as fast as C++ in server settings (where you can use the full JIT capabilities of the runtimes, because starting times and co are of no concern).
Oftentimes the possibly faster execution speed of C++ doesn't matter since the bottleneck is the database and network I/O.
So the benefits from ease / speed of development, safety (really sucks when your web app core dumps), and availability of frameworks will outweigh execution speed gains for many applications.
I once worked on a extremely high-performance web site done in C++ with a custom framework. We weren't using Apache--we had a domain-specific web server that could serve our special content fast and efficiently that was hand-coded in C++.
This server processed requests that came in from what was, at the time, the highest rated prime-time television show. (The host would say "log in to ......com to play along). Instantly, 100,000 or more people would be pounding the server. One ordinary PC was able to handle the load, but we had 3 running, just in case one went down, etc.
Fact is, the systems we use for Web development now are extremely wasteful. We're trading CPU cycles for ease of maintainability.
Take a look at architectures like http://acme.com/software/thttpd/ which are extremely fast web servers.
If you'd ever had to develop a web application in C++ you'd know why. Basically, there is nothing approaching the frameworks that .NET, Java or PHP have nor is there anything web-specific like ROR or Django.
Web development is full of people who got where they are from editing HTML, and has far fewer people who got there from C++, or C. The tendency then for most of these web developers, is to select simpler languages with garbage collection, that prioritise quick results over performance. C++ is really really not a langauge like that.
But that's only a superficial reading. Mostly it's about fashion.
C++ is not very handy for web development, because the programmer has to take into account that objects are destructed properly. In languages like C# and JAVA there is no need to create destructors, because instantiated objects only live in a certain scope. So in a pratical way you could say languages like C# and JAVA are more useful for web applications than C++.
I'd go with Karl Voigtland's answer (though I like Dan Diplo's too) but I wanted to add that I personally work for a company where speed is everything (in a comparable to google kind of way) and I still wouldn't use C++ for the web-app because the performance difference would be absolutely negligible, especially compared to the I/O bottleneck and network latency which is the real problem anyway.
C++ costs you a standard, well-documented, widely used framework (whichever one that happens to be) which makes up an enormous chunk of the work you'd have to replicate, and puts you firmly into the territory of crashing your server if something goes wrong.
So much effort and so much risk for no gain whatsoever. C++ is a weapon for an older more civilised age, it's not for the web.
For every type of job you need an appropriate tool. It is possible to drive a nail into a board by hitting it with a pair of pliers, but a hammer is much better suited for it.
because I would want to jump out the window every morning I would come to work.
Agreed that frameworks are important and solve a LOT of typical problems for you. c++ won't have those frameworks for you. Also, you may be optimizing performance at one level but this may not lead to the most optimal solution. DB access time is, with a larger site, likely a much larger concern and one that's most likely worth worrying more about than your application execution time.
Also, you're talking about web development where things change quickly. c++ is not the language of choice in this field and you'd be left standing still trying to catch up with the rest of the crowd that plays well together.
Stick with the crowd, use what's out there. Don't optimize locally. You're better off.
.... maybe another question could be asked. Do C/C++ developers write web apps, and if and when they do, do they use C++ or something else?
I'm building a browser game in C++, and yes, some parts definitively suck (such as using FastCGI, which does not support multiple connections at once, unless you're implementing your own FastCGI-Handler, CGI even worse, SCGI doesn't support multiplexing either (but is a charm to implement) and using a custom server API isn't portable), however, once you have the environment set up, developing isn't that difficult.
For example, the following code prints out all cookies:
for( map<string,string>::const_iterator it=data[cookie].begin(); it!=data[cookie].end(); ++it)
{
cout << "<b>" << it->first << "</b>: " << it->second << "<br>\n";
}
Or, if you want to design web applications as you would with Qt, take a look at Wt, which reduces the pain of developing C++-Webapplications to the manual memory management.
Because Web development involves a lot of HTML. In the old days of Java, there was only Servlet and this was counterproductive. So they invented JSP.
C++ is even worse than Servlet from that viewpoint.
And in the very old days Assembly Guys did pretend C++ was lame and that using Assembly Languages was much better so your question pertains to the same kind of perspective.
When the web first came out speed wasn't a big deal. We ran the servers on Unix machines that had more than enough power to fill a 10Mb ethernet. The handfull of users were on dialup and the sites were mostly text. So we used Perl, just because it was easy to do string manipulation, some of us even used TCL (shudder).
By the time the web took off enough to need bigger more complex systems the dynamic languages had got better and came with lots of helpful libs (especially Perl). Then business bought into Java in a big way - Sun actually managed to market something!.
There's no reason we couldn't have all the web features of Java / C# in C++ but the libs weren't developed or never gained wide traction.
There was a lot of web development in C++ but it was generally in custom web servers for very high performance tasks.
Another reason is that is a lot easier to write subtly insecure code (buffer overruns etc) in C++ than in languages with proper bounds checking that abstract raw memory away from the developer. C++ requires a great deal more skill to use safely than the alternatives.