Should PHP / Rails / Django / ASP websites be written in C ++?

I was looking at an open source SO project. This is a web framework written in C ++.

Now you are probably ready to answer how C ++ is a terrible language for websites, and on websites the bottleneck is in the database.

But ... I read this post:

http://art-blog.no-ip.info/cppcms/blog/post/42

and there he concludes that on a large site such as Wikipedia, database servers make up only 10% of all servers. So C ++ would be better than languages ​​like PHP Python Ruby C #.

Are his scores valid?

+4
source share
8 answers

The problem with the article you are referring to is that the author clearly does not know what he is talking about when he asks where the bottleneck is; the fact that someone has more web servers than database servers does not mean that "the database cannot be where the problem is." What is commonly referred to as a “database is a bottleneck” is the same thing that has been learned by everyone who has ever profiled web applications at runtime.

Consider an application that takes half a second to return a complete answer. Suppose you sit down and look at it, and find that this half second of processing time breaks as follows:

  • Incoming request analysis: 50 ms
  • Query Database: 350 ms
  • Sending HTML for response: 50 ms
  • Sending reply: 50 ms

If you saw such a breakdown, where database queries account for 70% of the actual application run time, you should rightly conclude that the database is a bottleneck. And it is exactly what most people find when they browse their applications (and, as a rule, the database so completely dominates the processing time that the choice of language for the rest of the processing does not matter, anyone will notice).

The number of database servers involved is not too important; the famous quote here is that people like the author of the message you contacted are types who hear that it takes one woman nine months to have a baby, and suppose that nine women working together can do this through month. In terms of a database: if a given query takes 100 ms to execute in a given database, then adding more database servers will not make any of them execute this query faster. The reason for adding more database servers is the ability to process more concurrent queries and block database loading, rather than making isolated queries faster.

And from there, you enter the usual dance of scaling an application: caching to reduce the total time it takes to get data or draw answers, load balancing to increase the number of simultaneous queries that you can serve, shards and more complex database design schemes so as not to get bogged down under load, etc. etc.

But, you will notice, none of this has anything to do with the programming language used, because once again the amount of time spent or saved by other factors greatly outweighs the amount of time gained or lost by the “fast” or “slow” language (and, of course however, this does not exist, so much depends on the problem area and the skill of the programmer that you simply cannot have a meaningful general comparison).

In any case, it becomes long and incoherent, so I just conclude it with a general guide: if you see that someone claims that “you have to build the X language because it works faster”, this is a dead giveaway that they really are nothing Unaware of real performance or scaling. Because, in the end, if it just went down to "write in the fastest language", they would recommend that we all use the assembly :)

+17
source

Servers are a one-time fixed cost several times. Programmer time costs a lot more. Of course, writing sites in C ++ would reduce the cost of equipment, but significantly slow down the development. Therefore, if you can shave one person-month of time from your development, using Ruby instead of C ++, which pays for an additional server.

Better means a lot more than "faster."

+11
source

There are so many problems that you encounter when writing in compiled, statically typed languages ​​such as C ++, and all this can affect development. Some of the main reasons scripting languages ​​were written, such as Ruby or PHP, are because we programmers can get more efficiency from the language and tools we work in.

Yes, websites will be faster if they are written in C ++. Yes, they can serve more people, be more scalable, and be more efficient. But is this a good enough reason to lose all the benefits that interpreted languages ​​give us? The happiness of the programmer, development time, ease of use, portability and much more I can not say.

The right tool for the right work, and for C ++ - website development is not one of them.

+3
source

I would not want to say that servers are a one-time cost of a few great ones, since some of them cost hundreds of thousands, and I would venture to say millions. A number of sources will suggest that the highest value for the IT industry is hardware, not labor. But to compare languages, we need to compare them, not hardware.

The idea behind languages ​​like Ruby, Python, PHP, and Groovy is essentially Rapid Application Development (RAD). Frames, Ruby on Rails, Django, CakePHP and Grails are designed to improve RAD. The languages ​​are easy to use and allow developers to customize and develop with minimal cost, and the timeline involved is reduced compared to other languages ​​or settings.

Right or wrong? This is all a personal opinion, but ultimately the needs of the project will determine which set of tools is best suited. If your application has low traffic, and you want it to be developed and live in a few months, it would be ideal to use one of the languages ​​mentioned above and / or the framework.

But what about C ++,. Net and J2EE? Theres a place for everything. They typically have higher upfront costs associated with time and energy to architect the project, customize the development environment, and complete the actual development. But the languages ​​and structures built from them are better suited for scalability to accommodate heavy traffic or computing.

Take a look at Facebook as an example. The original site was prototyped and deployed as a PHP application, and the user base was relatively small. Since the site has grown into a monster, we know this, because today they scaled their application, implementing J2EE on the back panel, using existing PHP scripts for the interface.

As a person with experience developing J2EE and Python / PHP, there is a very obvious set of advantages and disadvantages. I can create a blog with PHP in a few days, ready for public access, but the same project in J2EE can take much longer.

Forgive my terminology, but Enterprise languages ​​(J2EE, .Net) require significant configuration and deployment efforts. Ruby, PHP and Python no, you just open Notepad, write your code and save it with the correct extension, and you are ready to download.

Does it help?

+3
source

The desire of the programmer, development time, ease of use, portability and much more I can not mention

Actually ... it's not so awful and a slow development process in C ++, if you use the right tools.

The wiki that runs this project was written a few days later (and yes, in C ++) ... Not bad for the awful C ++ language; -)

Take a look:

I think this is not a slow process in the evenings to create such a wiki: http://art-blog.no-ip.info/wikipp/en/page/main

+2
source

No, his points are not valid. It’s not that it’s better than another, but, for example, C # and java, these are just more modern, modern languages ​​that were developed taking into account C ++ problems.

It doesn't make sense to worry about things like garbage collection if you don't need it. In addition, in different languages ​​of the web infrastructure, there are so many components, controls, modules, and many other parts, open source or otherwise written for them by other developers, you will invent wheels in other languages ​​everywhere.

I will always have a place in my heart for C ++, but this is a kind of idiotic or troll worthy of suggesting you better write sites in C ++.

(EDIT: Maybe if C ++ is the only language you know, or you have a lot of home-made C ++ components for the Internet, but your probably doesn't learn C ++ better for website development it's easy to find out once you know C ++ / C)

+1
source

Its scores are NOT valid for 99% of web applications. Web applications benefit from fast iterations and user-friendly interfaces that are best suited for languages ​​such as PHP, Python, and Ruby. If you are good or lucky to develop a highly used service, you have few problems scaling it.

0
source

The last thing I checked, php, Ruby and Python are written in C. Isn't it?

-3
source

All Articles