首页 / JAVA / Java vs Python
Java vs Python
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Java vs Python,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2064字,纯文字阅读大概需要3分钟。
内容图文
面试时常问到这两种语言的区别,在此总结一下。
Referrence: Udemy:python-vs-java
Generally, Python is much simpler to use, and more compact than Java. It is generally easier to learn, and more forgiving when it comes to using shortcuts like reusing an old variable. You will also need fewer lines to write code in Python than in Java, partly due to the removal of the braces. As a side-effect, Python code is a bit easier to read and understand than Java.
Scripting Language vs Compiled Language
Dynamic vs Static Typing
Java: static typing
Python: dynamic typing
Java and Python differ in handling variables.
Java forces programmers to define the type of a variable when first declaring it. And Java will not allow you to cahnge the type later in the program.
Python allows programmers to change the type of a variable, like replacing an integer with a string.
Dynamic typing is easier for novice programmers.
But static typing can reduce the risk of undetected errors. When variables do not need to be explicitly declared before you use them, it is easy to misspell a variable name and accidentally create a whole new variable.
Braces vs Indentation
Python uses indentation to separate code into blocks.
Java, like most other languages, uses curly braces to define start and end of each funcation and class definition.
Advantage of using indentation:
1. Makes the program easy to read
2. Avoid errors resulting from a missing brace
Speed vs Portability
Java: "compile once, run everywhere" One major advantage of Java is that it can be used to create platform-independent applicaitons.
Whereas to run Python programs you need a compiler that can turn Python code into code that your particular operating system can understand.
Because most devices already have the Java virtual machine installed, so a Java programmer can be confident that their application will be usable by almost all users.
The disadvantage of running inside a virtual machine is that Java programs run more slowly than Python programs.
原文:http://www.cnblogs.com/ireneyanglan/p/4944162.html
内容总结
以上是互联网集市为您收集整理的Java vs Python全部内容,希望文章能够帮你解决Java vs Python所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。