A thought on untyped languages

September 14, 2007

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.

Written on 14 September 2007.
« Limiting a process's memory usage on Linux
Weekly spam summary on September 15th, 2007 »

Page tools: View Source, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Fri Sep 14 22:58:43 2007
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.