Java vs Javascript – Say Hello World!

Photo by Meruyert Gonullu on Pexels.com

One of the complaints about Java programming language is that it is verbose.

Imagine you are new to programming.

And you want to learn to program.

The first thing most of us traditionally do is to print “Hello World!” .

And to do this in Java you need to go through a lot of ordeal:

  • Download Java in your machine (if you want the latest version you need to download from open source version like OpenJDK and not from Oracle website)
  • Install Java in your machine
  • Download an IDE
  • Install the IDE
  • Create a new Java Project
  • Create a class
  • Create a method named “main”
  • Append public, static, void keywords to this method
    • Why do you want these keywords just to print “Hello World!” !! – Well the creators of Java didn’t bother much about printing “Hello World” , they were more interested in developing robust applications through the language . But as a downside it makes entry into the language more complicated
  • Then write System.out.println(“Hello World!”)
    • Why do we need System and out keywords here , why not just println()?

And finally you right click on the class and run it as a Java application.

And you see the output on the console!

So many steps just to print a sentence “Hello World!”

The entry level programmer may very well be discouraged doing all these steps.

There is a new Java proposal to make this process easier.

But until then you need to go through all these steps.

You can also use a notepad and type all the above and use “javac” command in the command prompt to compile the code and then “java” command to run the code.

Recently java removed the need to use javac command for compiling a single Java file. So you can run “java filename.java” directly now .

Some solace.

But overall the process is quite complicated.

Now come to javascript.

To say “Hello World”

Just open “Developer Console” in your browser and type console.log(“Hello World!”) and press enter.

The output appears on the same console!

Yipee you have written your first program !

Welcome to the world of Javascript!!


Posted

in

,

by

Tags:

Comments

Leave a Reply

Discover more from The Full Stack Developer

Subscribe now to keep reading and get access to the full archive.

Continue reading