Programming Syntax

. Syntax refers to the spelling and grammar of a programming language, Syntax is varies from one language to another but purpose of the programming concepts is almost same.

Example:
Variable for storing or holding the data
int a=100; //Java

a=100 #Python

Dim x
x=100 'VBScript

Note: Purpose of Programming fundamentals like Data Types, Variables, Operators, Control Flow, Strings, Arrays etc, is almost same in every programming language, but Syntax is varies from one language to another.

. We use Keywords, Identifiers, Special characters etc, to write computer programs

File obj = new obj(); //Creating Object in Java

MsgBox "Hello VBScript" 'Display output/message on the Console

print ('Hello Python') # Print a message in Python

. The actual content of the program is called code. That is why programming is often referred to as coding or writing code.

. A programming language has its own syntax, which consists of the set of rules that dictate how words and symbols can be put together to form a program.

. Statements are the basic unit of code. A statement can assign a value to a variable, perform a single action, control the execution of other statements and do any number of other things.

In Java:
int num=100;
int result=100*7+100;
System.out.println("Hello World");

In Python:
a=100
b=200
c=a+b
print (a+b)
print ('Hello Python World')

In VBScript
Dim a, b
a=100
b=200
MsgBox a+b
MsgBox "Hello VBScript"

Programming Basic Syntax

1. Programming file extensions

a. Java program file extension is ".java"
b. Python program file extension is ".py"
c. VBScript file extension is ".vbs"

2. Case Sensitiveness

a. Java is Case sensitive language
b. Python is Case sensitive language
c. VBScript is not Case sensitive language

3. Writing Comments

a. We use // for single comment, and /*.........*/ for multi line comments in Java
b. We use #for single comment, and '''...........''' for multi line comments in Python
c. We use ' for single comment, and VBScript doesn't support multi line / block comment, and You can comment out each line individually.

4. Writing Statements

a. Every Java Statement / Step should end with ;
b. No formalities to write Python Statement
c. No formalities to write VBScript Statement

5. Declaration of Variables

a. Java supports Explicit Declaration of Variables
b. Python supports Implicit declaration of variables
c. VBScript supports Implicit declaration of variables

6. Writing Code Blocks

a. Java code blocks like conditions, loops, methods etc, are enclosed with {}

b. Python code blocks use code indentation

Ex:
a, b = 100, 500;

if (a b):
print ("A is Big Number")
else:
print ("B is Big Number")

for num in range(1, 6):
print(num)

c. VBScript code blocks use start and end keywords,

Ex:
Dim a, b
a=100
b=200

If (a b) Then
MsgBox "A is Big Number"
else
MsgBox "B is Big Number"
End If

For i = 1 To 5 Step 1
Msgbox i
Next

7. Functions and Methods

Some Programming features vary from one language to another

We use methods in Object Oriented Programming like Java for code reliability
We use Functions in C Languages for code reliability
Python supports both methods and functions