Writing forward-compatible software in Python

Py­thon 3 is the fu­tu­re of Py­tho­n. Ho­we­ver the­re mi­ght be a pro­blem in the ­co­m­mu­ni­ty if bo­th Py­thon 3 and 2 co­exis­t. The for­mer one was great an­d ­bri­llian­t, but it is ti­me to start wri­ting so­ftwa­re in the new ver­sion in or­de­r ­to mo­ve to­war­ds new fea­tu­res and im­pro­ve­men­ts.

Le­t’s start by the be­gin­nin­g. One of the rea­sons I alwa­ys pre­fe­rred Py­thon ove­r ­the rest of the pro­gra­m­ming lan­gua­ges is be­cau­se it is mo­re ad­van­ce­d, mea­nin­g ­that in­clu­ded many con­cep­ts that other lan­gua­ges did no­t. For exam­ple, thi­nk of how ear­ly Py­thon adop­ted ideas like lamb­da func­tion­s, dy­na­mic ty­pin­g, ­du­ck ty­pin­g, con­text ma­na­ger­s, me­ta­cla­s­ses and so on, whi­le other te­ch­no­lo­gie­s (­na­me­ly Ja­va, C++ for exam­ple [1]) we­re sti­ll using da­ta struc­tu­res and ca­llin­g ­them “ob­jec­ts”. Py­thon has alwa­ys been many steps ahea­d.

Great news are that this is no ove­r: Py­thon is sti­ll im­pro­ving at a fast pa­ce. And that is pre­ci­se­ly the is­sue wi­th Py­thon 3. As a re­sult of tha­t e­vo­lu­tio­n, the new ver­sion of Py­thon must chan­ge so­me of its in­ter­nals in or­de­r ­to pro­per­ly im­ple­ment new fea­tu­res, and this is what lead it to be in­com­pa­ti­ble wi­th ear­lier ver­sion­s, whi­ch should not be a pro­ble­m. But it see­ms it is.

So­me de­ve­lo­pers do not like the new re­lea­se, and they are not keen on mi­gra­tin­g ­the co­de ba­se. They ar­gue that Py­thon 3 “is wron­g” be­cau­se it is not ba­ckwar­ds com­pa­ti­ble, but my ques­tion he­re is why are we thi­nking ba­ckwar­ds ins­tead of fo­rwar­ds. A pro­gra­m­ming lan­gua­ge as a mo­del or con­cep­t, must evol­ve, im­pro­ve, so we s­hould be thi­nking on the fu­tu­re of the lan­gua­ge ra­ther that on its ­pas­t. I thi­nk they are mis­sing the new idea­s, the way Py­thon is chan­ging in or­der to in­cor­po­ra­te mo­re effi­cient me­cha­nis­ms. Perhaps this ti­me, the leap wa­s ­too bi­g.

I thi­nk the best for the lan­gua­ge is to adopt its new ver­sio­n, and do not thi­nk of it as a di­ffe­rent one. The­re­fo­re, when we say “P­y­tho­n”, it should be­ un­ders­tood that we are ta­lking about just one sin­gle ver­sio­n.

[1] At the time of this writing just the latest version of Java incorporated lambda expressions, which have been available in Python for many years.