Home  >  Article  >  Web Front-end  >  What is the difference between python and nodejs

What is the difference between python and nodejs

青灯夜游
青灯夜游Original
2021-09-01 15:48:376252browse

The difference between python and nodejs: 1. python cannot directly manage multiple versions of dependent packages; while nodejs can directly use NPM for package management. 2. Python is divided into two major versions, 2 and 3, which are less compatible with each other; while the nodejs version and API are relatively stable and unified. 3. Python lacks the ability to compile JIT dynamically, but node can. 4. The learning cost of node is low.

What is the difference between python and nodejs

The operating environment of this tutorial: windows7 system, nodejs 14.15.4&&Python3 version, DELL G3 computer.

Package and module management

  • Dependent package multi-version management
    • Python cannot be managed directly, and virtualenv needs to be used to separate different versions Environment
    • nodejs NPM package management, you can rely on different versions of third-party modules at the same time
  • Introduce modules
    • python use from/import , it is difficult to distinguish different modules with the same name
    • Other modules introduced by the nodejs module have locally valid names in this module, which is more free, flexible and convenient
  • Export module
    • python
    • nodejs Just add attributes directly to exports, or assign a value to module.exports. It is not a language level, but a simple ordinary operation

The language itself

  • Version unity
    • Python is divided into two major versions, 2 and 3. Mutual compatibility is poor. Many modules require module versions of specific python versions, which is quite confusing.
    • nodejs version and API are relatively stable and unified, and NPM is compatible with dependent modules of various versions. Version management is orderly and very good. Supports the version evolution of node core and third-party modules.
  • Grammar
    • python is indeed relatively concise and clear, especially the support of rich data structures. Various concise operators replace functions, which can be said to have rich syntactic sugar
    • nodejs language is javascript, and the core is more streamlined. Although its own data structure and data processing are relatively simple, using coffee-script can make up for it. coffee-script is simply the javascript version of python
  • Flexibility
    • javascript prototype-based inheritance is more flexible
    • nodejs event-based Processing makes hooks and extension points everywhere
  • hackability
    • python is not easy to hack
    • javascript is very easy to hack

Performance

  • They are all interpreted languages
    • Python lacks dynamic compilation JIT capabilities
    • nodejs v8 can JIT execute javascript, and the performance is better
  • Concurrency model
    • python requires multi-thread programming
    • nodejs adopts Non-blocking asynchronous I/O, very efficient for non-CPU-intensive applications

Development quality and efficiency

  • Both It is an interpreted language
    • It cannot perform various checks during compilation
    • But nodejs has various formats and syntax checkers in the javascript language for use
    • You can use coffee-script to develop javascript, absorbing a lot of python syntax sugar
    • build system
      • nodejs has a complete build system (grunt/gulp)
      • nodejs The richness, innovation and activity of web development resources are much higher than those of python

##Learning cost

    If you only have the energy to learn one language

    • it must be javascript, because at least the browser front-end requires js
    • js language core is smaller, more refined, and more The syntactic sugar and functionality are provided through modules or libraries
    • nodejs itself can be used as a production web server, while python requires at least nginx proxy
  • Environment preparation

    • There is no python environment by default in Windows, but you can practice javascript in the debugger console in the browser

#Asynchronous programming framework comparison

  • Comparison of JavaScript's nodejs and python's tornado

##Angle(javascript)(python)Language itself performanceIO performanceEcosystemIt is also not easy to integrate third-party modulesCross-platform
nodejs
tornado

v8 engine performance Very good Python interpreter performance is poor
Use epoll and other efficient IO mechanisms, the performance is good Use Epoll and other efficient IO mechanisms have good performance
Nodejs versions and peripheral module versions match well Python is compatible with various versions Sexual issues,
nodejs supports x86/arm/power/sparc python Due to the extensive use of c/c modules, cross-platform is poor
Other similar points

Aspect(javascript)(python)##Package ManagernpmpipPlatform multi-version managernvirtualenvProcess Monitorpm2supervisor

Related recommendations: nodejs tutorial

nodejs
tornado

The above is the detailed content of What is the difference between python and nodejs. For more information, please follow other related articles on the PHP Chinese website!

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