Home  >  Article  >  Backend Development  >  Comparison between Rails and Node.js/PHP/Python etc.

Comparison between Rails and Node.js/PHP/Python etc.

巴扎黑
巴扎黑Original
2016-11-11 09:58:581310browse

First of all, this is not a comparison post. Can languages ​​and frameworks be compared?

Secondly, I haven’t used them all

The only purpose of this article is to remind myself (and you who are browsing) what you really need to pay attention to

PHP
PHP is a simple but dirty language, and simple means The learning curve is low, mainly because there are a large number of fool-proof applications based on PHP, such as wordpress, discuz, etc. If you only have general blog or forum needs, as long as you make good use of Google, you don't need to write even a single line of code. But, is PHP itself simple? Personally, I don’t think so, and I won’t list the reasons one by one. As for dirty, I think it’s more about its design. The language design is rather poor. You can get a glimpse of it just by looking at the function names connected by underscores. Except for experienced PHP programmers, it is difficult for anyone to write a program that is not serious. Vulnerable code.

Recommended PHP development frameworks: First class: Yii, Yaf, Symfony; Second class: Zend, Cake, CI

Django
Django is a web development framework based on Python, which is very similar to Rails. A few years ago, it was better than Rails The good thing is that Python is more "reliable" than Ruby. The so-called reliability means that more people use it, it has more documents, and it is easier to find answers by asking. However, with the gradual rise of Ruby in recent years (mostly driven by Rails) , more and more websites use Rails. When it comes to language design alone, Python is not necessarily simpler than Ruby, and its consistency is slightly less consistent. It can be said that Python’s only advantage is that many serious scientists are using it, accounting for most of the world in the field of scientific computing, while Ruby is made in Japan. (Ruby borrowed from Python). If Ruby was a language born in European and American countries at the same time as Python, I believe that there would be nothing wrong with Python now.

Rails
Rails is an amazing web framework. The shadow of Rails can be seen in almost all mainstream web frameworks now. Rails uses the characteristics of Ruby to the limit. Rails can be applied to all large, medium and small applications. Very large-scale applications cannot be handled by any scripting language alone. After years of development, Rails has washed away its glory and is now in a state of "outstanding". It can be said that no framework can surpass Rails in terms of comprehensive capabilities (ease of use, simplicity, efficiency, learning curve, etc.), and NodeJS cannot. Django is not good, and other "niche" languages ​​are even less good. On the contrary, Rails is in a state of rapid development, and successful cases of ultra-large-scale applications will appear one after another in the future.

NodeJS
NodeJS is a promising web framework, but it is a pity that it was born a few years later, otherwise it would still be able to compete with Rails. Compared with PHP, Django and Rails, NodeJS has relatively few open source projects and large-scale There are also slightly fewer successful cases, but its design and performance are also quite simple and efficient. I believe it will also shine in the near future.

ASP, JSP, etc.
Complex, bloated, enterprise-level, companies that rely on the accumulation of people, state-owned enterprises, banks, e-commerce, start-up companies will commit suicide if they use these, and it will also commit suicide if important departments do not use these (recruiting people are not good, they can only Use after-sales service).

Others
Other languages ​​have their own uses, but they just happen to be used in business. Strictly speaking, they cannot be considered specialized in network development, such as Clojure, Io, etc. We won’t discuss it here for now.

Summary:

If I were asked to choose the learning route again (only language, excluding server, db aspects), I would

understand php, no need to go in depth

understand Yii, an MVC framework for php, no need In-depth

Basically learn Ruby

Basically learn Rails

Learn Ruby thoroughly

Learn Rails thoroughly

Understand Python, Django, Lisp, Clojure, NodeJS, etc.

-------------------------- ----------Separation line------------------------------

This article is about rails The applicable scenarios for nodejs are described very well. rails and nodejs are the two most noteworthy backend technologies.
Disclaimer: This article is by no means a discussion about the advantages and strategies of NodeJS and Ruby on Rails. It only describes some of the thinking in our decision-making process and the reasons behind our decisions. Both frameworks are excellent and have accomplished their original design goals well, which is why some of our modules still run on NodeJS.

I am a big fan of NodeJs. I think this is a very exciting technology and I believe it will become more and more popular. I have a huge appreciation for this technology - even though we recently migrated our Targeter App from NodeJS to Ruby on Rails.

The reason why we used NodeJS to develop it was simple. I have a package that gets our app online very quickly (it took us 54 hours to do it), and I use JavaScript more than Ruby. Because our technical architecture involves MongoDB, these expertise of mine only make sense in a NodeJS environment. However, as the application grew in size, I realized that choosing NodeJS to implement this application was a wrong choice. Let me outline why.

NodeJS is well suited for applications that have a large number of short-lived requests. For traditional CRUD applications, it's fine, but not ideal. There are very mature and optimized frameworks in PHP, Ruby, and Python languages ​​to handle this kind of application. The idea that everything in NodeJS executes asynchronously has no effect on CRUD applications. Popular frameworks in other languages ​​provide very good caching technology that meets all your needs, including asynchronous execution.

NodeJS is a very young technology framework, and its surrounding libraries are not very mature. I say this without any offense to the code donors. They are excellent people and have developed many excellent libraries. However, most libraries need improvement, and the fast-growing environment of NodeJS means that there are a lot of changes in each version upgrade; when you use a cutting-edge technology, it is very important that you keep up to date as soon as possible. version of. This brings a lot of trouble to entrepreneurial companies.

Another reason is about testing. The testing framework in NodeJS is not bad, but it is still inferior compared to the ones on Django or RoR platforms. For an application that has a large number of code submissions every day and will be released within a day or two, it is crucial that the program does not have problems, otherwise your hard work will not be worth it. No one wants to spend a day fixing some stupid bugs.

Last point, what we need is something that can cache everything, and it needs to be implemented as quickly as possible. Although our application is growing, with tens of thousands of hits per second, there will never be a large number of access requests; this is not a chat program! The main program can reach 1000RPS at most. Such a load is nothing to Ruby on Rails and Nginx.

If you are still reading this article now, then you have seen everything I have to say, and you may be very insistent and want to know where our application is still using NodeJS. Well, our application consists of two parts. The first is the interface, the part that users see, and the second is the part responsible for report management and the logging function. The latter is one of the best usage scenarios for NodeJS, where there are a large number of short-cycle requests. This part of the action needs to be executed as soon as possible, even before our data push is completed. This is important because when the request execution has not yet ended, the browser continues to wait for the response to end, which will affect the user experience. The asynchronous nature of NodeJS saved us. The data is either stored in the database or processed, and once the request is completed, the browser can start doing other important things.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP namespaceNext article:PHP namespace