Summary
One of my pet peeves is when people reference Wikipedia as an authoritative source for computer science defintions.
Advertisement
I recently repsonded to a weblog entry by Venkat Subramaniam about Java generics, where he used the term "type-safety" interchangeably with "static type-checking". When I pointed out the error, he claimed that it depends on how we define "type-safety" and then referenced the Type Safety entry at Wikipedia. I followed the link and found the following:
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.
Well I didn't verify who wrote that, but it is a typically poor definition. The requirement for strong-typing is not that you can't treat a value as a type to which it does not belong, but that if you do treat a value as a type to which it does not belong, then the behaviour is well-defined.
This is not the first time a Wikipedia computer-science definition has made me want to pull my hair out. In the end I don't care, as long as people don't make the mistake of taking Wikipedia definitions seriously. Just remember that in Wikipedia the definitions are written by random people, and edited by random people, not experts.
> Well I didn't verify who wrote that, but it is a typically > poor definition. The requirement for strong-typing is not > that you <b>can't</b> treat a value as a type to which it > does not belong, but that if you do treat a value as a > type to which it does not belong, then the behaviour is > well-defined.
Well-defined because it produces a compile time error?
I thought type-safety simply means that static type information inferred at compile time may not be altered at runtime. Type information known by the compiler is fixed for all future.
Strong-typing on the other hand is the requirement to fix the types of all values at compile time.
the_ wiki, http://c2.com/cgi/wiki?TypeSafe or more formally the Portland Pattern repository has always given me good information on computer science terminology. Also its very well linked so you can lose entire days exploring it. Highly recommended.
> > Well I didn't verify who wrote that, but it is a > typically > > poor definition. The requirement for strong-typing is > not > > that you <b>can't</b> treat a value as a type to which > it > > does not belong, but that if you do treat a value as a > > type to which it does not belong, then the behaviour is > > well-defined. > > Well-defined because it produces a compile time error?
A compile-time error would indicate that the program is not valid but is not considered behaviour. My point is that a language can be both dynamically typed and strongly typed. If an invalid type-cast is guaranteed to throw an exception, then a language would be strongly typed.
> I thought type-safety simply means that static type > information inferred at compile time may not be altered at > runtime. Type information known by the compiler is fixed > for all future. > > Strong-typing on the other hand is the requirement to fix > the types of all values at compile time.
This is not a broad enough definition to cover programming languages which support dynamic typing.
> So just update the article. It's really simple a quick to > do. > > Use your energy for good, not bitching. :)
I am not intending to simply bitch but instead make the point that Wikipedia entries are volatile, unreliable and from questionable sources. They can be good to help guide research but are hardly reference-worthy.
I suppose though I chould make a more positive contribution to the community than simply pointing out flaws in wikipedia. I have been toying with the idea of starting a computer science wiki which is restricted to contributions by actual experts in the field, but open for general discussion behind the scenes. This could be a fun project if anyone would find it worthwhile. Any thoughts?
Anyone could but would they? I'm sorry, you have no right to complain if you haven't tried it. Go put in what you consider to be a valid definition and if it gets changed to something you think is wrong, come back and tell us.
"Wikipedia the definitions are written by random people, and edited by random people, not experts."
What evidence do you have that experts never contribute to Wikipedia?
What evidence do you have that experts never disagree about computer science terminology?
What evidence do you have that any of your contributions to Wikipedia will always be changed by someone else?
In some ways, Wikipedia has the same 'protection' as open source software, in that a consensus of correctness tends to dominate over time. That is acheived by individuals brave enough to risk contributing to the 'greater good'.
I urge to to make corrections whenever you can. True, it is possible that your contribution will be modified, however if your contribution is good/correct/clear then the probability of 'desecration' is greatly lowered.