From 438bc87f5c9932e4039d4142c952997e6871eff4 Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 10 Dec 2019 08:56:16 +0800 Subject: [PATCH] translated --- ...ava vs. Python- Which should you choose.md | 157 ------------------ ...ava vs. Python- Which should you choose.md | 156 +++++++++++++++++ 2 files changed, 156 insertions(+), 157 deletions(-) delete mode 100644 sources/talk/20191204 Java vs. Python- Which should you choose.md create mode 100644 translated/talk/20191204 Java vs. Python- Which should you choose.md diff --git a/sources/talk/20191204 Java vs. Python- Which should you choose.md b/sources/talk/20191204 Java vs. Python- Which should you choose.md deleted file mode 100644 index edc59c7b3d..0000000000 --- a/sources/talk/20191204 Java vs. Python- Which should you choose.md +++ /dev/null @@ -1,157 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Java vs. Python: Which should you choose?) -[#]: via: (https://opensource.com/article/19/12/java-vs-python) -[#]: author: (Archit Modi https://opensource.com/users/architmodi) - -Java vs. Python: Which should you choose? -====== -Compare the two most popular programming languages in the world, and let -us know which one you prefer in our poll. -![Developing code.][1] - -Let's compare the two most popular and powerful programming languages in the world: Java and Python! Both languages have huge community support and libraries to perform almost any programming task, although selecting a programming language usually depends on the developer's use case. After you compare and contrast, please make sure to answer our poll to [share your opinion][2] on which is best. - -### What is it? - - * **Java** is a general-purpose object-oriented programming language used mostly for developing a wide range of applications from mobile to web to enterprise apps. - * **Python** is a high-level object-oriented programming language used mostly for web development, artificial intelligence, machine learning, automation, and other data science applications. - - - -### Creator - - * **Java** was created by James Gosling (Sun Microsystems). - * **Python** was created by Guido van Rossum. - - - -### Open source status - - * **Java** is free and (mostly) open source except for corporate use. - * **Python** is free and open source for all use cases. - - - -### Platform dependencies - - * **Java** is platform-independent (although JVM isn't) per its WORA ("write once, run anywhere") philosophy. - * **Python** is platform-dependent. - - - -### Compiled or interpreted - - * **Java** is a compiled language. Java programs are translated to byte code at compile time and not runtime. - * **Python** is an interpreted language. Python programs are translated at runtime. - - - -### File creation - - * **Java**: After compilation, **<filename>.class** is generated. - * **Python**: During runtime, **<filename>.pyc** is created. - - - -### Errors types - - * **Java** has ****2 ****types of errors: compile and runtime errors. - * **Python** has 1 error type: traceback (or runtime) error. - - - -### Statically or dynamically typed - - * **Java** is statically typed. When initiating variables, their types need to be specified in the program because type checking is done at compile time. - * **Python** is dynamically typed. Variables don't need to have a type specified when initiated because type checking is done at runtime. - - - -### Syntax - - * **Java**: Every statement needs to end with a semicolon ( **;** ), and blocks of code are separated by curly braces ( **{}** ). - * **Python**: Blocks of code are separated by indentation (the user can choose how many white spaces to use, but it should be consistent throughout the block). - - - -### Number of classes - - * **Java**: Only one public top-level class can exist in a single file in Java. - * **Python**: Any number of classes can exist in a single file in Python. - - - -### More or less code? - - * **Java** generally involves writing more lines of code compared to Python. - * **Python** involves writing fewer lines of code compared to Java. - - - -### Multiple inheritance - - * **Java** does not support multiple inheritance (inheriting from two or more base classes) - * **Python** supports multiple inheritance although it is rarely implemented due to various issues like inheritance complexity, hierarchy, dependency issues, etc. - - - -### Multi-threading - - * **Java** multi-threading can support two or more concurrent threads running at the same time. - * **Python** uses a global interpreter lock (GIL), allowing only a single thread (CPU core) to run at a time. - - - -### Execution speed - - * **Java** is usually faster in execution time than Python. - * **Python** is usually slower in execution time than Java. - - - -### Hello world in Java - - -``` -public class Hello { -   public static void main([String][3][] args) { -      [System][4].out.println("Hello Opensource.com from Java!"); -   } -} -``` - -### Hello world in Python - - -``` -`print("Hello Opensource.com from Java!")` -``` - -### Run the programs - -![Java vs. Python][5] - -To run the java program "Hello.java" you need to compile it first which creates a "Hello.class" file. To run just the class name, use "java Hello." For Python, you would just run the file "python3 helloworld.py." - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/12/java-vs-python - -作者:[Archit Modi][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/architmodi -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_development_programming.png?itok=M_QDcgz5 (Developing code.) -[2]: tmp.Bpi8QYfp8j#poll -[3]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string -[4]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system -[5]: https://opensource.com/sites/default/files/uploads/python-java-hello-world_0.png (Java vs. Python) diff --git a/translated/talk/20191204 Java vs. Python- Which should you choose.md b/translated/talk/20191204 Java vs. Python- Which should you choose.md new file mode 100644 index 0000000000..3dbe4bb50e --- /dev/null +++ b/translated/talk/20191204 Java vs. Python- Which should you choose.md @@ -0,0 +1,156 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Java vs. Python: Which should you choose?) +[#]: via: (https://opensource.com/article/19/12/java-vs-python) +[#]: author: (Archit Modi https://opensource.com/users/architmodi) + +Java vs. Python:你应该选择哪个? +====== +比较世界上最流行的两种编程语言,并在投票中让我们知道你喜欢哪一个。 +![Developing code.][1] + +让我们比较一下世界上两种最受欢迎、最强大的编程语言:Java 和 Python!这两种语言有巨大的社区支持和库来执行几乎任何编程任务,尽管选择编程语言通常取决于开发人员的场景。在比较和对比之后,请投票[分享你的观点][2]。 + +### 是什么? + + * **Java** 是一门通用面向对象的编程语言,主要用于开发从移动端到 Web 到企业级应用的各种应用。 + * **Python** 是一门高级面向对象的编程语言,主要用于 Web 开发、人工智能、机器学习、自动化和其他数据科学应用。 + + + +### 创建者 + + * **Java** 是由 James Gosling(Sun Microsystems)创造的。 + * **Python** 是由 Guido van Rossum 创造的。 + + + +### 开源状态 + + * **Java** 是免费的,(大部分)开源,但商业用途除外。 + * **Python** 所有场景均免费。 + + + +### 平台依赖 + + * **Java** 根据它的 WORA (”一次编写,到处运行“)哲学,它是平台无关的。 + * **Python** 依赖于平台。 + + + +### 编译或解释 + + * **Java** 是一门编译语言。Java 程序在编译时转换为字节码,而不是运行时。 + * **Python** 是一门解释性语言。Python 程序在运行时进行解释。 + + + +### 文件创建 + + * **Java**:编译后生成 **<filename>.class** 文件。 + * **Python**:在运行期,创建 **<filename>.pyc** 文件 + + + +### 错误类型 + + * **Java** 有 2 种错误类型:编译和运行时错误。 + * **Python** 有 1 种错误类型:回溯(或运行时)错误。 + + + +### 静态或动态类型 + + * **Java** 是静态类型。当初始化变量时,需要在程序中指定变量的类型,因为类型检查是在编译时完成的。 + * **Python** 是动态类型。变量不需要在初始化时指定类型,因为类型检查是在运行时完成的。 + + + +### 语法 + + * **Java**:每个语句都需要以分号 (\*; ) 结尾,并且代码块由大括号 ( {} ) 分隔。 + * **Python**:代码块通过缩进分隔(用户可以选择要使用的空格数,但在整个块中应保持一致)。 + + + +### 类的数量 + + * **Java**:在 Java 中的单个文件中只能存在一个公有顶级类。 + * **Python**:Python 中的单个文件中可以存在任意数量的类。 + + + +### 代码更多或更少? + + * **Java** 通常比 Python 要写更多代码行。 + * **Python**通常比 Java 要写更少代码行。 + + + +### 多重继承 + + * **Java** 不支持多重继承(从两个或多个基类继承)。 + * **Python** 支持多重继承,但由于继承复杂性、层次结构、依赖等各种问题,它很少实现。 + + + +### 多线程 + + * **Java** 多线程可以支持同时运行的两个或多个并发线程。 + * **Python** 使用全局解释器锁 (GIL),一次只允许运行单个线程 ( CPU 核)。 + + + +### 执行速度 + + * **Java** 的执行时间通常比 Python 快。 + * **Python** 的执行时间通常比 Java 慢。 + + + +### Java 的 Hello world + + +``` +public class Hello { +   public static void main([String][3][] args) { +      [System][4].out.println("Hello Opensource.com from Java!"); +   } +} +``` + +### Python 的 Hello world + + +``` +`print("Hello Opensource.com from Java!")` +``` + +### 运行程序 + +![Java vs. Python][5] + +要运行 java 程序 ”Hello.java“,你需要先编译它,这将创建一个 ”Hello.class“ 文件。只需运行类名 ”java Hello“。对于 Python,只需运行文件 ”python3 helloworld.py“。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/java-vs-python + +作者:[Archit Modi][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/architmodi +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_development_programming.png?itok=M_QDcgz5 (Developing code.) +[2]: tmp.Bpi8QYfp8j#poll +[3]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string +[4]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system +[5]: https://opensource.com/sites/default/files/uploads/python-java-hello-world_0.png (Java vs. Python)