What is JavaScript?JavaScript is an object oriented programming language that was created specifically for the web. JavaScript adds functionality and interactivity to websites by allowing your plain old HTML pages to actually have their own programming language embedded inside of them.

You see, HTML isn't really a programming language, it's what's known as a “markup” language, which is really just used to describe how to present text in your browsers.

So what JavaScript brings to the table are all of the common programming elements to your HTML pages.

This means you'll be able to use fun things like control structures, data structures, data validation, even an in-browser database if you feel the need to get fancy!

JavaScript brings websites to life and makes them more than just a glorified electronic newspaper.

Java is NOT JavaScript

Although they share the same root word, these two programming languages are quite different in the way they work under the hood.

Sure a gas powered car and an electric car are both cars… but they use very different means of propulsion. Same concept applied with Java and JavaScript. They're both programming languages, but they live in very different worlds.

Where Can I Download JavaScript?

A common thought that Java programmers have when learning JavaScript is “Where do I download the JavaScript programming language so I can start using it?”

Well the beauty is that you don't need to download it, JavaScript already exists inside of any internet browser you use. Just goes to show you how tightly coupled HTML and JavaScript are ;)

So that brings me to my first real talking point about JavaScript.

Because JavaScript exists inside of the browser, this means that it's a client-side programming language.

JavaScript is Client-Side, Java is Server-Side

We call JavaScript “client-side” because all the code that you write will actually exist inside your users' browsers and that code will be executed by the JavaScript language that ALSO exists on your users' browsers.

Compare and contrast this “client-side” idea to the Java language. Java is a “server-side” language. This is the case because when one of your users interacts with a web application that's powered by Java, the user won't ever see your Java code. The Java code exists on YOUR web server (either in your house or in some hosting companies data-center), never on the users' computers.

This client-side vs server-side distinction is just the start of many important differences between the two programming languages.

So, When Should I use JavaScript?

Alright, so one language exists in the browser, and on exists on a server… so… in what situation should I use JavaScript and in what situation should I use Java?

This is a great question!

The answer will depend on the project you're working on. You see, Java is typically chosen as the “go-to” programming language when you want to build “enterprise” level applications. What this means is that if you're wanting to build an application that will be used for business purposes and will be a fairly large application with hundreds or thousands (or millions) of users, then Java is probably your language of choice.

If you're building a smaller application, like a single player game that won't require concurrent users, or if you're building a simple application to handle the processing of forms, then JavaScript might be your go to language. Or perhaps you wish to build an “offline” web application, one that can be used with or without an internet connection, then JavaScript with HTML5 is a great option!

The big thing to point out here is that this isn't a “one or the other” type of scenario. When I build my web applications, I use BOTH Java and JavaScript.

I typically use JavaScript to be my “front-line” or “presentation layer” support for validating any forms, interacting with the users and dynamically changing the elements on an HTML page. Then I'll use the Java language on the back end in the “business layer” of the application to process the data that was validated and sent from the “presentation layer” (or HTML + JavaScript layer).

So Java and JavaScript actually play quite well with each other.

How else are Java and JavaScript Different

Well one big difference you'll notice between the two languages is how JavaScript's variables work.

You see, JavaScript uses something called Dynamic Typing. This is a topic that we'll cover in the next article. But the quick version is that you don't need to assign a “type” to your variables like you do with Java. Java uses something called Static Typing, which requires you to declare what types your variables will be (i.e. String, Integer, Double, etc).

JavaScript uses a sort of “guessing system” to choose a data type on your behalf so you don't need to. But like I said, we'll talk more about that in the next post.

In Summary

JavaScript is here to stay and it's an extremely useful language to learn and use. I'm actually predicting that JavaScript will knock Java off of it's #1 spot as the most popular programming language in the coming years.

JavaScript is embedded right into your browser and it was designed to easily interact with HTML elements, so it's the perfect language to use when you want to “spice up” your boring HTML web pages with dynamic programming.

Free Java Roadmap

Discover exactly what you need to learn and where to start in order to become a professional coder.