Interpreted or compiled languages ​​for websites (PHP, ASP, Perl, Python, etc.)

I create database driven websites. I used to use Perl or PHP with MySQL.

Now I am starting a big new project, and I want to do it so that as a result the most responsive site possible appears.

I saw several pages here where questions about how to optimize PHP are criticized with different versions: "It is not worth making big strides to optimize PHP, because it is an interpreted language, and it will not make much difference."

I have also heard various discussions (especially in the SO podcast) about the benefits of compiled and interpreted languages , and it seems to me that it is in my interest to use a compiled language to serve the site instead of the interpreted language.

Is this possible in a web context? If so, what would be the smart language choice?

In addition to speed, one advantage that I foresee is the ability to find errors at compile time instead of debugging the website. Can this be expected?

+7
php webserver
source share
7 answers

What you can do is what several sites with high traffic do (for example, Facebook or Twitter), and also write your "processor consuming" algorithm in the C-plugin.

For example, you can write a PHP extension if you plan to use PHP or Ruby extension , if you plan to use Ruby / Ruby on Rails, etc.

Thus, you can simplify and simplify the management of your simplified code (it may be more difficult to process the request with C rather than with PHP), having a strong and robust core core (because it is compiled and the compiler tells you what problems are during compilation)

+7
source share

If you are going to create a new language ... and you come to all the semantics, and it was completed, and you had a magic box that had a transition between creating a language, compiled or interpreted, the compiled version will be faster than the interpreted version.

Why? Since compiling brings your semantics to a lower level on the machine, which means that it can run much faster, while interpreting means that the semantics of your language will be translated by some sort of thing (i.e. an interpreter) when the user actually uses your site.

Having said that ... this does not necessarily mean that your site will run 100% faster in a compiled language and an interpreted language. There are translators who are very fast at present for different languages ​​(i.e. PHP), and there are even optimizers for interpreted languages ​​that make them even faster.

There are many other things that affect the performance of your site, which are agnostics of your chosen language. Hardware setup, Database setup, Network topology, etc. These things can have a greater impact on you. I would suggest measuring to be sure.

For me, finding errors during compilation is a huge time saver, so I prefer compiled languages ​​that are strongly typed. This allows me to do my work faster, but this does not make it objectively the best option. Some people have no problem writing weakly typed code and running test suites to test their functionality, which I think will work just as well.

+4
source share

IMHO it is quite difficult to write a complex web application using a compiled language, because it does not provide the benefits of a number of manageability problems.

There are many ways to improve performance and scalability in a scripting language, both at the language level and at the system level, being secondary, ultimately available with a compiled language that is fully influenced.

On the other hand, it’s very useful for me when you can follow the fast development and search scheme of errors by simply changing your code and viewing the results.

0
source share

Perl is not an interpreted language: it is compiled into bytecode, so you pay the price for translation only when you run the perl executable. Therefore, when you use it with Apache, do not use CGI, but mod_perl.

Whatever you do, the development time is likely to significantly exceed the response time if you choose a language that is not suitable for web programming, or you do not have good libraries to support what you need to do. For example. I would never choose C or C ++. You do not want the web application to be fast, but buggy and 6 months late.

0
source share

Tomcat is a common way to use compiled languages ​​to deploy web pages, but before you go too far, seriously think about what your speed bottlenecks will be. There are several main sources of web application slowdowns:

  • Network delays
  • Static media, especially images
  • Database queries
  • Server Side Processing Code
  • Client Processing Code

1 and 5 do not really have much to do with this issue.

2 will be relevant if you have many images that vary from page to page. In this case, client browsers will not do such good caching work, and each page loading will take some time. In this case, it is very likely that your server language will not be noticed, since service data from a static medium predominates.

3 is likely to be a larger factor than 4 for many applications. If you have very little data, but you are doing a lot of processing, then 4 may dominate, but otherwise 3 will dominate, even if you use an interpreted language.

People may ask, "Why optimize php?" because 2 and 3 are often more important. Often a good database caching system will be a better (and simpler) optimization.

0
source share

There are many parts that go into a web application. The time taken by the application layer should not be large. For a typical application, the largest pigs will be on the web server and in the database. Replacing PHP with binary cgi will not change this.

In addition, although the interpreted parts of PHP may be somewhat slow, this is only a small part of what happens when the PHP script is executed. All functions provided as part of the language are implemented in native code. For example, when you call a function like preg_match , it is called from a library of native codes and allows it to do its job. This means that a less realistic interpretation is occurring than you think.

Perhaps in some cases, using a language other than PHP may be useful, but these are special cases. In general, nothing will work here.

0
source share

Network latency is by far the biggest determining factor in this argument. In fact, network latency is such an important factor that it does not take into account performance considerations. So ... go with what you know. Use the language that is most convenient and productive for you, and other considerations may be developed along the way. Now, it’s always interesting to try new things, and learning new things can become an obsession, so if the project is personal, which allows you to experiment, well, by all means .....

0
source share

All Articles