× Home

Introduction to programming

Programming is a way to instruct the computer to perform various task.
Computers only understands Binary i.e., 0's and 1's.
Instructing computer in Binary is very difficult for humans so, to solve this issue we have programming languages.

Programming language:- It is a computer language used by programmers to communicate with computer.

Types of Programming languages

Proceduaral

  • Specifies a series of well-structured steps and procedures to compose a program.
  • Contains a systematic order of statements functions and commands to complete a task.

Functional

  • Writing a program only in pure functions i.e., never modify variables but only create new ones as an output.
  • Used in a situation where we have to perform lots of different operations on the same set data like ML.

Object oriented

  • Revolves around objects
  • Code + data = objects
  • Developed to make it easier to develop, debug, reuse and maintain software.

Note : - "One programming language can be of all 3 types like - Python".
Java follows procedural and object oriented both types.

Static VS Dynamic Languages

Static

Dynamic

Perform type checking at compile time

Perform type checking at runtime

Errors will show at compile time

Errors might not show till programs run

Declare datatypes before use

No need to declare datatype of variables

More control

Saves time in writing code but might give error at runtime.

Memory Management

There are 2 types of memory Stack and Heap.
When we declare a variable then the reference variable stored in stack memroy points to the object of that variable stored in heap memory.
For ex:- a = 10
Here "a" is called reference variable, and "10" is the object of that reference variable

Points to remember
Now supporse,
a=10
b=a

→ More than one reference variable can point towards one object.
→If any of the reference variable changes the object then it is changed for all reference variable that points towards same object.
→If there is an object without reference variable then object will be destroyed by "Garbage Collection".