3 ms·
There's an argument to be made: one can't be all things to everyone. Python is a dynamic language, and adding optional features to make it work differently won'
by obtu 15y ago
There's an argument to be made: one can't be all things to everyone. Python is a dynamic language, and adding optional features to make it work differently won't bring the benefits of either way of making things work consistently. Two syntaxes like that troll poster proposed would increase cognitive load, static typing mixed with dynamic typing would add some boilerplate for no real safety.
- exDM69 15y agoSimplicity 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.