Thursday 3 May 2018

Differences between PYTHON and JAVA.


Differences between PYTHON and JAVA. 

       In this blog, I am trying to list out the differences between Python and Java.
* Python and Java are two very different programming languages.

* Dynamic vs Static Typing

In python, you can declare a variable without type, python will infer the type of the variable based on the value assigned to it.
for eg:
x = 1   #here type of variable 'x' is number.
x = "hello" #here type of variable 'x' is string.
#in both case, we are not specifying the type of the variable.

Java forces you to define the type of a variable when you first declare it.A language is statically typed if the type of a variable is known at compile time.  - static typing.

* Braces vs Indentation

Python uses indentation to separate code into blocks.
Java uses curly braces to define the beginning and end of code blocks.

* Portability

  To run Python programs you need a compiler that can turn Python code into code that your particular operating system can understand. - source code to machine code.

  Java is platform independent, Java code is compiled into bytecode which can be executed by       JVM(platform dependent) of specific devices.

 * Verbosity and Simplicity
 
    Java syntax is verbose; Python syntax is clean and simple.

 * Semicolon

   Python statements do not need a semicolon to end.
   if you miss a semicolon in Java, it throws an error.

 * Comments

JAVA:
//This is a single-line comment
/*This is a multiline comment
Yes it is*/
PYTHON:
#This is a comment






No comments:

Post a Comment

Python and packages offline Installation in ubuntu machine.

https://www.linkedin.com/pulse/python-packages-offline-installation-ubuntu-machine-sijo-jose/