Say "Hello World" in Some Languages

Welcome to my "re-first" post. Why "re-first" ?. Why not just "first". Well..., to understand it You must read my Welcome-Notice post First.

OK..., don't waste any time again. In this post I'm going to talk about "Hello World". What is "Hello World"?. Refer to Wikipedia,
A "Hello, World!" program is a computer program that outputs or displays "Hello, World!" to the user. Being a very simple program in most programming languages, it is often used to illustrate the basic syntax of a programming language for a working program. It is often the very first program people write when they are new to the language.
From description, I will make it simple. "Hello World" is a very simple program written by a people when they are new in a language. Now the problem is, which language?. We know there are so many programming languages. From low-level to high-level. Each language, has its own characteristic. Because it so many.., then I'm going to these languages: C, Python, and jAVA

Let's Start.

BEFORE WE START
Before we start, make sure our computer is ready for some languages I mention above. This mean, Your computer ready to compile and execute. I wouldn't explain one by one how to prepare it, so do it by Your self. For Your Information, when I write this post, I use Linux Ubuntu 16.04 LTS as my Operating System, GCC 5.4, Python 2.7, Python 3.5, and openJDK 1.8.0_121. I use Kate as my Text Editor,

WRITING HELLO WORLD IN C
First, open Your text editor and type these code.









Then, save it with name: HelloWorld.c or whatever You like.
Then compile it. Because I use linux, there are three ways to compile this c file.

  1. cc program-source-code -o executable-file-name
  2. gcc program-source-code -o executable-file-name
  3. make program-source-code -o executable-file-name

For Example, I use gcc to compile my source code. Then I do (see screenshot):

gcc HelloWorld.c -o HelloWorld



From compiling process, we get an executable file that ready to executed. Final step, execute!. To execute I do (see screenshot):

./HelloWorld



How do You feel? You just create Your first program written in c!. Feeling excited?, wonderful? or what?. Do you want to continue to the next language? If You want to continue,  let's continue our journey. We are going to learn how to write a Hello World program in Python.

WRITING HELLO WORLD IN PYTHON
Writing Hello World program in Python isn't so complicated. But, You must make sure are you running python 2 or python 3 on Your computer. Because syntax in python 2 is quite different with syntax in python 3. 

In Python 2
To create a python 2 Hello World program, open Your text editor and type these code:
After that, save it with name: HelloWorld.py or whatever you like.

In Python 3
To create a python 3 Hello World program, open Your text editor and type these code:
After that, save it with name: HelloWorld3.py or whatever you like.

Run HelloWorld.py (python2) - See screenshot
To run a python2 .py file, I do:

python2 HelloWorld.py




Run HelloWorld3.py (python3) - See screenshot
To run python3 .py file, I do:

python3 HelloWorld3.py


See the difference? That's what I'm talking about. For a simple syntax like print, there is a difference between python 2 and python 3. But don't worry, in the future I will write more about python. Let's continue the journey. Now we will create a Hello World program in most popular language, jAVA.


WRITING HELLO WORLD IN JAVA
Creating a Hello World program in jAVA is very easy. Even You use Linux, Windows, or Mac, there is no different syntax and compiler command. To be able run java program in Your computer, minimal You must have installed JRE (Java Runtime Environment). But, if you want to compile java source code, You must have JDK (Java Development Kit) installed on Your computer. Once You install JDK on Your computer, You don't need JRE anymore. 
To install JRE or JDK, You can visit Java Oracle download page here.

After everything is ready, then let's begin. Write these code on Your favorite text editor and save it to HelloWorld.java (File name must be exactly same with Class Name!)
After You save it, then open your CLI Application (Command Prompt or Terminal). Go to where You save your java source-code through CLI. We are going to compile it. After you found it, to compile, type this command. 

javac HelloWorld.java


To run your java class, type this command:

java HelloWorld

Is it so simple right? from three languages we talk, which one on Your opinion to be the simplest language? it is up to You. The most important is, here, we just talk three languages from so many languages. So, if you think learn these three languages are enough, You are wrong. Sometimes You must learn a new language just for solve your problem. Let's learn more, and welcome to mil-notes....!


~ FIN ~


Comments