Basics - For A Programming Language.

Basics - For A Programming Language.

Before we step up into learning a programming language.. Let's check what is in it and what includes in it.!

Types of Languages :

Procedural

It's a series of well-structured steps and procedures to complete a program.
Also, a systematic order of statements, functions and commands to complete a task.

Functional

It is a program or a pure functions i.e., never modify variables (reuse) used in situations where we've to perform multiple different operations on the same set of data.

- First class functions (Reassigning as a form of variables)
  This defines that, you can create an 'instance' for a function, so as to have a variable reference the function, just like a reference to a String, Map or any other object. 

Functions can also be passed as parameters to other functions.
But, in Java - methods are not first class objects.

Object-Oriented

- Here, everything is revolved around objects.
- Code + Data = Object
- Mainly introduced to make it easier to develop, debug, reuse and maintain software.
- Instance of class (template) is object.

Static vs Dynamic languages :

Static

- Performs 'Type checking' at Compile(Conversion of human understandable code to computer language) time.
- If any errors, these will be shown at compile time.
- Always user has to declare the respective datatype before using it.
- Additionally, user has more control on it.

Dynamic

- Perform 'Type checking' at Run(During the execution of code after compilation) time.
- Errors aren't shown until program is executed.
- No need to declare datatype of variables
- Saves time in writing code but errors are shown at runtime.

Stack and Heap Memory :

- Reference Variables are stored in Stack memory
- The respective Object (Value of variable) are in Heap Memory.

Stack -----> Heap (S is pointed to H)

- All the primitive datatypes are stored in STACK memory ONLY.
- Rest of the datatypes like Arrays, objects, hash maps etc are stored in HEAP memory.

** More than One ref. variables can be pointed to one Object.
** If any one of the ref variables are changed; the change is visible to the rest of variables.

Garbage Collection

- The main aim here is, object with no ref. is removed from the memory.