UP | HOME

Why Python

Python is driven by a huge crowd (way bigger than anything else) and thus has an enormous momentum, both in its continuing evolution and in related social dynamics, which include academic activities, books, development of pragmatic, high quality libraries (mostly by corporations), etc.

Since MIT switched to Python to the main teaching language, lots of academics are “into it”, so the language have way less theoretical blunders and kludges which infest amateur languages, of which PHP4 is a legend, and Java and especially Javascript were originally just a fucking carp.

It also has some high quality books (mostly by good academics), high quality teaching materials (whole video courses and lecture notes) and high quality libraries. Notice that Ocaml and Haskell courses from Cambridge has even better lecture notes.

Python is also a unique blend of mostly-functional (immutable bindings) and imperative features (with all the implied problems of mutating or overwriting assignments - the aliasing problems, mutable state problems, etc).

Being a strong- but dynamically typed language gives it some benefits too. It has optional (not mandatory everywhere) type-annotations, which could be checked both by the interpreter at compile-time and by an ordinary code at runtime.

It cannot have a proper type-inference, since its lacks referential transparency, its conditionals can “return” values of different types, its statements are not pure expressions, and its data recursive data-structures are not homogeneous.

This makes Python to be “closer” to early LISPs at the static-semantics level.

Its main implementation is a (simple byte-code) interpreter, which, arguably, is the best choice for a trully-dynamic language. (Julia is an attempt to prove the contrary). Smalltalk was the first trully-dynamic, by the way.

In addition to that, like all good dynamically-typed languages (Lua, Julia and NOT Javascript), it has a ’structural typing“, which is an “evolution” of merely type-tagging of LISPs.

The structure of an object defines its type (a particular subset to which it belongs), not just a set of possible operations, as in the classic languages.

Which methods and slots (fields) “hangs out” from an object (literally!) determines its “behaviors” or “traits”.

Lets call it a “structural duck-typing” or “structural type-classes” (when, again, it is the dynamic structure of an object which define its “type”).

Given all this, Python is by no means a simple language. It is, however, a “less wrong language” (thanks to a small crowd of good academics involved), as it could be possible for an imperative language with destructive assignments, mutable state and statements “in time”.

A complex language becomes messy, especially with messy amateur libraries, which are plagued by unnecessary, redundant, poorly-chosen abstractions and misused advanced language features. Well, use only the best ones.

So, should it be one’s first language? I would say NO. Scheme or Ocaml or even Haskell or Clojure are the better choices.

Should one learn Python as a second language? Absolutely, without any doubt.

Again, the momentum is enormous – books, courses, tooling and especially libraries – and one has to ride it, just like a surfer would.

Author: <schiptsov@gmail.com>

Email: lngnmn2@yahoo.com

Created: 2023-08-08 Tue 18:40

Emacs 29.1.50 (Org mode 9.7-pre)