Where is Python better than Java?

Source: Internet
Author: User
Php Chinese network (www.php.cn) provides the most comprehensive basic tutorial on programming technology, introducing HTML, CSS, Javascript, Python, Java, Ruby, C, PHP, basic knowledge of MySQL and other programming languages. At the same time, this site also provides a large number of online instances, through which you can better learn programming... Reply content: Thank you for your invitation.

As a hybrid C/Java/Python developer for several years, I will talk about my feelings.

I think C, Java and Python are both very successful languages. Which of the following depends on your scenario.

To compare Python with Java.

Python:
Advantage (why can't I make this line bigger ??) :


The syntax is concise, elegant, and powerful. The standard library and third-party library are very powerful and have a wide range of application fields: vinta/awesome-python-GitHub (A clear comparison with PHP !)

Language:

Everything is an object !!!
Class (class itself)/function/class method is callable object
Because it is an object, you can upload it. for example:

Class A: def _ init _ (self): print "init A" def run (self): print "run A" threading. thread (target = ). start () #: execute A () a = A () threading in another thread. thread (target =. run ). start () #: execute. run ()... # stunned. How did this happen ?? Maybe you should look at the descriptor concept.
Because python is flexible and functions can also be passed and injected to a certain extent, the code is much more flexible. Java cannot pass parameters through functions before Java 8, in this case, Java developers can only write a large number of anonymous classes to inject code blocks (this is better than ruby block code injection, isn't it ).
Python comes with curry functions, delayed operations, and closure syntax, so python is more difficult to control than java at a certain level.
Of course, the best thing about python is the duck typing attribute. as a dynamic language proprietary feature, python can free objects from the constraints of the static language paradigm and patch programs at will, so the program scalability is better.
At the same time, as an interpreted language and server hot deployment, python certainly has an advantage. Once a program goes wrong, it can directly overwrite the original source file, while the Java server hot deployment is based on classloader switching, hot deployment of servers such as tomcat (that is, the reload function) can easily cause JVM heap to crash, and relies entirely on the server background thread to scan the timestamp of each code file, so the hot deployment of this python is better than java. It won't be hacked to use Python. Unlike Java, it is used to compare various scolds every day, and Java programmers are all despised. Also, I think the advantage of Python over Java is its concise syntax and strong expression. Nothing else. oh, python is also a scripting language. in some cases, the scripting language is a little better than the compiling language. The advantage is that the syntax is simple and clear.
After learning the basic python syntax, I can fully analyze the OTA package generation process of Android and interpret the ota_from_target_files script. If you don't ask why, you just ask why you are playing hooligans.

What language is used, only the most suitable and not the best. Niu in ...... first, Python is easy to use. then, as the learning goes deeper, the Python code is more elegant, while the Java code is more regular (swollen )....... python has two more letters than java. To put it simply
Python syntax: What do you think is true?
Java syntax: You think it is like this, but it is actually like this...

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.