Python vs Java: How programming has helped broaden my employment potential
- Ian Vicino
- Dec 4, 2023
- 5 min read
Updated: Aug 5, 2024
My search for work has been long and hard. Although I can vent and moan about my difficulties, I figure it would be more beneficial for my readers and myself to see the benefits that have come from my work search. Many benefits have come from my struggle to find work, some of which may not come to light until years have passed and I look back on this time from the future. The benefit I want to focus on for this blog post is the added value programming has given my resume. Because I learned Python and built many applications and machine learning algorithms demonstrating my ability to code, my knowledge base has been broadened. During my employment search, using the keyword ‘biotech’ to search Indeed and LinkedIn, I found a plethora of job postings that required programming experience. Again that was while searching for biological technology jobs which are not usually thought of as jobs that require such experience. That is not counting the programming positions I could now apply to. Learning how to code has opened up more potential employment opportunities for me than would have been possible if I merely knew how to culture cells, or perform a Western Blot.
That being said, knowing how to code in Python is great, but knowing how to code in other languages is even better. Which leads me to why I decided to master Java. I have learned the basics of many programming languages but figured I should master another language as well. As there are many jobs out there looking for a Java developer, I figured that would be the best place to start.
In pursuit of this goal, I decided to pick a project to code from scratch. I chose to code a pseudorandom number generator (PRNG) using the chaos theory as I did before using Python (https://www.codersjournal.com/post/want-to-learn-to-code). I will discuss some differences between Python and Java using the code I made as an example. Below you will find the Python version of the PRNG above the Java version.
Python Code:
# pseudorandom Number Generator using Chaos Theory
# Logistic Growth equation
# Xi+1 = RXi(1-Xi)
entry = int(input('How many random numbers do you want? '))
X = float(input('Write a decimal between 0 and 1 indicating the initial population percentage (maximum of 1) ')) # Xi is the percentage of rabbits, for instance, with a maximum of 1 or 100%
R = 3.7
def PRNG():
x = R*X*(1-X)
for num in range(entry):
x = R*x*(1-x)
print(x)
return x
prng = PRNG()
print('Your final number is: ', prng)
Java Code:
// This is my attempt at replicating my psueodrandom number generator I created in python with the java programming language
import java.util.Scanner;
public class Main {
public static void main(String[] args){
// creates an object of Scanner
Scanner input = new Scanner(System.in);
System.out.print("How many random numbers do you want? ");
// takes input from the keyboard,
// usually .nextLine() is used to print out the next line of text,
// but can be used to use the next line of text as input to the program!!!
Byte entry = input.nextByte();
// prints the name
System.out.println("You want " + entry + " random numbers");
System.out.print("Write a decimal between 0 and 1 indicating the initial population percentage (maximum of 1):\n ");
Float X = input.nextFloat();
System.out.println("You want an initial population of " + X );
float R = 3.7f;
float x = R*X*(1-X);
for (byte i = 0; i < entry; i++) {
x = R*x*(1-x);
System.out.println(x);
// closes the scanner
input.close();
}
}
}
The first difference you can see is the length of the code. The Python PRNG is significantly shorter than the Java PRNG. In addition the Java PRNG needs to import an external class, Python would call this a module, in order to take input from a user. Those are just the differences that are immediately seen.
Java is a static programming language, whereas Python is a dynamic programming language. With a dynamic language like Python, a variable can contain an integer, float, string, etc, and can change from containing an integer to a string with no problem. This is because the contents of the variable are checked in the background. This takes more time for the code to run which is one draw back to this type of programming language, but it is a lot easier to code.
Java on the other hand runs faster because it is a static programming language. A variable can contain only one data type that is defined when the variable is initialized. This is why this programming language is used to create games, like Minecraft and Stardew Valley, whereas Python is too slow to make many games. There are some games that can be made with Python but the majority of games are made with static programming languages because they are faster.
The problem with static programming languages like Java is that they are slower to code. The programmer must define the contents of a variable before it can be used. After it is defined its contents cannot change to another data type. Coming from a dynamic language like Python, it is annoying to need to initialize every variable I use.
Variables in Java (once defined, cannot change the data type):
byte age = 30;
int herAge = age;
long viewsCount = 123_456_789_045L;
float price = 10.99F;
char letter = 'A';
boolean isEligable = true;
Variables in Python (Freely manipulatable):
age = 30
herAge = age
viewsCount = 123_456_789_045
price = 10.99
letter = 'A'
isEligable = True
age = 'Thirty'
herAge = int(age) + 30
viewsCount = 123456789045/9
letter = 'A banana is yellow'
isEligable = False
There are many other differences between Python and Java, and you can inspect my code to find the differences if you are curious. (Hint: look at the for-loops and the data types) What I want to end with is some advice. My advice for my readers is to learn a programming language if you don’t already know how to code. Whether you are a biologist, entrepreneur, lawyer, or retail worker, really any profession, if you learn how to code it will open up more employment opportunities for you. If nothing else you will learn how to think logically which skill is highly needed in the world. As for which language to learn, my advice is Python as it is, in my opinion, the easiest language to learn.
If you already know how to code in one programming language I advise you to learn another programming language as well. Each language has pros and cons, and can be suitable to different tasks.
As for me, I will continue to perfect my knowledge of Python, and continue learning Java. I hope my effort will land me a good job and help grow my career. Keep learning and challenging your intellect.
Comments