Basic computer course, C programming language, Education, Engineering Course, Engineering Courses, Maths Coaching, online computer coaching, PGDCA course coaching, programming course, school computer coaching, training, Uncategorized, Web Design course

Static and Dynamic Typing-tccicomputercoaching.com

Data Types are always important in any programming Language.

Let us understand through an example:

If we write direct a=10;

There will be an error.

Because user has to inform compiler about data type of data before use them in code.

All most all Languages have this feature. Some are exceptional which don’t require to declare data type before use.

Static” and “dynamic” are the types of “typing” that we shall see in the sections that follow. Languages that have static typing or dynamic typing are said to be “static typed” or “dynamic typed”.

What is static typing? And what’s dynamic typing?

Static Typing

Static typed programming languages are those in which variables need not be defined before they’re used. This implies that static typing has to do with the explicit declaration (or initialization) of variables before they’re employed. Java is an example of a static typed language; C and C++ are also static typed languages. Note that in C (and C++ also), variables can be cast into other  types, but they don’t get converted; you just read them assuming they are another type.

Static typing does not imply that you have to declare all the variables first, before you use them;

/* C code */

static int num, sum; // explicit declaration

num = 5; // now use the variables

sum = 10;

sum = sum + num;

Dynamic Typing

Dynamic typed programming languages are those languages in which variables must necessarily be defined before they are used. This implies that dynamic  typed languages do not require the explicit declaration of the variables before they’re used. Python is an  example of a dynamic typed programming language, and so is PHP. Consider the following example:

/* Python code*/

num = 10 // directly using the variable

A lot of people define static typing and dynamic typing with respect to the point at which the variable types are checked. Using this analogy, static  typed languages are those in which type checking is done at compile-time, whereas dynamic typed languages are those in which type checking is done at run-time.

To learn more about Type- Checking

Connect with us @ TCCI Computer Coaching in Bopal-Satellite,Ahmedabad

Call us 98256 18292.

Visit us @ http://tccicomputercoaching.com/

 

Leave a comment