UP | HOME

Dynamic Typing

Let’s collapse some bullshit.

Dynamic /typing has to be a strong-typing, meaning no implicit coersions. This is the fundamental principle and it rules out the utter idiocy of PHP and Javasctipt.

This is crucial to have woring proper arithmetics, and a proper implementation of a so-called Numeric Tower with no surprices, and evetything that follows from this.

With dynamic typing one necessarily has

Again, TTD (or REPLs) in dynamically typed languages is absolute necessity and is at the core of rapid prototyping and explotatory programming which is what these lanuages are good for.

The goal is to pass trough every code path (a flow control “branch”) in your code explicitly (and implicitly by testing higher-level layers).

This never guatanee absense of the bugs, but it shows the absense of runtime type-errors.

Of course, the universal fundamentals - proper Abstraction, specifications and Modularity are even more evident in dynamically typed languages - applying them will avoid the possible mess.

Dynamic typing is deeply related to an untyped mathematics, provided that Sets and all the “Algebraic Strucures” are, of course, fomally defined /types – defined by the sets of possible operations.

This is what an proper ADT (packaged as a distinct module) must be.

Notice also that so-called Duck-typing, which is absolutely fundamental at a higher-level, is orthogonal to wether one uses runtime-checking or not.

On the other hand the Late Binding technique is expecilally useful together with the dynamic strucutural typing, as in Python 3

Dynamic typing also “naturally” facilitates the layered DSLs architecture.

The benefits of dynamic typing are best understood in the context of implementing mathematics (as in MATLAB or Julia or various Python libraries).

There the benefits are in high-level, uncluttered programming (see the Octave REPL), not at the implementation side.

Nowadays it is well-understood that to do efficient compilation we need type-inference and type hints (annotations) at the level of compiler’s intemediate representation.

Structural typing

I intentionally do not mention Ruby and Python becase these are class-based dynamically-typed languages, which adds another “dimension” of complexity.

Python 3 champions the “structural dynamic typing”, where one uses the “structure” of an object (which methods hang out of it, literally).

This can be thought of as a unique typing scheme, which goes beyond traditional type-tagging (explicit or as a “static environment”, which a lookup table.).

Author: <schiptsov@gmail.com>

Email: lngnmn2@yahoo.com

Created: 2023-08-08 Tue 18:39

Emacs 29.1.50 (Org mode 9.7-pre)