程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Is Python and JavaScript fair?

編輯:Python

author | STX Next

translator |  Meniscus

Produce | CSDN(ID:CSDNnews)

Should be used in the discussion Python still JavaScript When building a project , In general, we would not say that we only use one programming language to build all components .

In modern software development , If you want to build software that meets the standards , Make sure to complete... By the deadline , Or build an application that can handle millions of users , that I usually use multiple languages 、 frame 、 Tools and API.

therefore , If we want to compare Python and JavaScript, Then we should discuss the use of these two languages to build the core components of the software .

In addition to this core theme , We will also discuss in this article :

  • Instagram To be the biggest in the world Python The story behind the application ;

  • Best fit Python and JavaScript Applications for ;

  • The two languages complement each other .

Python and JavaScript A quick introduction to

Before delving into the details , First, let's briefly review Python and JavaScript Development experience of , And their current unique position in the programming world .

Python The process of becoming one of the largest programming languages

Python Published in 1991 year , This is a general purpose programming language , Therefore, it can be used to solve any problem that can be quantified and described by code .

In recent years ,Python Its popularity in the technology market has increased significantly . stay Django etc. Web Development framework ,Python popularity gained by good reputation , Besides Python It is also very popular in academic circles . after ,Python It has become the preferred language for machine learning and data processing , This is further increased Python The popularity of .

CSDN Pay to download from visual China

Python With the help of Django etc. Web The development framework has become more popular in network development , Although not as good as JavaScript. stay 2020 Year of StackOverflow Developer survey ,JavaScript With 67.7% The usage rate of is the highest , and Python The usage rate of is 44.1%. In terms of framework ,JavaScript Libraries and frameworks jQuery、React and Angular In the top three .Django In the first 10 position .

Now , Many scientists and researchers are using Python, These people are well versed in complex scientific knowledge , But the technical force is not particularly strong , For them ,Python It's a language that's easy to learn . Scientists can use Python Rapid prototyping , So this language is more attractive .

All because Python Is one of the simplest languages , But this language is easy to get started , It's hard to master . Even if you're not a programmer , You can also use Python Simple automation , For example, capture the data of the website , Or migrate data from one program to another .

Besides , If you spend some time to really master Python, You can use it to build all kinds of software .

JavaScript The long road to becoming a universal programming language

JavaScript On 1995 First introduced in . There was no such thing as Web application ,JavaScript The goal is to Web Become a true application platform .

JavaScript The development of is not plain sailing . Due to some design choices , And bad marketing ,JavaScript Rejected by many developers , And because of the low network speed and low bandwidth ,JavaScript Our ability is also very limited . in addition , For a long time , Cross browser compatibility has always been a problem , This makes it difficult for developers to build websites that run on all browsers .

CSDN Paid download from the East IC

these years ,JavaScript The popularity of has been growing steadily . On 2006 Published in jQuery Is the first library to eliminate cross browser compatibility issues . stay jQuery With the support of , The implementation of website interactivity becomes easier . Then came a mainstream framework AngularJS, But it was later Angular 2+ replace , Today the framework is still very popular in enterprise solutions .

2011 year ~2012 About years ago ,JavaScript For the first time, it is supported by all major browsers , Include Firefox、Chrome、Opera and Safari. But even now ,JavaScript Still unable to obtain 100% Support for . This is because JavaScript New features will be added regularly , Therefore, browser developers must constantly strive to improve their understanding of JS Support for .

2013 year ,Facebook The engineering team released React, The framework quickly became popular , And for consolidation JavaScript As the most popular network technology, it has contributed an important force .

Of course , The above is just JavaScript A summary of the history of development , In fact, the whole development process is even longer , More complicated . in general ,JavaScript Experienced many hardships , It's where I am today .

at present , new edition JavaScript The design of is moving towards a mature universal programming language .

When to use Python and JavaScript To build core components

If the core component or system fails for a long time , The whole project will collapse . therefore , We need to choose the construction technology of this part carefully .

For lower priority systems , You can try different methods , Find the most cost-effective way . However , When choosing a programming language for building core components , Adopting this attitude will lead to the failure of the project .

Suppose there is an application that is mainly used to share photos and videos , Has more than one in the world 10 Billion users , Then the server that handles massive content is the core component of the application . For such applications , My first thought was Instagram, This app is known as “ The biggest in the world Python Website ”.

Instagram An engineer of has said ,“Instagram Your server is completely powered by Python drive .”Instagram The server application is “ A huge 、 Contains millions of lines of code and thousands of Django A large code base for endpoints ”.Instagram Every picture of 、 Every video is through the most popular Python Web frame Django Compiling .

Why? Instagram Will choose Python To write the core server ?

Instagram Used a lot of Facebook The server in the data center . Engineers need to manage more than just the look and feel of the application 、 Message flow 、 Content recommendation algorithm , You also need to make sure that the server CPU Will not overheat .

This is an extremely difficult task . they Why choose Python As the main language ?

Instagram Our developer blog has published the answer :“ We initially chose to use Python, Because the language is simple and practical , This is very consistent with our philosophy , That is, start with simple things ’. But simplicity has one drawback : Low efficiency .”

Simple and practical .Martin Fowler He is a master of software development , With decades of working experience , A number of books have also been published , He once wrote :“ Any fool can write code that a computer can understand . But only good programmers can write code that human beings can understand .”

It means , Although your goal is to ensure that the machine does not overheat by serving billions of users every day , But the way to do this is not to learn how to write machine code better . You have to write code that is easy for other developers to understand , So they can quickly debug the code if necessary , Or build new functionality on top of existing code , And don't worry about destroying existing systems .

Python Very suitable for this kind of application , Because the language Easy to read 、 Concise and easy to understand .

Instagram Use JavaScript Do you ?

although Instagram The server of is Python, But the interface is not made up of Python be responsible for .Python Responsible for storing and managing all data , But the interface on smart phones is built using native programming languages , And a large part comes from JavaScript.

Instagram The mobile interface is to use Swift(iOS) and Java(Android) Built , But the popular mobile front end JavaScript frame React Native It also played an important role .Instagram The reason why the engineer chose this framework , Because they want to improve the development speed , In this way, the application can be iOS and Android Version adds new features .

React Native It's the best choice , Because engineers only need to write a set of code to release new functions on different systems . They can use JavaScript The code creates a native interface on both systems .

They could have used another method , For example, using Swift and Java Build a separate interface , But they chose React Native. stay React Native With the support of , Maintaining the interface can not only save cost and development time , And it can also reduce the burden on developers .

Python And JavaScript: Which language is used more ?

Instagram It represents the benchmark of the current network and mobile industry . Many popular applications use a similar structure : Back end adoption Python, The front end uses JavaScript.

Even with Instagram It's totally different PayPal, There are similar technology stacks . They said in a very simple statement that they used Python To manage data , And it uses JavaScript To create a user interface .

This statement is extremely simplistic , Because to understand the details of the programming languages and tools they use , Will be overwhelmed by complexity . in addition , They don't look like Instagram So keen to share the details of the technology stack with the world .

Another blog post explained that ,PayPal Middle tier infrastructure (Web Server and front end ) Adopted Node.js, So they can just use JavaScript To build a website .

But this is not the core component .PayPal The core components of are hidden under all these interfaces , Many of them use Python( There are probably several other languages ) Compiling , And security 、 Stability and data management are also governed by Python conscientious .

JavaScript It is not suitable for the construction of core system . first , The design goal of this language is to add interactivity to the website , Although now it has developed into a powerful tool , But it is still limited by the design .

On the other hand ,Python The design goal of is a general programming language , So its use goes far beyond Web Development . Now ,Python It is also rooted in academia . We can not only use Python Build a website , But also can use this programming language to build artificial intelligence neural network .

therefore , in general ,Python The use of JavaScript More broadly . however , In several areas JavaScript It's the best choice , choice Python It's not very wise .

JavaScript Compare with Python The advantages of

JavaScript Is a winner in mobile development . Although there are some niche frameworks for mobile development ( such as Kivy and PyQT) It's using Python Developed , But few people use .

about Python For developers , Study JavaScript And use its most popular mobile development framework React Native To build an application is a reasonable choice .

There is another area JavaScript be a stroke above , That's front-end development . In building modern interfaces ,JavaScript Have a first-class framework (React、Angular、Vue). Developers can also use Node.js, Build the server side of the application . Besides , Developers can also JAM Technology stack ( namely JavaScript + APIs + HTML), Quickly build beautiful... In the short term Web application .

For a limited budget , Small and medium-sized enterprises with time constraints Web And the mobile development team ,JavaScript Absolutely the best choice .

Instagram and PayPal Our example shows that ,Python And JavaScript Use a combination of , Can build applications that dominate the market and revolutionize the lives of billions of people .

JavaScript Whether the performance exceeds Python?

Use JavaScript The built application can be in Web It runs fast on the Internet . And Python Applications compared to , There is no doubt that Node.js Built Web Applications will run faster .

just as Towards Data Science said ,“Python The performance of is relatively slow , Because it can only handle requests in one line , and Node.js You can use multithreading .”

There are some ways to optimize Python Performance of , Because its bottom layer uses C Language . for example ,NumPy Leverage optimized C The code improves Python The speed of .Cython It's a compiler , yes Python The superset of language , Developers using this compiler can build faster C modular , So as to speed up Python Execution of code .

Generally speaking , about I/O Stressful applications ( such as Facebook) Come on ,JavaScript It's faster , Such applications need to process large amounts of real-time data , It's important to avoid users waiting .

If it is CPU Demanding applications , For example, machine learning models that need to process large amounts of data to solve specific problems , be Python Faster . in addition , need GPU Applications that do a lot of Computing , You should also choose Python.

Instagram Belong to I/O Intensive application , But its server uses Python, This shows that , After reasonable optimization ,Python The execution speed of can also be very fast .

About performance , We also need to consider another dimension : Time to market . As long as the code is properly written , Both of these languages can be used to quickly build products that minimize feasibility . For complex programs , Use Python It can shorten the development time , Because the language is easy to read and debug . Besides ,Python It can also promote teamwork .

While using JavaScript Building a product can be complicated , Although it's fast , But the development time will be longer . For this reason , Now many companies choose TypeScript, Because some developers think TypeScript Than Python Easier to read and maintain .

In the field of machine learning Python And JavaScript Use

Python Is the preferred language for machine learning developers . Machine learning is complicated , It involves a lot of data , So choose Python be perfectly logical and reasonable .Python It is a simple and easy to read language , It can reduce the burden on developers , And it has always been the standard of data science .

Today's popular machine learning framework ( Such as TensorFlow、scikit-learn、PyTorc) Most of them use Python Compiling , And they also provide dedicated Python API.TensorFlow I was in 2018 The framework was released in JS edition , Support developers to build in the browser or Node.js The machine learning model running in the server .

But this is not enough to win the whole world of machine learning .Python Very suitable for machine learning , And it is unlikely to be replaced by another language in the short term .

Python and JavaScript The future of

Many people think that Python And JavaScript It's not fair to compare . After all, the two languages are designed for different purposes , Therefore, there are differences in the application of the two in software development .

It is these differences that enable the two technologies to complement each other perfectly in the modern programming world .

Will this situation change in the future ? For now ,JavaScript As the most powerful Web And the position of mobile application development tools seems to be very solid . meanwhile ,JavaScript It is also developing towards a general programming language , But can it replace Python Language like that , The jury is still out .

as for Python, because Readability 、 Ease of use and ability to process data , The language may continue to dominate the field of machine learning and academia .

At the end of the day , The choice of technology stack always depends on Nature of the project 、 The skills programmers have and many other factors .

* This paper is written by CSDN translate , unaccredited , Prohibited reproduced .

Link to the original text :https://medium.com/@STXNext/python-vs-javascript-is-it-a-fair-comparison-a3d90288a204

— Recommended reading  —

《 New programmers 001-004》 Fully listed

Welcome to scan the QR code below or click to subscribe now

You can enjoy e-books and exquisite paper books .

*Linux super macOS、 Most annoying Angular.js frame , A survey of 7 The latest discovery of 10000 developers !
*“ Write once , Operating each end ”, Qualcomm heavyweight releases AI Software stack !
* Move Tencent to the cloud , Cured their technical anxiety 

One key, three links 「 Share 」「 give the thumbs-up 」「 Looking at 」

100 million technical people


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved