Home » C++ » Why isn't C++ used in Web-Development? [closed]

Why isn't C++ used in Web-Development? [closed]

Posted by: admin November 29, 2017 Leave a comment

Questions:

A lot of People see similarities between Java and C++ .

But when it comes to web development JavaEE is being used. Whereas C++ has little support on that?
C++ is fast.
So why it isn’t used in web development?

Answers:

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.

Questions:
Answers:

C++ may be fast in execution speed, but Java, C#, PHP, etc are faster in time to market.

Questions:
Answers:

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.

Questions:
Answers:

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.

Questions:
Answers:

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.

Questions:
Answers:

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.

Questions:
Answers:

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.

Questions:
Answers:

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.

Questions:
Answers:

I think the answer has more to do with history than anything else.

C++ was created for tasks like systems programming long before web development existed. Since it has long adhered to ISO standards, the language itself avoids solving specific problem domains.

As far as web development goes, C++ was steamrolled by Java and everything else that came after that had web development tools baked in.

But C++ is a tenacious little beast, due to (IMHO) its powerful combination of efficiency and elegance. You typically have to look beyond C++ into libraries when you are talking about fairly high-level functionality like web development. C++’s first-class library, boost, has low-level well-designed peer-reviewed multithreaded networking tools (boost::asio). Simple http client and server examples are already provided and will grow and stabilize.

I think C++ is on the upswing in this area, given that it started working up from last place.

UPDATE: here is an example of the strict review process before anything will be accepted into boost (in this case, rejection of a process library). And as you can imagine, the review process to actually get into the C++ standard is going to be much much higher. There is a definite intention to keep the scope of C++ (and boost) tight and rock-solid.

Questions:
Answers:

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.

Questions:
Answers:

Some of you need to research the concept: Resource Acquisition Is Initialization. Additionally, I haven’t had a coredump writing modern C++ code in …. years? C++ is probably out of vogue because it’s designed to be a portable machine code language that compiles on many architectures. Thus, no standard networking or threading libraries, and this goes up the chain to web framework.

Questions:
Answers:

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.

Questions:
Answers:

I am a C++ developer who first moved to Java (Scala) and then moved partially back to C++11.
A few reasons why C++ isn’t widely used for web development:

  • Security: Interpreters and “managed” languages (e.g. JVM) provide a kind of protection against bugs that would result in execution of malignant code: buffer overflows, memory corruption, etc. Every large program have bugs, but in Java these bugs would only rarely lead to a cracker taking control of your site. In C++ it is too easy to make a mistake (or use a library which made mistake) that leads to the system been cracked. This “flaw” in “system” programming languages is now mitigated by availability of simple system firewalls, like AppArmor. I set an AppArmor profile for all C/C++ programs of mine and I wouldn’t have returned to C++ if such system firewalls weren’t available.
  • Ease of development: C++ only recently acquired automatic memory management (shared_ptr), anonymous functions, for loops, type inference, etc. The modern C++11 is a decent language but the old C++ was much harder to develop in than the alternatives.
  • Too much diversity: in Java there is a standard way of doing web development (Sevlets), in C++ one has to find one’s way between different libraries and frameworks by trial and error. The path to a good combination of libraries might in C++ take many years.
Questions:
Answers:

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).

Questions:
Answers:

Because the C++ is hard to learn.

Questions:
Answers:

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.

Questions:
Answers:

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.

Questions:
Answers:

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.

Questions:
Answers:

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 xn amount of money and develop within ym amount of time using C++ (FastCGI). Wheres n and m are 3-5+. What would you prefer?

Questions:
Answers:

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.

Questions:
Answers:

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++.