top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is strong-typing versus weak-typing? Which is preferred? Why?

0 votes
429 views
What is strong-typing versus weak-typing? Which is preferred? Why?
posted Jun 19, 2017 by Amit Sharma
Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Strong typing: It checks the type of variables as soon as possible, usually at compile time. It prevents mixing operations between mismatched types.

A strong-typed programming language is one in which:

All variables (or data types) are known at compile time
There is strict enforcement of typing rules (a String can't be used where an Integer would be expected)
All exceptions to typing rules results in a compile time error

Weak Typing: While weak typing is delaying checking the types of the system as late as possible, usually to run-time. In this you can mix types without an explicit conversion.

A "weak-typed" programming language is simply one which is not strong-typed.

which is preferred depends on what you want. for scripts and good stuff you will usually want weak typing, because you want to write as much less code as possible. in big programs, strong typing can reduce errors at compile time.

answer Jun 23, 2017 by Shweta Singh

Your answer

Preview

Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
Similar Questions
+2 votes

Why is it preferred to not use finalize for clean up?

+3 votes

How to Sign an Assembly with a Strong Name?

0 votes

How to implement an Object Pool in C#.NET.

...