answersLogoWhite

0

Strong-typing vs Weak-typing

Weak typing is where a language allows you to treat blocks of memory defined as one type as another (casting). Languages like C and C++, although statically typed, are weakly typed.

Languages like Perl and PHP are weakly typed because you can do things like adding numbers to strings and the language will do an implicit coercion for you.

Languages like Java, C# and Python are strongly typed - there is no way you can add a number to a string without doing an explicit conversion.

In addition, there are many large systems that have been created with dynamic type systems. Catching type errors (typos) at compile time only catches a very small proportion of errors and a strong testing strategy produces much more reliable systems irrespective of the type system in use.

Strong type is checking the types of variables at compile time. weak typing is checking the types of the system at run-time. For scripts & quick stuff we'll use weak typing, In big programs, strong typing can reduce errors at compile time

The above answer is not 100% correct. C++ doesn't allow for an integer (int) to be added to a string, unless you mean appending. In which case, C# and Java behave in similar fashion by doing an implicit conversion. For a better answer see the answer to "Strongly typed programming language" in this site.

Juan R

--------------------------------------------------------------------------------------------------------------

Strong typing provides greater type safety. You might have specially heard it about DataSets being strongly typed, where instead of referring columns as datacolumns(index).value, you create an XML schema from which you make a dataset derived class. Strong typing is preferred as there remains no type ambiguity. Another example is, turning on Option strict in VB, where you have to do explicit type casts.Instead of running into situation where you get a type that you did not expect and try performing an operation on it, you go for strong typing so that such errors are caught during compile time itself.

--------------------------------------------------------------------------------------------------------------

strong typelanguage specication requires its typing rules strongly (i.e. more or less allowing only those automatic type conversions which do not lose information),

one can refer to the process as strongly typed, if not, as weakly typed.

example in c language

int a;

float b, c;

b=2.2;

c=3.3;

a=b+c;// here we are losing data result is 5 instead of 5.5 because a is an integer

cout<

here ouptput 5.

if language do not allow to automatic type conversion then it should be strongly type otherwise it is weakly typed.

dynamic type:- if compiler know information about the type of variable or data at run time then it is called dynamic type.

static type:- if complier get information about type of variable or data at compile time then it is called static type.

User Avatar

Wiki User

9y ago

What else can I help you with?