3 ms·
Simplicity can be a benefit, but there are examples of languages that are either dynamically typed with optional static type annotations and languages that are
by exDM69 15y ago
Simplicity can be a benefit, but there are examples of languages that are either dynamically typed with optional static type annotations and languages that are statically typed but have a special dynamic duck type (that may use something like the invokedynamic opcode in the java bytecode), so why not Python?
Examples:
static typing with optional duck types: Boo.
dynamic typing with optional type annotations: many Lisps, e.g. Racket.
- obtu 15y agoPython can't become static with optional invokedynamic; static typing has to be built from the start. For example, the % operator can't be typed. Optional typing I've seen in Perl, and again it seems like boilerplate for no benefit.
- chromatic 15y agoOptional typing I've seen in Perl, and again it seems like boilerplate for no benefit. One benefit is additional optimizations. Many good Lisp implementations take advantage of this.
- exDM69 15y agoI was thinking more about having optional type annotations to facilitate better optimization in (JIT) compiler based implementations of Python, like PyPy, Jython, IronPython or others. Type annotations may also be useful for doing some static sanity checking.