Science Fair Projects Ideas - Type safety

All Science Fair Projects

      

Science Fair Project Encyclopedia for Schools!

  Search    Browse    Forum  Coach    Links    Editor    Help    Tell-a-Friend    Encyclopedia    Dictionary     

Science Fair Project Encyclopedia

For information on any area of science that interests you,
enter a keyword (eg. scientific method, molecule, cloud, carbohydrate etc.).
Or else, you can start by choosing any of the categories below.

Type safety

In computer science, a programming language is type safe when the language does not permit the programmer to treat a value as a type to which it does not belong. This generally requires that the language have a complete specification of its semantics; this in turn implies that programs written in that language follow the specification regardless of what machine it is run on. Safety is a property of the programming language, however, and not of the programs themselves. For example, it's possible to have a safe program written in a type-unsafe language.

Type safety is synonymous with one of the definitions of strong typing.

Subsets of ML and Java have been mathematically proven to be type-safe (however, certain errors may occur at runtime due to bugs in the implementation , or in linked libraries written in other languages).

The C programming language is the archtypical type-unsafe language due to casting, particularly the casting of pointers to void pointers and back. More recent implementations of C perform some compile-time type-checking, making the language much more type-safe than it was in its early days. However, the compiler only issues warnings, and the user is still free to perform arbitrary casts that destroy type safety.

In order for a language to be completely type-safe, even against adversaries, it typically needs to have garbage collection. It is possible to make a language type-safe without garbage collection, but it can be difficult. The reason is rather technical: suppose that a strongly typed language (like Pascal) did not have garbage collection and that allocated memory had to be explicitly released. If a dangling pointer existed that still pointed to the old memory location, it is possible that a new data structure can get allocated in the same space with the slot the dangling pointer refers to now pointing to a different type. For example, if the pointer initially pointed to an integer, but in the new space another pointer took its place, then that pointer could be changed to anything simply by changing the value of the integer. Because it is not specified what would happen when such a pointer is changed, the language is not type-safe.

Note that garbage collectors are best implemented in languages that allow pointer arithmetic, so that the library that implements the collector itself is best done in a type-unsafe language like C.

See also

Further reading

10-26-2009 08:16:03
The contents of this article is licensed from www.wikipedia.org under the GNU Free Documentation License. Click here to see the transparent copy and copyright details
Science kits, science lessons, science toys, maths toys, hobby kits, science games and books - these are some of many products that can help give your kid an edge in their science fair projects, and develop a tremendous interest in the study of science. When shopping for a science kit or other supplies, make sure that you carefully review the features and quality of the products. Compare prices by going to several online stores. Read product reviews online or refer to magazines.

Start by looking for your science kit review or science toy review. Compare prices but remember, Price $ is not everything. Quality does matter.
Science Fair Coach
What do science fair judges look out for?
ScienceHound
Science Fair Projects for students of all ages
All Science Fair Projects.com Site
All Science Fair Projects Homepage
Search | Browse | Links | From-our-Editor | Books | Help | Contact | Privacy | Disclaimer | Copyright Notice