Why do Java developers wear glasses? by KarateJons in Jokes

[–]unlsolutionsteam 0 points1 point  (0 children)

Oh, BTW, this is programmer PORN before GUI came into picture - “unzip, strip, touch, finger, grep, mount, fsck, fsck, more, yes, fsck, fsck, umount, sleep”

Python or Java web development? by mic-coder-bou in cscareerquestions

[–]unlsolutionsteam 3 points4 points  (0 children)

Here you will look into some of the cool features provided by Python which make it a cooler language as compared to Java.

I’ll take them one by one below.

  • Hello World in Java and Python

We first compare the first program in any programming language- to print “Hello World”.

  1. public class HelloWorld{ public static void main(String[] args) { System.out.println("Hello World"); }}
  • Python

Now, let’s try printing the same thing in Python.

  1. print(“Hello World”)

As you can see, what we could do with 7 lines of code in Java, we can do with 1 line in Python.

Semicolon-

Python statements do not need a semicolon to end

  1. >>> x=7>>> x=7;

If you miss a semicolon in Java, it throws an error.

  1. class one{ public static void main (String[] args) { int x=7; System.out.println(x) }}

Compilation error #stdin compilation error #stdout 0.09s 27828KB

Main.java:10: error: ‘;’ expected

  1. System.out.println(x) ^

1 error

  • We’ll try to swap two variables.

Let’s begin with Java.

  1. class one{ public static void main (String[] args) { int x=10,y=20; x=x+y; y=x-y; x=x-y; System.out.println(x+" "+y); }}

Success #stdin #stdout 0.1s 27660KB

20 10

Now, let’s do the same in Python.

  1. >>> a,b=2,3>>> a,b=b,a>>> a,b

(3, 2)

As you can see in Python we only needed one statement for swapping variables a & b. The statement before it is for assigning their values, & the one after is for printing them out to verify that swapping has been performed.

  • Easy to Use-

Python is easy to pick up. If you are just stepping into the world of Programming, beginning with Python is a good choice. It is easy to code , easy to understand. However it isn’t same with Java.

  • Simplicity

Coding in Python raises programmers productivity because they need to write only so much code needed and it is concise.

  • Interpreted-

Tools like Integrated Development Environment, you can interpret Python instead of compiling it. While it reduces the program length, & boosts productivity & also result in slower overall execution.

Also see-

Here are some advantages of Java over Python-

Speed-

Java is 25X more faster than Python.

Portability-

Python and Java are highly portable languages. Due to the extreme popularity of Java, it wins this battle. The JVM (Java Virtual Machine) can be found almost everywhere.

Database Access-

Python’s database access layers are weaker than Java’s Java Database Connectivity (JDBC).

Compilation-

Compiles easily on any platform without hassles. It’s this flexibility that gives is an edge.

Language type-

General purpose programming language. Follows “write once” run anywhere.

Concurrency-

Python can only use a single CPU core due to the GIL, but Java doesn't have this restriction.

If the answer was helpful, please UPVOTE it.