Category: 

What Is Type Safety?

Article Details
  • Written By: Alex Newth
  • Edited By: Angela B.
  • Last Modified Date: 24 November 2016
  • Copyright Protected:
    2003-2016
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog
Helium is the only element that was discovered in space before it was found on Earth.  more...

December 10 ,  1948 :  The UN adopted the Universal Declaration on Human Rights.  more...

Type safety is a part of computer programming that helps to prevent the creation of bugs that appear when a program runs. If type safety is lax, then there is a high probability that there will be some bugs, which can cause a variety of errors. The most common way of ensuring these errors do not occur is by using strong coding. While many programming languages inherently have functions to ensure programming fidelity and to prevent errors, poor coding can render these functions powerless. There are two ways that a programming language can check for these errors — static or dynamic — and both can be effective.

Errors are common in programs and coding and, with type safety, the error specifically occurs from different data types that are not properly regulated. The errors that can occur range from nominal to serious, but most tend to be serious. This can shut down the program, or the poor coding may cause worse problems that may make the coding useless and fragmented.

There are many ways to ensure type safety, but one of the easier and more common ways is by using strong type coding. Unlike softer coding methods, which can enable the programming language to improperly define awkward coding, strong type coding is very direct. Strong type coding also uses rules and regulations to ensure the coding is not improperly defined and ensuring there are few errors.

Ad

A breach in type safety can result in major problems, so many programming languages have adopted features to test for and eliminate — or alert programmers to — these problems. Before the programming goes on to runtime, the language will check for common errors and usually will abort the runtime launch if errors are detected. At the same time, these features may be useless if the programmer creates very poor coding. The language will be unable to recognize the common signs of type safety, so the program will run even though there is an error.

Two methods exist for catching potential type safety issues, and these only apply to programming languages that automatically check for errors. Static methods simply look for the common signs of a problem when the program is going on to runtime. The other method, dynamic, thoroughly checks the code and looks for the role of each coding element in the particulate program. It then searches through the entire program to see if there is a special exception for coding that could be an error, and then it either lets it pass or stops the program’s launch.

Ad

You might also Like

Recommended

Discuss this Article

Post your comments

Post Anonymously

Login

username
password
forgot password?

Register

username
password
confirm
email