Java vs Python
面试时常问到这两种语言的区别,在此总结一下。
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.
Java vs Python的更多相关文章
- Java集合-Python数据结构比较
Java list与Python list相比较 Java List:有序的,可重复的.(有序指的是集合中对象的顺序与添加顺序相同) Python list(列表)是有序的,可变的. Java Lis ...
- windows、ubuntu下eclipse搭建java、Python环境问题总结
前两篇博文分别讲述了如何在windows.ubuntu下用eclipse搭建java.python环境,下面就针对本人遇到的问题做一个总结. 一.windows下关于java环境变量JAVA_HOME ...
- ubuntu上用eclipse搭建java、python开发环境
上一篇文章讲到如何在windwos上用eclipse搭建java.python开发环境,这一讲将关注如何在ubuntu上实现搭建,本人使用虚拟机安装的ubuntu系统,系统版本为:14.04 lts ...
- windows 下用eclipse搭建java、python开发环境
本人只针对小白!本文只针对小白!本文只针对小白! 最近闲来无事,加上之前虽没有做过eclipse上java.python的开发工作,但一直想尝试一下.于是边查找资料边试验,花了一天时间在自己的机器上用 ...
- paip.元数据驱动的转换-读取文件行到个list理念 uapi java php python总结
paip.元数据驱动的转换-读取文件行到个list理念 uapi java php python总结 #两个思路 1.思路如下:使用file_get_contents()获取txt文件的内容,然后通过 ...
- paip.提升安全性----Des加密 java php python的实现总结
paip.提升安全性----Des加密 java php python的实现总结 /////////// uapi private static String decryptBy ...
- paip.抓取网页内容--java php python
paip.抓取网页内容--java php python.txt 作者Attilax 艾龙, EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:http://blog ...
- paip.函数方法回调机制跟java php python c++的实现
paip.函数方法回调机制跟java php python c++的实现 作者Attilax 艾龙, EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:http:// ...
- paip. uapi 过滤器的java php python 实现aop filter
paip. uapi 过滤器的java php python 实现aop filter filter 是面向切面编程AOP.. 作者Attilax 艾龙, EMAIL:1466519819@qq. ...
- paip. 调试技术打印堆栈 uapi print stack java php python 总结.
paip. 调试技术打印堆栈 uapi print stack java php python 总结. 作者Attilax 艾龙, EMAIL:1466519819@qq.com 来源:attil ...
随机推荐
- Java中的ThreadLocal深入理解
提到ThreadLocal,有些Android或者Java程序员可能有所陌生,可能会提出种种问题,它是做什么的,是不是和线程有关,怎么使用呢?等等问题,本文将总结一下我对ThreadLocal的理解和 ...
- 为什么Nginx的性能要比Apache高很多?
为什么Nginx的性能要比Apache高很多? 这得益于Nginx使用了最新的epoll(Linux 2.6内核)和kqueue(freebsd)网络I/O模型,而Apache则使用的是传统的sele ...
- Shiro学习详解
1.Shiro基本架构 一.什么是Shiro Apache Shiro是一个强大易用的Java安全框架,提供了认证.授权.加密和会话管理等功能: 认证 - 用户身份识别,常被称为用户“登录”: 授权 ...
- git hub 资料汇总
tobecrazy Selenium automation test framework https://github.com/tobecrazy/Demo Smartphone Test F ...
- Open Session In View
Open Session In View模式的主要思想是:在用户的每一次请求过程始终保持一个Session对象打开着 实现步骤: 步骤一.创建一个Web项目,创建包cn.happy.util,创建Hi ...
- App上线流程全攻略(续)-iOS8之后的改动与所遇日常错误
随着iOS8的公布,iTunes Connect的界面也是发生了非常大的改变,App 上传到 Store上面的步骤也是发生了些改变.以下继续用图说话: /*********************** ...
- [ES6] Generators
Example 1: function *topicList(){ yield "ES2015"; yield "Semi-colons: good or bad?&qu ...
- Unity 触屏缩放模型
现在的手机都是触屏控制的,那么在游戏中我们想通过手指在屏幕上滑动捕获相应的动作呢?Unity官网API中提供了Input类和Touch类,在该类里提供了许多接口.相信只要我们稍微看下,就可以自己应用了 ...
- WebApi2官网学习记录---BSON
BSON 是轻量级的,能够进行快速查询和高效的解码/编码.BSON方便查询是由于elements的前面都有一个表示长度的字段,所以解释器可以快速跳过这个elements:高效的解码/编码是因为nume ...
- Proguard 保留native methods的问题
发现一个奇怪的问题,如果使用下面的配置来keep的话,native的方法还是被删掉了,百思不得其解. -keepclasseswithmembers class * { native *; } ...