Java vs
Python
B
|
een in programming
since my first semester. My first programming language ever learnt is Java.
Well, actually before this I’ve been on Visual Basic when I was studying SPM
ICT. But that time I had totally no idea on what I had learnt therefore I don’t
consider that to be my first programming language ever learnt in my life (All
the Visual Basic assignment were just copied and pasted at that time). After
that, my life on programming became more challenging with the concepts of
object-oriented programming and the application of data structure theory into
programming. Then I learnt PHP, HTML, CSS, Javascript, a bit of C and C++. Now
this semester I learn another two language which are UNIX shell scripting and
Python. Err… I’m not quite sure whether the UNIX shell scripting can be
considered as a programming language or not. Whatever! Now come back to the
topic. Today’s topic is Java vs Python. The programming language that I have
learnt since my first semester vs the programming language that I had just
started learning (Not quite sure why Mr Azrul taught us Python and how is
Python related to parallel computing). These are my perceptions and feelings
towards these 2 fellows. Now let’s start this comparison with some aspects!
1.
First impression
Everything
needs to have something to give others a good first impression. So as programming
languages. These 2 languages are performing well in their display of their
first impression towards me. I like these 2 languages.
The first
time when I started learning Java, I remembered that I have to download quite a
number of utilities in order to get Java to work. The most important thing is:
These utilities are quite huge, with sizes of almost 100MB each. Nowadays Java SDKs
are quite large compared to past days. Netbeans itself is quite huge also with
size of almost 100MB. Because my house’s internet is not that fast so I really
think that 100MB is quite huge to be downloaded. And of course my friends are
not happy as the line will get slow and their games will be laggy and the ping
increases.
On the
other hand, python only requires 20MB of my disk space, which I think is quite
convenient to get Python run on my pc compared to Java. Python comes with
Python shell, which looks like UNIX shell for me. This semester I learn bash
shell programming in UNIX as well. Users can enter commands in Python shell,
similarly to command prompt in Windows environment. Therefore, in my opinion,
Python owns Java in first impression.
2.
Hello World
My Hello
World experiences on these 2 languages are different. On Java, I have to open a
class (At that time I don’t even know what is a class) and set it to public
then give the class a name. Then inside
the class, I have to open a main method. Then I can successfully print Hello
World.
public
class Hello_world {
public static void main (String []args) {
System.out.println (“Hello World”);
}
}
It was
like: Wow! I can’t understand this! I begin to understand these sophisticated
elements after I had learned object-oriented programming 1 year after my Hello
World.
Meanwhile,
my Hello World program in Python is way more simple than in Java. It takes me
to write only 3 words to get the program works, which is Print (“Hello
World”).
That’s all! Simple is it? Therefore, Python owns Java in simplicity and
convenience in coding and easy-learning.
3.
Simplicity
Simplicity
is one of the important aspects that decides how the programming language ease
programmers the most. I should take an example to make a clearer comparison.
For example, reading for user input. In Java, I have to import the Scanner
feature in order to make this happens:
import
java.util.Scanner;
public
class Hello_world {
public static void main (String []args) {
Scanner input = new Scanner (System.in);
System.out.print (“Enter your name”)
String name = input.next();
System.out.println (“Hello World” + name);
}
}
But
in Python, it only requires two lines:
x
= input (“Please insert your name”)
print
(x)
Simple
is it? Therefore, Python owns Java again in this.
4.
Flexibility
This is
what Java wins over Python. Flexibility is an aspect where the code can be run
even the code is in the wrong indentation or the codes are separated with
unwanted blank spaces.
Java’s
syntax for while loop enables the coding to be run without considering its
indentation, as long as the coding that supposed to be run within the loop is
within the curly brackets.
import
java.util.Scanner;
public
class Hello_world {
public static void main (String []args) {
while (true) {
System.out.println
(“Infinite loop!!!!!”)
}
}
}
But in
Python, the indentation is important. Wrong indentation indicates different
meaning:
while
1:
print (“Infinite loop”)
print (“Infinite loop also”)
print
(“Outside of loop”)
The
indentation is important. Else, you won’t get the coding to work properly.
Therefore, Java owns Python for flexibility
5.
Execution time
I used
Netbeans all the while to do my Java projects. I touched a bit Eclipse also to
study on Android programming myself. I noticed that Java is actually slow in
execution time. It needs a long time loading before it can actually run. On the
other hand, Python runs much faster than Java on this. I dunno is this related
to simplicity of the syntax since Python’s syntax is simpler than Java.
Therefore, again, Python owns Java in execution time.
6.
Real-time error detection
Most of
the Java IDE such as Netbeans and Eclipse comes with real-time error detection
where like Microsoft Office, a red line is displayed at the bottom of each
wrong syntax or coding. This is quite convenient especially for long and
complex coding where programmers can know where they have done wrong in short
time.
Python, so
far, do not have this kind of feature. Programmers can only know the error
after they have run the code. It is not so convenient compared to real-time
detection in Java.
These are my perceptions towards these
2 programming languages. It doesn’t mean to be 100% correct as different people
see things differently. The 2-4 score of Java vs Python doesn’t mean that
Python is exactly better than Java as these 2 programming languages have their
own advantages and disadvantages. The aspects discussed above are just a part
of them. Therefore, everyone is free to choose what language he or she is going
to use. That’s all for my article on comparison. Thank you!
No comments:
Post a Comment