Java vs Javascript
Published: 2020-12-12 23:05:15

Today I am going to write about a couple languages that often get confused because of the obvious similarity in name. Java and JavaScript. Java is a language that was developed in the mid 90's by James Gosling while working with Sun Microsystems. On a slight side note, anyone around my age(29) or younger might not quite remember Sun. However, I always remember it because it was a main sponser of a youth soccer team I was on for a couple years, and I remember vividly someone telling me of Sun and how they were bought out by Oracle, the huge company that everyone knows today. Anyways, Java was developed to be simple, dynamic and perhaps most importantly, object oriented. The name Java was chosen because they wanted something cool and smooth to say, another top contender for the name was Silk. 

Javascript on the other hand was created by Brandon Eich while working at Netscape. At the time Netscape and Sun made a partnership and wanted a scripting language to accompany Java. They wanted a language that could be used both on client and server side. The crazy part from what I have read is that JavaScript was not originally taken very seriously. Many thought the "web" would not be a very serious platform for deployment. Imagine that. 25ish years later I am sure there are still plenty of programmers out there that were there during this. I wonder how much they chuckle when they think of that. 

I myself have been fascinated by programming ever since I heard of it. When I was much younger I tried to take some Java classes and did so-so. I never really got to sink my teeth into it though, because I was too busy chasing girls and playing video games, I didnt have time to do something pragmatic, gimme a break. Eventually I come to decide I really want to code and I went with JavaScript as my language to start with. So personally I love it.

Java and JavaScript *do* have some similarities. They are both object oriented. This of course, just means that they are structured around reusable objects. One of the cool differences though is that JavaScript can be used to make dynamic webpages that are very interactive with the user. What this entails is that there is no need for a virtual machine like java in order to complete certain tasks that javascript can do within the browser. 

Recently I have been trying to brush up on my Java so I have done some exercises and whatnot. A couple things I have noticed that were quite glaring were the variable declarations. They are very declarative, instead of writing something like 'let c = 9' (JS) in java you would write something like 'int c = 9'. In Java while declaring the variable we must also declare the type of variable. 

Another cool difference is that Java code needs to be compiled into bytecode and be ran by a Java Virtual Machine in order to run. This can make changes to Java code a bit more ardous than JavaScript which is often executed in the same syntax as written and therefore can be changed quickly if need be. Another big thing about Java is that it is class based. In order to write any Java code a class must be instantiated. In JavaScript the code is prototype based and inherits from built in classes. 

One thing to acknowledge as well is something I mentioned earlier about the bytecode compilation that Java works with. This can sometimes cause things to take a little longer but it is also arguably more secure. Because of JavaScripts connivence in being in a readable syntax, it makes it easier for people of malicious intent to mess with things. All in all I am having a lot of fun learning Java, but I still think Javascript is my heart.