I would like to have a language with a scalable type system. That means the type system should accommodate everything from dynamic typing for quick hacks, all the way to finely-grained static typing suitable for safety-critical systems.
For example, a particular variable's typed might be refined over time in stages like this.
1. dynamically typed
2. number
3. floating-point number
4. floating-point number between 0.0 - 100.0
5. floating-point number between 0.0 - 100.0, with a minimum of 40 bits in the fractional part
6. floating-point number between 0.0 - 100.0, with a minimum of 40 bits in the fractional part, and tell the execution environment to optimize for memory use instead of performance
The languages in use today can cover parts of that spectrum, but nothing allows the whole range.
Type systems that are concerned with representation and range of primitive values aren't very useful. Replacing representation/structure with type names doesn't improve things.
If I'm adding 3.5 oz of OJ to 6.7 oz of vodka, that's either a programming mistake or a strong drink (represented programatically). (Yes, the correct answer depends on context.) A type system that helps me in that situation is worth something.
A type system that only addresses representation and range of primitive values can't even begin to help in that situation.
Yes, units are a partial solution. (They also reduce programmer work - you can add feet to furlongs and get something sensible.)
Agreed. I just used that floating-point variable as a simple example.
It would certainly be useful to have some concept of units built into the language. I'm actually working on handling units in Java right now, as part of a larger library for healthcare data.
http://www.hl7.org/v3ballot/html/infrastructure/datatypes/da...
For example, a particular variable's typed might be refined over time in stages like this.
1. dynamically typed
2. number
3. floating-point number
4. floating-point number between 0.0 - 100.0
5. floating-point number between 0.0 - 100.0, with a minimum of 40 bits in the fractional part
6. floating-point number between 0.0 - 100.0, with a minimum of 40 bits in the fractional part, and tell the execution environment to optimize for memory use instead of performance
The languages in use today can cover parts of that spectrum, but nothing allows the whole range.