HaskellWiki

Haskell | Wiki community | Recent changes
Random page | Special pages

 

Not logged in
Log in | Help

Typing

Categories: Glossary

Programming languages can be distinguished by their type systems.

1 No vs. weak vs. strong typing

2 Dynamic vs. static typing

This question concerns whether types are checked at run-time or at compile-time. Static typing has the advantage that errors can be catched before the program runs. This is especially useful if in a large library or program the type of a basic function is changed and this change affects many parts of the project. The type checker can spot many places where the program must be adapted. Static types also allow more efficient code, because if the type of a variable is 'ASCII character' the compiler knows that it must reserve a byte for it. The program does not need to allocate memory for it at run-time. If the variable is processed, its type needs not to be checked, actually the program even cannot check if the type is correct. The program just assumes that the place where the variable is stored always contains an ASCII character.

Dynamic typing is needed whenever the types are not known at compile time. Haskell provides the type Dynamic, which can safely be used but is hardly needed. Scripting languages usually rely entirely on dynamic typing.

Object oriented type systems try a balancing act between dynamic and static typing. Each reference has a static type, but at runtime you can assign more an object of a more specialised type to it. You need type information and type checks at run-time, but you have also static checks.

Retrieved from "http://haskell.org/haskellwiki/Typing"

This page has been accessed 926 times. This page was last modified 14:38, 27 November 2007. Recent content is available under a simple permissive license.