What is Dynamic and Static Typing?

0 votes
54 views
asked Dec 29, 2013 in C++ by checker
HI all

What is Dynamic and Static Typing language?
commented Dec 31, 2013 by Jack
As in Ruby, Python, Smalltalk, Groovy… Extremely useful because we don’t always know beforehand what our objects are going to be at run-time. Dynamic typing in Objective-C is simple to use. For example, this declares a variable that can hold a reference to an object:
    id myObject;
Optional static typing
Still, Objective-C also has support for static typing. Best of both worlds.
This declares a variable that can hold a reference to an object of class (or subclass of) NSView:
    NSView *myObject;

1 Answer

0 votes
answered Dec 29, 2013 by admin (8,135 points)
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.
 
Dynamically-typed language
 
       meaning that you don't have to tell the compiler what type of object you're working with at compile time. Declaring a type for a varible is merely a promise which can be broken at runtime if the code leaves room for such a thing. You can declare your variables as type id, which is suitable for any Objective-C object.
...