+ 7

What is statically typed program?

23rd Jun 2018, 5:38 PM
Navoneel
4 Answers
+ 5
A statically typed program (for example C Language) will have variable name which will be bound to a type and to a object in compile time.Once the variable is bound to a type it is followed by assignment operator to bound the object.Consider the below example, int p=7; int x; here variable p is of int type and the object 7 of int return type during compile time.Now for variable x the object is 0 at compile time. if and only if two functions are of same type then each objects of both the functions are members to each other and has a dual image.In statically type program a variable of same type can only be manipulated and compared.If any two variables are different then they are type-casted.Example, char c='g'; int d= (int)c; So variable c of character type is type-cast to integer type for variable d in compile time.So the object of var d is the object value of var c of type int instead of char. So a statically typed program will lack type inferencing and needs to declare the type of variable explicitly.
23rd Jun 2018, 10:45 PM
D-Key
D-Key - avatar
+ 6
💐Thanks D-key💐
24th Jun 2018, 6:08 PM
Navoneel
+ 4
As shown above.So the statically program will be more closer to the hardware control flow or low level language. Therefore these programs will be more hardware performance efficient but their compile time and execution time will be out of phase to each other for some tasks.So compiler tends to do more optimization to a machine efficient code.And execution phase would be of less time.
23rd Jun 2018, 11:03 PM
D-Key
D-Key - avatar
+ 3
Orion Pax while(1) you are welcome😊
24th Jun 2018, 6:14 PM
D-Key
D-Key - avatar