What are the advantages and disadvantages of Node. js and Python as backend Service programming languages?

Source: Internet
Author: User
Tags windows support
Front-end, but I want to learn a back-end language. I originally wanted to learn Nodejs. After all, if I use Node as the back-end language, It is also helpful to be familiar with the front-end js, however, we found that the Node learning curve was steep, and there was no good learning material, and Node was not very popular in China. We found that Python was a good back-end language and had a lot of learning materials, now I am struggling with the two. Could you please advise? Front-end, but I want to learn a back-end language. I originally wanted to learn Node js. After all, if I use Node as the back-end language, It is also helpful to be familiar with the front-end js, however, we found that the Node learning curve was steep, and there was no good learning material, and Node was not very popular in China. We found that Python was a good back-end language and had a lot of learning materials, now I am struggling with the two. Could you please advise? Reply: @ SUN Ruoyu I 'd like to say that Node is not good at CRUD.

CRUD applications have little to do with the platform itself, but more importantly, it depends on the open source Library at the upper layer. Express + (mongo + mongoose) | (node-mysql + sequencee) CRUD development is also fast, more importantly, Node's asynchronous database I/O performance is much higher than that of Python.

Some people say that Node lacks a "mature" Big framework. In fact, this is related to the development ideas of the Node community. Several leading developers advocate "small programs that write one thing well, then concatenate them. "The Unix philosophy, coupled with npm, is very good at processing the dependencies between packages. Therefore, flexibility is actually one of the selling points of Node. In my opinion, Node does not need a "big and comprehensive" web framework like rails/django. Disclause: The following comparison may have strong personal colors

Node. js> Python
  1. Fast: There are two ways to speed up. First, the V8 engine is fast.Lars BakGreat God, he created high-performance SmallTalk engine and Java Hotspot engine (now Java's default VM). The V8 engine he led brought Javascript speed to a new stage. The second is asynchronous execution, Node. js functions are an Asynchronous Network and I/O Library Based on the V8 engine, which is similar to Python's Twisted. The difference is Node. js event loop is very underlying in the language. It can be imagined that the entire file is in a large event loop during execution.
  2. Npm: npm is the most popular package management. As the official package management of Node. js, npm brings together the most concentrated resources of the entire community. Unlike Python, which has experienced easy_install and pip, there are still 2to3 problems.
  3. Windows support: Node. javascript has the blessing of Microsoft, and Windows is basically supported by first-class citizens. libuv can already achieve unified cross-platform API, while Python also has official support for Windows, but I always feel like a second-class citizen, and sometimes there are some problems.
Python> Node. js
  1. Language: from a language perspective, Python is much more comfortable to write than Javascript. The Javascript design has many defects. After all, it was designed only as a script for simple tasks in the browser. Therefore, once the code is large, maintenance is still difficult (but Node. js module greatly improves this problem ). However, using Coffeescript can greatly improve Javascript, which is almost equivalent to Python.
  2. Maturity: the language itself is mature, and the Framework and ecosystem are also very large. The vast majority of Node. js frameworks are new, Some APIs are constantly changing, and some feel that they are no longer maintained. In short, there is no framework that feels like Django. The mainstream ORM SQLalchemy of Python is also very mature.
It is difficult to distinguish between Python and Node. js.
  1. Asynchronous Style: the asynchronous Style of Node. js is CPS, that is, layer-by-layer callback. Based on event, it is similar to Javascript in the browser. The advantage of CPS is that it is easy for anyone familiar with browser Javascript to get started quickly. The disadvantage is that the logic is complex and becomes difficult to maintain. Basically, you need to use libraries like async. js or promise. In addition to Twisted, similar to Node. js, asynchronous Python also has a gevent Based on coroutine. coroutine makes asynchronous code maintenance easier, but the learning curve is steep.
  2. Application Scenario: if it is a CRUD app, you do not want to directly use Python or Node. js itself is not good at CRUD apps (the vast majority of nodes. js is directly exposed, rather than Nginx, otherwise websocket will not be available, but the new nginx version starts to support websocket), and the Code is not well maintained, the WSGI of Python is very suitable, and there are many mature stacks. If you prefer real-time, such as a chat room, it is easier to implement Node. js. The two application scenarios are different.
I personally have access to Django and a small number of Node. js
Which of the following is the main use of web development?
In my opinion, Django is more comprehensive, developing a complete website or cms.
Node. js features are also prominent, but Node is fully used. it is not cost-effective to develop a complete website using js. I prefer to use Node. the RESTful server developed by js can solve high-frequency requests and avoid the depth of event nesting.
So with this idea, Django is developing the web, using Node. js in some parts that require RESTful or high-frequency requests.
Their respective strengths... SUN Rouyu's answer is comprehensive. In addition, the require of npm and commomjs has surpassed a simple package management tool and has developed into a system architecture.
In addition, I use CoffeeScript to write Node. js, so that I can enjoy the benefits of both worlds.
Although Python also has an asynchronous library, the implementation of different frameworks and libraries is inconsistent because Asynchronization is not its DNA. For Node. js, the asynchronous mode has become the first specification for the 99% Modules. This consistency is required by a robust background program. The asynchronous encapsulation of non-blocking IO and coroutine synchronous methods brought by Python gevent is sufficient to terminate Twisted;
Nodejs features non-blocking I/O and faster language interpreters. However, based on the event programming model, Nodejs is more suitable for the front-end of the user response method, and most of the server logic is RPC or cyclic;
In distributed and SMP architectures, gevent multi-process + coroutine + simple language features + easy C/C ++ performance expansion is definitely an ideal choice. The Node. js framework express should be similar to the Python framework Django, Tornado, and Flask. If you are familiar with js, you should start with Node. js. Performance differences

I don't think many people's systems are more complicated than paypal's.
Paypal is now full of nodejs (the background BI may still be java)

However, it is difficult to build large code in prototype mode.
Converting to oo programming is no different from writing python

Callback is not a problem. I didn't use the pure js NATIVE METHOD OF THE js library that transformed callback.
If you get used to it, please refer to this: What is Node. js?

Node is a server-side JavaScript interpreter that will change how the server works. It aims to help programmers build highly scalable applications and write connection code that can process tens of thousands of concurrent connections to one (only one) physical machine.
To try to explain what Node is. js, this article will briefly introduce some background information: the problem to be solved, how it works, how to run a simple application, and finally, under what circumstances is a good solution for Node. This article does not involve writing a complex Node application, nor is it a comprehensive Node tutorial. Reading this article should help you decide whether to continue learning Node for your business. I have used python and nodejs. I do think that the design of python is better than that of javascript, but nodejs is actually better than python in actual development.
Nodejs has the following advantages:
1. The node. js environment is very easy to build, and npm package management is also easy to use. Just run a few commands, while installing the python environment is painful.
2. node. JS is forced asynchronous, io asynchronous, mysql asynchronous, http requests asynchronous, and asynchronous callback is a natural usage of javascript. Therefore, the actual project can be much faster than python's synchronized mysql without too many optimizations.
3. nodejs is consistent with the front-end. In actual development, you do not need to switch the environment and language like python.
4. The watch function of nodejs file system greatly facilitates testing and compilation, and greatly improves development efficiency.
5. nodejs has formed a huge ecosystem today: npm has the largest number of libraries, angularjs is very close to the back-end programming style, and the testing framework combined with watch, webpack, livereload, pm2, all these things are far better than those of other languages for web development.
6. The evolution of the javascript language gradually makes javascript more useful. For example, the callback gradually evolves to Promise, and async/await must be python. python is not reasonable here.
To align with each other, nodejs should align with the python tornado framework.
I have studied Baidu's clouda before, so I have been in touch with both of them.
I will focus on tornado, but nodejs has little advantage in front of tornado.
First, Performance
Node is superior to tornado in terms of performance, but has little advantage. It can be said that it is the addition of language bonus and C ++. However, their design philosophy is similar, so the performance gap is not big. What's more, if the processing speed of the business is slow, the throughput will be too large.
Second, Ease of use
This python-based tornado wins. You can write asynchronous code in synchronous form without needing to use a lot of callback and closure, which is very important for business-heavy scenarios, this is also the cause of steep node learning costs. If it is not easy to use, the risk of memory explosion stack caused by a large number of closures of node will surely make everyone learn node.
Scalability
There is no doubt that except lua, there are no other languages that can be said to have python scalability and convenience, for Computing-intensive businesses or functions, you can easily use C language to customize extensions (I have even written an awk nested programming ). What's more, python also has an extension package with a geometric multiple of npm. (I should know that at least many npm modules cannot be directly looked at. You have seen that one module has only one function, is there a single sentence in it? The number of high-quality libraries cannot be compared with pypi. The development threshold is there, so I will not admit that npm has a large number of python packages because it is too much garbage ). In addition, you can also modify and customize the framework layer (of course, under the license), redefine the engine behavior, eventloop behavior, and have a high degree of freedom.
Maintainability
Needless to say, js Code is difficult to write elegant and cool python, and the readability of various callback and closures is simply a disaster. In addition, the js language itself has many pitfalls. This round of python wins.

In short, I am personally in this situation. If someone talks about nodejs and tornado, I will tell him that I don't need to use python. Even if I want to resign.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.