Wandering Thoughts archives

2007-09-14

A thought on untyped languages

In thinking about the whole subject of how languages deal with types recently, it struck me that calling something an untyped language is usually somewhat of a misnomer.

Most things that get called untyped languages, such as assembly code, actually have types; it's just that they are attached to operations instead of to values (and variables, and storage locations). Arguably assembly language has stronger typing for arithmetic operations than most high level languages, since there isn't any silent conversion between different types of numbers.

Thinking about it, I suspect that languages moved to attaching type information to variables because you have to tell the system each variable's type so that it can automatically give you enough storage space for each of them. Once you do that, repeating the information by using a typed operation is just redundant, and programmers are good at getting rid of redundancy.

I believe that there are a few genuinely untyped languages, where all values have a single underlying representation and you can perform any operation on them, although some operations may not make much sense for some data values. I think that APL is close to this, and you could do an APL-like language where all values were really numeric arrays of some number of dimensions.

Another sort of untyped language is one where there are types but everything gets wildly converted back and forth and if something doesn't work out you just get a null value. I thought that awk might be untyped this way, but it is possible to get it to complain about a type mismatch under some circumstances.

programming/UntypedLanguages written at 22:58:43; Add Comment


Page tools: See As Normal.
Search:
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.