Sunday 19 April 2015

Every Programmer should know these terms.

Being a programmer, we tend to learn new programming languages or better to say play with them to make sure there is a piece of code that distinguishes you from your peers. Or sometimes to boast about the language's capability and more often simply criticize the existing ones.There are more than 256 to choose amongst.
But when you are asked about few questions on them and ,if you go for a freeze, then let me bail you out :)

Difference between static and dynamic typed Programming language?

Statically typed languages enforce the type of the variable to be declared forehand. 

int var = 10; //object here is an integer
String var ="text" //it wont compile because a is already defined

Dynamically typed languages don't enforce the type of variable to be declared at all.

var ="Text" //var will be parsed as a string
var=12  // var will be considered as integer

The advantage of statically typed languages over Dynamic languages is it makes code type safe.
The code below gives ambiguity between 42 and 537
  1. var x := 5;     
    
  2. var y := "37";  
    
  3. var z := x + y;

Statically Typed languages :Java,C#..more
Dynamically typed languages : Javascript,Ruby,Python..more.

No comments:

Post a Comment