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 ...
随机推荐
- 从有限状态机的角度去理解Knuth-Morris-Pratt Algorithm(又叫KMP算法)
转载请加上:http://www.cnblogs.com/courtier/p/4273193.html 在开始讲这个文章前的唠叨话: 1:首先,在阅读此篇文章之前,你至少要了解过,什么是有限状态机, ...
- testng xml 示例
TestNG的DTD检查文件:http://testng.org/testng-1.0.dtd.php 更多testng配置及说明,请移步http://testdoc.org/docmaster?pi ...
- HTML5新增的一些属性和功能之一
大致可以分为10个方面: HTML5表单元素和属性 表单2.0 视音频处理 canvas绘图 SVG绘图 地理定位 拖放技术 web work web storage web socket 一.新的i ...
- php中对MYSQL操作之批量运行,与获取批量结果
<?php //批量运行,与获取结果 //创建一个mysqli对象 $mysqli = new MySQLi("主机名","mysqlusername". ...
- Hash表题目整数hash-HDOJ1425(转载)
哈希表(散列表)的基本原理:使用一个下标范围比较大的数组来存储元素,一般通过设计一个函数(哈希函数,即散列函数),使得每个元素的关键字都与一个函数值(即数组下标)相对应,然后用该数组单元来存储对应 ...
- 解决 Google 重定向,体验 Google 本味
想要体验原汁原味的 Google(google.com),下面的方案是我用过的较方便的方案. 欢迎更正及补充 Chrome 扩展 Chrone 商店有一款禁止重定向的扩展 NoCountryRedir ...
- JavaScript 字符串函数 之查找字符方法(一)
1.JavaScript查找字符方法 首先看一张 有关字符串函数的查找字符的方法图 接下里补充里面的方法说明 2.charAt() charAt() 方法返回字符串中指定位置的字符 语法 ...
- edmx文件
MethodBase 提供有关方法的信息 在System.Reflector命名空间之下 edmx edmx:Runtime节点下包含与EF有关的定义与映射信息 edmx:ConceptualMode ...
- Silverlight Visifire控件 后台设置颜色
ColorSet cs = new ColorSet(); cs.Id = "colorset1"; // 设置ColorSet 的 Id 为 colorset1 1.cs.Bru ...
- 8 fastJson的使用
Fastjson介绍 Fastjson是一个Java语言编写的JSON处理器,由阿里巴巴公司开发. 1.遵循http://json.org标准,为其官方网站收录的参考实现之一. 2.功能qiang打, ...