From the translator: this article is an attempt by the author to show the advantages (not disadvantages) of the programming languages Python and Java, as well as to demonstrate the duality of any comparisons. Something that seems to be an advantage may be a disadvantage, and vice versa. Perhaps some moments may seem controversial, but this is for the better - in the comments you can discuss everything, correctly justifying their point of view. The article is suitable for both beginners and programmers with experience.Java and Python are equally popular programming languages. However, Python is more productive: it has less code needed to solve the problem. Why do programmers still work with Java where Python can be used? Let's figure it out.
We remind: for all readers of "Habr" - a discount of 10,000 rubles when recording for any Skillbox course on the promotional code "Habr".
')
Skillbox recommends: Online Profession Java Developer Educational Course.
Performance comparison
First, let's discuss why Python is more efficient and saves time when developing a web application.
Dynamically typedOne of the main reasons that Python is a more productive language is dynamic typing. This means that we do not need to declare anything — we simply give the variable a name and assign a value. Python independently determines its type according to the assigned value.
But Java is a statically typed language. All types of variables must be declared here. If you make a mistake, the program will not work or will, but with problems.
BrevityPython is a very laconic language: only a small number of words can be used in several lines. But Java is verbose, in it much is used without direct necessity. Let us give an example - the “Hello, World” program, written in both languages.
Java:public class HelloWorld{
public static void main (String[] args){
System.out.println("Hello, World!");
}
}
Python 2:print "Hello, world!"
, Python , . .
Java:int x = 5;
int y = 6;
int temp;
temp = x;
x = y;
y = temp;
Python 2:y, x = x, y
Boilerplate code, JavaPython Boilerplate code, Java, . Java, Boilerplate code - , ( ), .
, , Python. , . Java .
Java?
, Java , , Python.
, . , . , , Java , , , Python. , . . ( -, , Python) , .
, Java- , Python, , . Java- , , Python- -. , , .
, Java, Python , . JIT (Just-in-Time Compiler), . Java- , /++.
Python- Cython Jython /++ Java- Python. . Python Java.
. Java .
Python Java, Python , , ++ Fortran. , , Python, , , , C C/C++. , , Python. Java — Java.
Concurrency vs. ParallelismJava concurrency . , . Java , Python. - GIL (Global Interpreter Lock), Python , .
Python, Java . Java , . . , . , JVM: Scala, Kotlin, Clojure, Groovy .. , Java , Gradle Maven.
IT, , , , . , Python , . — , Java.
, Java Android, Kotlin. , Android, , Java. .
Python, Kiwi, .
Java JDBC (Java DataBase Connectivity). Java- , java.sql, Java SE. JDBC , URL.
Java Python — , . , , , , , , . . Java , , Python , .
Skillbox :