Is it possible to develop websites with C / C ++?

16

I know a bit of PHP, but I see that on content sites, sometimes it fires and so on.

Researching, I have seen (very shallow) reports that it is possible to develop web applications with C / C ++, and that these, in turn, would have far more performance than php, which are interpreted language.

I wonder if this is true. If anyone can help, please be grateful.

    
asked by anonymous 15.12.2016 / 10:15

4 answers

26

Yes, it is possible. But almost nobody does. Usually the gain is not worth the effort, which is much greater. Moreover, if one does not master every developmental process, mastering every minute of language can have a much worse result. Languages do not work miracles. They can allow the program to get the desired result if it knows what it is doing.

All mainstream programming languages can be used to develop websites, since what we call sites are text pages. All language can generate texts. These texts must be used by an HTTP server. Every HTTP server can call an executable and get that text somehow. Of course, if the language can communicate more efficiently with this server, the better. There are libraries for C / C ++ that help with this. Note that it is common for these HTTP servers to be written in C or C ++.

The programming language is not the problem.

Locking

It is possible that these crashes are related to your very complex problem. But it is also possible that it is because you are not using PHP properly. Then changing language will not solve anything. PHP is very easy, it's harder to do something wrong with it. But I see a lot of people do. PHP is one of the most used languages to develop websites, do complex things, and does not crash.

I even have criticisms of PHP. But almost everything for web gives to develop with it. It will not always be the most appropriate language, but in simple things it usually is. Even if it is not the most suitable, it will still be reasonably adequate.

What people often do when they need extreme performance is to switch to Java or C # that are almost as easy as PHP and perform better.

I could suggest a number of things I could do in PHP itself to improve performance, but neither should that be the problem. It should be something related to the algorithm adopted. So more specific questions about a timely problem can be helpful in figuring out what is going on.

But reinforcement, if you do not know how to do everything very well, do not understand every aspect of computing, you will not get good results in any language. Maybe the way is to improve at that point.

    
15.12.2016 / 10:51
13

Yes web programming in C / C ++ is possible , this also refers to the start of dynamic web applications. In the '90s CGI with Perl for text manipulation and C / C ++ for "heavy processing" were the norm.

The programming language, on average, is not the first bottleneck of a website. Network latency, IO, etc. are factors that weigh much more than language in the vast majority of cases.

Of course the cost of processing exists, as well as the cost of scaling a website to handle thousands / millions of concurrent requests ... Also, with studies indicating that a one-second delay can impact sales by 7%, there is an economic incentive to optimize performance >.

Let's assume you have a problem where the programming language really has become relevant to the other performance and scalability bottlenecks. Even in this Universe things are not so binary; the decision need not be between purely construed versus purely compiled languages. In fact, the sweetspot for web solutions seems to be in virtual machines with compiling < in> just-in-time . This was Facebook's solution for PHP (see HHVM ) for much of enterprise development > for large web sites (Java, .NET, etc.) and even for JavaScript (see V8 ).

You do not need to expose developers to the C / C ++ idiosyncrasies to get a significant performance gain. In fact, even assuming that a properly optimized C / C ++ solution will always be faster (which is not true), the law of diminishing returns makes extracting these last drops of language performance in a world with so many other factors unlikely to be worthwhile.

In the great majority of cases, it is not feasible to give up years and years of evolution of the languages, tools, techniques and knowledge accumulated by the various communities specialized in web development to write a solution in C / C ++. Frameworks for web development in C ++ such as CppCMS and Wt , regardless of technical merits, simply do not have the same traction of technologies in more recent ecosystems.

In this way, I would say web development in C / C ++ is possible and there are applications in certain niches. That being said, I see little chance of such development becoming mainstream . The argument of performance gain with C / C ++ to avoid crashes does not hold up, and it's hard to think of a good reason to write web applications in C / C ++ in 2016.

    
15.12.2016 / 13:36
4

As @bigown commented, it is possible, but almost nobody does.

This is simple to understand: C / C ++ does not have this focus of being a Web language.

It would be like trying to develop a site with Pascal , COBOL or other language with different purpose.

OC / C ++ is a language that allows you to develop anything, but there are more suitable languages for certain purposes, such as SQL for database interaction, and R for calculations that help Big Data , there are languages supported for Web development, such as PHP , Java and ASP / ASP.Net using C# for example.

In general, you can, but would have to program or find libraries for basic things that these other languages above already have.

Now, about your performance problem, blaming language is premature. There are sites in ASP / VB that work very well even today. Your problem may be network, file access, traffic, database, etc., a lot of things that, regardless of language, will slow your site down.

I suggest you dig deeper and identify where the problem is. Most likely you'll be able to resolve using PHP and your site will perform well.

    
15.12.2016 / 11:31
0

I recommend using C #. I have now started interning in a web programming company and am using ASP.NET and C #. In college I learned C / C ++, and C # is very similar and easy to learn and the best thing is that it saves a lot work, as there are bookstores for everything, including for web applications, and the best thing is that you can use the same code to develop for various platforms (eg Android or iOS) using Visual Studio, which is free in the community version.

    
15.12.2016 / 11:02