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

What are the technical advantages of Python? What is better than other languages?

編輯:Python

Python What are the technical advantages

1. Object oriented and functional

Fundamentally speaking ,Python It's an object-oriented language . Its class model supports polymorphism 、 Advanced concepts such as operator overloading and multiple inheritance , And take Python Unique concise syntax and types for the background ,OOP Very easy to use . in fact , Even if you don't understand these terms , You will still find learning Python Than learning other things OOP Language is much easier .

In addition to being a powerful means of code organization and reuse ,Python Of OOP Its nature makes it an ideal scripting tool for other object-oriented system languages . for example , With the appropriate bonding code ,Python The program can be used to C++、Java and C# Class for subclass customization .

OOP It's just Python Just a choice , This is very important . Even if you can't become an object-oriented expert right away , But you can also continue to learn more . It's like C++ equally ,Python It supports both object-oriented programming and process oriented programming patterns . If conditions permit , Its object-oriented tools can come in handy immediately . This is very useful for policy development patterns , This pattern is often used in the design phase of software development .

Except for the original process ( Statement based ) And object oriented ( Class based ) Programming paradigm ,Python Built in support for functional programming in recent years —— A generator is included in most cases 、 deduction 、 Closure 、 mapping 、 Decorator 、 anonymous lambda A collection of functions and first class function objects . This is for itself OOP Supplement and substitution of tools .

2. free

Python It's completely free to use and distribute . Just like other open source software , for example ,Tcl、Perl、Linux and Apache. You can start your Internet Free access Python Source code . You can copy without restriction Python, Or embed it in your system or release it with the product . actually , If you like , You can even sell its source code .

But please don't get me wrong :“ free ” Doesn't mean “ No support ”. On the contrary ,Python Our online community is as responsive to user needs as commercial software . and , because Python Completely open source , Improve the strength of developers , And produced a large team of experts .

Although studying or changing the implementation of a programming language is not so interesting for everyone , But when you know you can do this if you need to , How gratifying . You don't need to rely on the wisdom of business vendors , Because the final document and the ultimate pure land ( Source code ) Let your use .

Python Development is community driven , yes Internet The result of a wide range of collaborative efforts .Python Language changes must follow a set of normative and binding procedures ( Referred to as PEP technological process ), And it needs to be thoroughly checked by the standardized test system . That's what makes Python It can be conservatively and continuously improved compared with other languages and systems .

Even though Python 2.X and Python 3.X The split between versions has effectively and deliberately undermined this tradition , But usually it is still reflected in Python Inside these two series .

3. portable

Python The standard implementation of is made up of portable ANSI C Compiling , It can be compiled and run on all current mainstream platforms . for example , Now from the palm computer (PDA) To supercomputers , Can be seen everywhere Python Operation of .Python Can run on the following platforms ( Here is just a partial list ):

  • Linux and UNIX System
  • Microsoft Windows( All modern versions )
  • Mac OS( Include OS X And classic )
  • BeOS、OS/2、VMS and QNX
  • Real-time operating system , for example VxWorks
  • Cray Supercomputers and IBM The mainframe
  • function Palm OS、PocketPC and Linux Of PDA
  • function Symbian OS and Windows Mobile Mobile phone
  • Game terminals and iPod
  • Running Google Android and apple iOS Tablet and smart phone of the system
  • And more

In addition to the language interpreter itself ,Python The self-contained standard libraries and modules at the time of release also consider cross platform portability as much as possible in their implementation . Besides ,Python The program is automatically compiled into portable bytecode , These bytecodes are installed in compatible versions Python The results are the same when running on the platform of .

These mean Python The core language and standard library of the program can be found in Linux、Windows And others with Python The interpreter runs indiscriminately on the platform . majority Python Peripheral interfaces have platform related extensions ( for example COM Support Windows), But the core language and libraries are the same on any platform .

As we mentioned before ,Python It also contains a called tkinter(Tkinter Of 2.X edition ) Of Tk GUI tool kit , It can make Python The program realizes complete functions , It can be used in all mainstream without any modification GUI Graphical user interface for desktop platform operation .

4. Powerful

From the perspective of language characteristics ,Python It's a mixture . Its rich toolset puts it somewhere between the traditional scripting language ( Such as Tcl、Scheme and Perl) And system language ( Such as C、C++ and Java) Between .Python Provides the simplicity and ease of use of all scripting languages , And it has advanced software engineering tools that can only be found in compiled languages .

Unlike other scripting languages , This combination makes Python It is very useful in long-term large-scale development projects . Here are some Python Introduction to the tools in the toolbox :

  • Dynamic type :Python Track the type of object while the program is running , There is no need to declare complex types and sizes in the code . in fact ,Python There is no type or variable declaration in . because Python The code does not constrain the type of data , It often automatically applies a generalized object .
  • Automatic memory management :Python Automatically allocate space for objects , And when the object is no longer used, it will automatically undo the space (“ Garbage collection ”), Automatically expand or shrink when needed . As you will learn ,Python Can help you complete the underlying memory management .
  • Large program support : In order to build a larger scale system ,Python Contains modules 、 Classes and exceptions . These tools allow you to organize the system into components , Use OOP Reuse and customize code , And handle events and errors in an elegant way . aforementioned Python Functional programming tools , Provides other ways to achieve the same goal .
  • Built in object types :Python Provides common data structures as a basic part of the language . for example , list (list)、 Dictionaries (dictionary)、 character string (string). We'll see , They are flexible and easy to use . for example , Built in objects can be expanded or contracted according to requirements , Can arbitrarily organize complex information, etc .
  • Built in tools : To handle the above object types ,Python It comes with many powerful standard operations , Including splicing (concatenation)、 Fragmentation (slice)、 Sort (sort) And mapping (mapping) etc. .
  • Library tools : To accomplish more specific tasks ,Python Many precoded library tools are preset , From regular expression matching to network support . When you master the language itself , Can be used in application level operations Python Library tools for .
  • Third party tools : because Python It's open source. , It encourages developers to provide Python Precoding tools other than built-in tools . You can find it on the Internet COM、 The image processing 、 Numerical programming 、XML、 Database access and many other free support tools .

In addition to this series Python Outside the tool ,Python It maintains a fairly concise syntax and design . The result of all this is a powerful programming tool with all the usability of scripting language .

5. Mixable

Python Programs can easily interact with components written in other languages in a variety of ways “ Bonding ” together . for example ,Python Of C Language API Can help Python The program flexibly calls C Program . This means that you can give as much as you need Python Program add function , Or in other environmental systems Python.

for example , take Python And C perhaps C++ The library files are mixed together , send Python Become a front-end language and customization tool . As we mentioned before , This makes Python Become a good rapid prototyping tool ; The system can be used at the initial stage of development for speed Python Realization , Then transfer to C, Gradually realize the system according to the performance needs in different periods .

6. Relatively simple and easy to use

Same as other languages ( Such as C++、Java and C#) comparison ,Python Programming is surprisingly simple for most users . To run Python Program , You simply type Python Just program and run it . No other language is required ( Such as C or C++) Necessary intermediate steps such as compilation and linking .

Python The program can be executed immediately , This creates an interactive programming experience and the ability to quickly adjust in different situations , Often you can see the effect of the program change almost immediately after modifying the code .

Of course , The short development cycle is just Python One aspect of ease of use .Python Provides simple syntax and powerful built-in tools . actually ,Python Used to be called “ Executable pseudocode ”. Because it reduces the complexity common to other tools , When implementing the same function ,Python Programs are simpler than programs written in other popular languages 、 small , And more flexible .

Python How does it compare with other languages

Last , You may already know , People tend to Python And Perl、Tcl and Javat And other languages . This part summarizes some general consensus in this regard .

I want to make it clear in advance that I personally don't like to win by slandering competitors —— This will not work in the long run , And it's not the purpose here . Besides , This is not a zero sum game —— Most programmers use many languages throughout their careers . For all that , Programming tools also show choices and tradeoffs worth considering . After all , If Python Nothing offers more than its competitors , Then it won't be used in the first place .


We've covered the performance tradeoffs before , Here, we will focus on the functions . Although the languages listed below are also powerful tools worth learning and using , But people usually think that Python:

  • Than Tcl Powerful .Python Strongly support “ Large scale programming ”, Make it suitable for developing large-scale systems , Its application library is also richer .
  • Than Perl More readable .Python It has simple grammar and simple and coherent design , This in turn makes Python More readable and easier to maintain , It also helps to reduce the number of programs bug.
  • Than Java and C# It's simpler 、 Easier to use .Python It's a scripting language , but Java and C# Both are like C++ So much larger OOP Many grammars and complexities are inherited from the system language .
  • Than C++ It's simpler 、 Easier to use .Python The code is better than the equivalent C++ The code is simpler , It is only one fifth to one third of its length . Although as a scripting language ,Python Sometimes I can play many different roles .
  • Than C More simple and advanced .Python Stay away from the underlying hardware architecture and reduce code complexity , Have a better organizational structure , Parallel ratio C(C++ The ancestors of the ) More friendly .
  • Than Visual Basic More powerful , A wide range of uses , It also has cross platform features .Python Is a more widely used and richer language , Its open source nature means that it cannot be controlled by any one company .
  • Than PHP Easier to understand and more versatile .Python Also used to build Web Site , however , It is also used in almost every computer field , From robots to movie animation and games .
  • Than JavaScript More powerful and versatile .Python There is a larger toolset , Nor is it firmly bound to Web Development . It is also used in scientific modeling 、 Instrument commissioning, etc .
  • Than Ruby More readable , And more acceptable .Python Less grammatical confusion , Especially in more complex code , At the same time, its OOP Not very useful for users and OOP Is completely optional in the project .
  • Than Lua More mature and received more attention .Python A larger feature set and more extensive library support give it a better performance than Lua( One door and Tcl Same embedded “ glue ” Language ) A broader view .
  • Than SmallTalk、Lisp and Prolog Even less obscure .Python Have a dynamic taste for this kind of functional language , But it also has a traditional syntax that is acceptable to both developers and end users of customized systems .

Especially for text files that are not only used for personal scanning , The future will be ( Including you ) Read the program , A lot of people will find out Python Better value than any currently available scripting or programming language . More Than This , Unless your application requires cutting-edge performance ,Python Tend to be C、C++ and Java And other system development languages :Python Code can often achieve the same goal , But it will reduce a lot of writing 、 The trouble of debugging and maintenance .


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