PEP 526 - var annotations and the spirit of python

Abdur-Rahmaan Janhangeer arj.python at gmail.com
Thu Jul 5 02:23:00 EDT 2018


*you know x should still an int after these two statements, because
the type hint says so. Without it:    x = 3    x = f(x)x could be anything.*
*...*


*If something is an int, then make it an int:    x: int = 0*

i'm not arguing about it being useful or not but rather people turn to
python to have a sleek programming experience

python has a personality unless of course we are interested in making it
become a stylised copy cat or a mix-it-all language

i make languages for fun during my spare time and from my experience i can
tell that syntax beats the technical aspects

it's like the front-end and back-end of a website, sure you need something
that works and is efficient but the back-end can be switched. like a
website can be powered by java, ruby, py, etc unless of course you've
thoroughly connected those two like in the case of wordpress. decoupling
the front and back end allows the same user experience across technologies.
that's why we have IronPython, Jython etc.

the back-end matters not, but the front-end yes, in our case it's the
syntax. it's not an issue of being dynamic or not as py is dynamic and will
remain so, rather we must concern ourselves with coding experience

if type hinting is the approval of the steps taken by other languages,
coerced by technical points and is something we miss in python or is like
hey another feature : why not?, for both reasons it explains not it's
purpose

nevertheless type hinting is like an enhanced comment, from the language
making point of view, it is interesting as it is a recognised ignored
pattern. the real power of it will come later, for other implementations.
let me illustrate this.

take the example of javascript, it is like python loose, beginner candy but
crazier and more work. let us see typescript, which at the end of the day
compiles to js. in typescript you must specify for basic types as well as
for arrays the type, number, string etc. type hinting will make it easier
for source-to-source compilation to python

or vice versa like you write your python code and it outputs to C or Java.
tools doing this will have less effort to do as python already has an
in-built way to specify the type.
having an in-built way means no need for special comments, and ensures
uniformity as errors are be raised by the interpreter itself.
personally if i want to undertake a big project in C now, i'll maybe make
python do it for me (source-to-source compilation). just imagine the power
that python can unleash as the py coder will be able to become embedded
systems programmers or android programmers (ideas for free)

from a language maker's perspective, through type hinting python will be
doing a première, coupled with the -> operator, it has what it needs to
ensure a dual personnality, the advantages of which can take another thread

however, as a python user i have always liked a smooth experience, smooth
to read and smooth to write, a language without much ado, a language simple
to use and maintain. we must remember that type hinting relies on good
faith as it can lie but that's not a prob

if i were to choose type hinting or no type hinting i'd choose no but it's
use can be regulated. like a style guide on why and when to use it or some
special comments at the top (in the docstring) but it should be regulated.
if it's use is specified then no prob

a successful language lies in design, not in the implementation of the
design. in language making, function follows form. by successful i have not
included the marketing of it.

python is not tied to C, actually C is too bad to be used by humanity in
the 21st century, it is totally possible for python to replace it as the
de-facto language for hard jobs. we'll just need to switch back-end,
keeping the syntax intact (with minor modifs as needed). (the computer does
not understand C).

if so, it hints to two programming modes in python, one for your daily
quick jobs and one for hard stuffs.

final words :
no to type hinting in your "everyday" codes
yes for specific uses

appendix :
one language for all jobs is totally possible and python is very much
suited for to become that language, but it all depends on human acceptance

Abdur-Rahmaan Janhangeer
https://github.com/Abdur-rahmaanJ
Mauritius (Paradise Island In the Indian Ocean)



More information about the Python-list mailing list