User avatar
davidcoton
Posts: 5154
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: Python 2 EoL...at least in theory

Fri May 22, 2020 9:20 am

Heater wrote:
Fri May 22, 2020 8:44 am

If you ever find you have been around the block a few times and have had to program in more languages than you care to remember you will likely come to the conclusion that all programming languages suck.

We know this to be generally true because new programming languages sprout like weeds. Why would so many talented software engineers, waste their time trying to define and build new programming languages if they were happy with anything that existed already?
I'm writing a new language. It's called Vacuum, because it sucks.
But it's awesome for cleaning out bugs.
Release is scheduled for 1/4/2021 -- recruiting beta testers now....

See also the X language.
I'm going to incorporate some of that.
Especially mono fonts for integers, proportional fonts for real numbers.
Location: 345th cell on the right of the 210th row of L2 cache

Heater
Posts: 16314
Joined: Tue Jul 17, 2012 3:02 pm

Re: Python 2 EoL...at least in theory

Fri May 22, 2020 9:51 am

jahboater wrote:
Fri May 22, 2020 9:10 am
Heater wrote:
Fri May 22, 2020 8:44 am
Since when has popularity been a measure of the quality of anything?
Of course, rarely.
But it is a measure of the practical usability of the language for real world applications.
In this case universal availability, vast library resources, extensive knowledge base, etc etc.
Very true. That is why I find myself having to use Python. For example a huge majority of the tutorials, examples etc in the machine learning world are presented in Python. It would be a huge effort to try and swim against the tide there.
jahboater wrote:
Fri May 22, 2020 9:10 am
Wide exposure means less bugs.
Hopefully that is true for all the libraries one ends up using.

I'm worried about the bugs in my own code. Python does not even try to help there. I feel like I'm trying to construct huge buildings out of jelly.
Memory in C++ is a leaky abstraction .

Heater
Posts: 16314
Joined: Tue Jul 17, 2012 3:02 pm

Re: Python 2 EoL...at least in theory

Fri May 22, 2020 9:55 am

davidcoton wrote:
Fri May 22, 2020 9:20 am
I'm writing a new language. It's called Vacuum, because it sucks.
Brilliant!

No matter what source you shovel in to it nothing ever comes out. Totally bug free :)

Your next version "BlackHole" will be even better.
Memory in C++ is a leaky abstraction .

User avatar
jojopi
Posts: 3292
Joined: Tue Oct 11, 2011 8:38 pm

Re: Python 2 EoL...at least in theory

Fri May 22, 2020 10:38 am

gkreidl wrote:
Fri May 22, 2020 5:42 am
No kind of conversion tool will fix this.

Code: Select all

pi@tau:~ $ 2to3-2.7 keys.py 
RefactoringTool: Refactored keys.py
--- keys.py     (original)
+++ keys.py     (refactored)
@@ -1,2 +1,2 @@
-k = d.keys()
+k = list(d.keys())
 k.sort()
RefactoringTool: Files that need to be modified:
RefactoringTool: keys.py

User avatar
Cancelor
Posts: 777
Joined: Wed Aug 28, 2013 4:09 pm
Location: UK

Re: Python 2 EoL...at least in theory

Fri May 22, 2020 10:46 am

drgeoff wrote:
Wed Apr 22, 2020 11:46 pm
Theory and practice are not always the same.
In theory they are, in practice they are not. ;-)
Can't find the thread you want? Try googling : YourSearchHere site:raspberrypi.org

Heater
Posts: 16314
Joined: Tue Jul 17, 2012 3:02 pm

Re: Python 2 EoL...at least in theory

Fri May 22, 2020 12:06 pm

jojopi wrote:
Fri May 22, 2020 10:38 am
gkreidl wrote:
Fri May 22, 2020 5:42 am
No kind of conversion tool will fix this.

Code: Select all

pi@tau:~ $ 2to3-2.7 keys.py 
RefactoringTool: Refactored keys.py
--- keys.py     (original)
+++ keys.py     (refactored)
@@ -1,2 +1,2 @@
-k = d.keys()
+k = list(d.keys())
 k.sort()
RefactoringTool: Files that need to be modified:
RefactoringTool: keys.py
Nice example. However:

"For this reason tools like 2to3, even if well written and extremely useful to automate the conversion of every other difference, have some limitations. With the bytes/unicode split the difference in behavior surfaces at runtime, and a tool that can only do parsing/static analysis thus won’t be able to save you if you have a huge Python 2 codebase that mixes these two types."

From here: https://www.toptal.com/python/python-3- ... the-switch
Memory in C++ is a leaky abstraction .

User avatar
DougieLawson
Posts: 39573
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Python 2 EoL...at least in theory

Fri May 22, 2020 12:17 pm

Heater wrote:
Fri May 22, 2020 9:51 am
jahboater wrote:
Fri May 22, 2020 9:10 am
Wide exposure means less [sic] bugs.
Hopefully that is true for all the libraries one ends up using.

I'm worried about the bugs in my own code. Python does not even try to help there. I feel like I'm trying to construct huge buildings out of jelly.
Isn't that the reason behind IDLE, Geanny and Thonny for the folks who need those types of thing. I write python with vim and debug it from a bash command line.
The python stack trace is almost as useful as the Java stack trace for telling you which line in your code is broken, but without revealing why it's broken.

Here is a classically cryptic example:

Code: Select all

pi@endeavour:~/python$ python3 matrix_single.py
Traceback (most recent call last):
  File "matrix_single.py", line 31, in <module>
    demo(args.cascaded, args.block_orientation, args.rotate)
  File "matrix_single.py", line 11, in demo
    serial = spi(port=0, device=0, gpio=noop())
  File "/usr/local/lib/python3.7/dist-packages/luma/core/interface/serial.py", line 285, in __init__
    self._spi.cshigh = cs_high
SystemError: error return without exception set
pi@endeavour:~/python$
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

Heater
Posts: 16314
Joined: Tue Jul 17, 2012 3:02 pm

Re: Python 2 EoL...at least in theory

Fri May 22, 2020 12:33 pm

DougieLawson wrote:
Fri May 22, 2020 12:17 pm
Isn't that the reason behind IDLE, Geanny and Thonny for the folks who need those types of thing. I write python with vim and debug it from a bash command line.
I have no idea about IDLE, Geanny and Thonny. I have no intention to find out. I too write everything in Vim or VS Code.
DougieLawson wrote:
Fri May 22, 2020 12:17 pm
The python stack trace is almost as useful as the Java stack trace for telling you which line in your code is broken, but without revealing why it's broken.
Getting your code running as you are developing it is one thing.

The problems come when you have a large code base that trips up over some weird circumstance in the middle of the night. Projects have spent years shaking out such issues in their code bases. Which of course makes them very wary of making any changes to adapt it to the new Python 3 language. Let alone trust it to any automated language transpilation tool.
Memory in C++ is a leaky abstraction .

plugwash
Forum Moderator
Forum Moderator
Posts: 3648
Joined: Wed Dec 28, 2011 11:45 pm

Re: Python 2 EoL...at least in theory

Fri May 22, 2020 12:36 pm

ehem wrote:
Fri May 22, 2020 2:57 am
They can almost certainly be automated. Worst case, write a Python 2 interpreter in Python 3 and you should be able to continue running Python 2 within Python 3. I haven't done anything very gnarly with Python, but 2 and 3 are mostly fairly compatible.
The problem is python is such a dynamic language. It's virtually impossible to be sure what type(s) a variable could be at any given point in the code. To avoid crazy code bloat with piles of conditional logic, conversion tools and people doing a conversion have to make educated guesses, sometimes those guesses are wrong leading to the introduction of bugs.

In an ideal world code would have comprehensive testsuites that could be used to detect such bugs, in the real world it often doesn't.

The syntax issues are a minor issue by comparison and can easily be dealt with.

jahboater
Posts: 5932
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: Python 2 EoL...at least in theory

Fri May 22, 2020 1:42 pm

Heater wrote:
Fri May 22, 2020 9:51 am
I feel like I'm trying to construct huge buildings out of jelly.
I like that phrase :)
Others I remember from computing history are:-

Like trying to kick a dead whale along a beach.

Like pushing a pea up a mountain with your nose.
Pi4 8GB running PIOS64 Lite

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26852
Joined: Sat Jul 30, 2011 7:41 pm

Re: Python 2 EoL...at least in theory

Fri May 22, 2020 1:57 pm

Heater wrote:
Fri May 22, 2020 12:33 pm
DougieLawson wrote:
Fri May 22, 2020 12:17 pm
Isn't that the reason behind IDLE, Geanny and Thonny for the folks who need those types of thing. I write python with vim and debug it from a bash command line.
I have no idea about IDLE, Geanny and Thonny. I have no intention to find out. I too write everything in Vim or VS Code.
So, there's a suggested way to debug your code more easily, but you refuse to use it? Sheer bloody mindedness, or an actual reason? Presumably you also use gbd on the command line, because have your important bits trapped in a vice isn't masochistic enough?
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

Heater
Posts: 16314
Joined: Tue Jul 17, 2012 3:02 pm

Re: Python 2 EoL...at least in theory

Fri May 22, 2020 2:01 pm

In that case you might like what the mathematician Po-Shen Loh said:

"Whenever I write a program in C++ I feel like I'm building a race car out of duct tape"

Have you ever seen a dead whale on the beach? I have, near Brighton pier round about 1984. A couple of young girls were daring each other to touch it. One did. Her finger sank into the rotting flesh and she screamed like crazy.

You really don't want to try kicking that up the beach.
Memory in C++ is a leaky abstraction .

Heater
Posts: 16314
Joined: Tue Jul 17, 2012 3:02 pm

Re: Python 2 EoL...at least in theory

Fri May 22, 2020 3:07 pm

jamesh wrote:
Fri May 22, 2020 1:57 pm
So, there's a suggested way to debug your code more easily, but you refuse to use it? Sheer bloody mindedness, or an actual reason?
Perhaps if you were to point out how anyone of those helps debug anything in any way better than what can be done with Vim and/or VS Code I might be persuaded to take a look.

As for "actual reason", put it down to IDE fatigue. Currently I need IntelliJ for Scala, qtcreator for C++ and Qt. Quartus for dealing with FPGA. The Propeller Tool for Spin, Arduino for Arduino. Not to mention having to use a dozen other IDEs for various embedded systems over the years. Enough is enough, stop it already.
jamesh wrote:
Fri May 22, 2020 1:57 pm
Presumably you also use gbd on the command line, because have your important bits trapped in a vice isn't masochistic enough?
Not a great user of debuggers actually. Typically if a bug is not found on initial running of the code and subsequent unit and other testing it is also pretty hard to track down with a debugger like gdb, with or without a nice GUI.
Memory in C++ is a leaky abstraction .

W. H. Heydt
Posts: 12972
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Python 2 EoL...at least in theory

Fri May 22, 2020 4:55 pm

Heater wrote:
Fri May 22, 2020 2:01 pm
Have you ever seen a dead whale on the beach? I have, near Brighton pier round about 1984. A couple of young girls were daring each other to touch it. One did. Her finger sank into the rotting flesh and she screamed like crazy.
This would probably have been some time before 1910, and certainly no later than 1920 (I don't have a reference handy, and I read about it at least 50 years)...

Roy Chapman Andrews (a partial model for Indiana Jones) was tasked with recovering the skeleton of a dead whale for the NY Museum of Natural History.

W. H. Heydt
Posts: 12972
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Python 2 EoL...at least in theory

Fri May 22, 2020 4:57 pm

Cancelor wrote:
Fri May 22, 2020 10:46 am
drgeoff wrote:
Wed Apr 22, 2020 11:46 pm
Theory and practice are not always the same.
In theory they are, in practice they are not. ;-)
I wish I lived in Theory. Everything *works*...in Theory.

bls
Posts: 718
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: Python 2 EoL...at least in theory

Fri May 22, 2020 5:02 pm

DougieLawson wrote:
Fri May 22, 2020 12:17 pm
I write python with vim and debug it from a bash command line.
Ah, a fellow luddite! I write python with emacs and debug it with that same wonderful bash command line :lol:
Pi tools:
Easily and quickly build customized-just-for-you SD Cards: https://github.com/gitbls/sdm
Free your network from your router's DHCP/DNS:https://github.com/gitbls/ndm
Easy strongSwan VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

Heater
Posts: 16314
Joined: Tue Jul 17, 2012 3:02 pm

Re: Python 2 EoL...at least in theory

Fri May 22, 2020 5:30 pm

W. H. Heydt wrote:
Fri May 22, 2020 4:55 pm
Heater wrote:
Fri May 22, 2020 2:01 pm
Have you ever seen a dead whale on the beach? I have, near Brighton pier round about 1984. A couple of young girls were daring each other to touch it. One did. Her finger sank into the rotting flesh and she screamed like crazy.
This would probably have been some time before 1910, and certainly no later than 1920 (I don't have a reference handy, and I read about it at least 50 years)...
Grief, I'm not that old.

It was mid 1980's. Brighton as in Sussex as in England, in case there are any other Brightons out there. It was the day of the London to Brighton Vintage Car Rally. My old MG managed to make it there and back.
Memory in C++ is a leaky abstraction .

W. H. Heydt
Posts: 12972
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Python 2 EoL...at least in theory

Fri May 22, 2020 7:02 pm

Heater wrote:
Fri May 22, 2020 5:30 pm
W. H. Heydt wrote:
Fri May 22, 2020 4:55 pm
Heater wrote:
Fri May 22, 2020 2:01 pm
Have you ever seen a dead whale on the beach? I have, near Brighton pier round about 1984. A couple of young girls were daring each other to touch it. One did. Her finger sank into the rotting flesh and she screamed like crazy.
This would probably have been some time before 1910, and certainly no later than 1920 (I don't have a reference handy, and I read about it at least 50 years)...
Grief, I'm not that old.

It was mid 1980's. Brighton as in Sussex as in England, in case there are any other Brightons out there. It was the day of the London to Brighton Vintage Car Rally. My old MG managed to make it there and back.
The reason I"m pretty sure of the date of the incident is that, starting in 1920, Andrews led several expeditions into the Gobi Desert to look for fossils. He used motor vehicles for transport with a contracted camel caravan to leave supply dumps. This was quite radical at the time, as was the idea that the Gobi was a good place to look for fossils. What Andrews really wanted to find were *human* fossils, as it was widely believed at the time that humans originated in Asia. What he found were dinosaur fossils, including the first known dinosaur eggs.

Andrews himself was a Naturalist, of the "old school"...shoot the critter you're interested in and bring back the skin and bones.

Heater
Posts: 16314
Joined: Tue Jul 17, 2012 3:02 pm

Re: Python 2 EoL...at least in theory

Fri May 22, 2020 9:34 pm

W. H. Heydt wrote:
Fri May 22, 2020 7:02 pm
Andrews himself was a Naturalist, of the "old school"...shoot the critter you're interested in and bring back the skin and bones.
Are we talking about the same event?

Mine was in the mid 1980's.

I did not see any dinosaur parts around or guys with blunderbusses.
Memory in C++ is a leaky abstraction .

User avatar
ehem
Posts: 55
Joined: Mon Sep 09, 2019 1:17 am

Re: Python 2 EoL...at least in theory

Fri May 22, 2020 11:29 pm

gkreidl wrote:
Fri May 22, 2020 5:42 am
ehem wrote:
Fri May 22, 2020 2:57 am
They can almost certainly be automated. Worst case, write a Python 2 interpreter in Python 3 and you should be able to continue running Python 2 within Python 3. I haven't done anything very gnarly with Python, but 2 and 3 are mostly fairly compatible.
...
No, Heater's right. Although there are some tools for conversion, you will have a lot of bugs/problems. Here's a simple example:
Automated translation of programming languages is nearly always possible, it is called a "compiler". A compiler with Python 2 input and Python 3 output feels like it shouldn't be too difficult. Humans would likely end up severely tweaking the output before checking it into revision control. Is this a worthwhile project? Likely not, but 2 and 3 aren't that far apart.

Heater wrote:
Fri May 22, 2020 8:11 am
It's not the TAB width that is the problem. Although of course nobody should use TAB characters in their code. The whole idea of using white space as block delimiting is daft. And, if you are going to do it so as to remove weird braces and such then do a proper job and don't require that stupid redundant ":" everywhere.
Both Linux and FreeBSD have standards of using tabs. I've found GCC's misleading whitespace warning to have a very high rate of identifying actual errors. Meanwhile warning about casting from void * is beyond useless.

DougieLawson wrote:
Fri May 22, 2020 8:22 am
BTW, I thought python2 had a happy death on 1st Jan 2020.
I suspect its true death may be closer to April 1st, 2718.

Heater
Posts: 16314
Joined: Tue Jul 17, 2012 3:02 pm

Re: Python 2 EoL...at least in theory

Sat May 23, 2020 5:03 am

ehem wrote:
Fri May 22, 2020 11:29 pm
Automated translation of programming languages is nearly always possible, it is called a "compiler". A compiler with Python 2 input and Python 3 output feels like it shouldn't be too difficult. Humans would likely end up severely tweaking the output before checking it into revision control. Is this a worthwhile project? Likely not, but 2 and 3 aren't that far apart.
Adding bold emphasis to what you said shows that you agree. Any automatic translation will not be 100% correct. Will require extensive retesting and likely human inspection and rework. For this reason the switch over has been going on for years.
ehem wrote:
Fri May 22, 2020 11:29 pm
Both Linux and FreeBSD have standards of using tabs.
Do you mean the Linux kernel? No doubt that project has its standard formatting style.

Or did you mean "Linux" as in generally the whole operating system based on a Linux kernel like Raspbian. I'm sure you will find as many formatting styles in there as there are projects from which it is built.
ehem wrote:
Fri May 22, 2020 11:29 pm
I've found GCC's misleading whitespace warning to have a very high rate of identifying actual errors. Meanwhile warning about casting from void * is beyond useless.
What do you mean there? I don't recall ever getting a white space warning out of GCC (except a missing line feed on the last line sometimes, for reasons I have never understood).

Python cannot tell if you have a white space error in your code. So that is no help either.

Incorrect casts in C is a major source of bugs and well worth a warning.
Memory in C++ is a leaky abstraction .

jahboater
Posts: 5932
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: Python 2 EoL...at least in theory

Sat May 23, 2020 10:00 am

Heater wrote:
Sat May 23, 2020 5:03 am
What do you mean there? I don't recall ever getting a white space warning out of GCC (except a missing line feed on the last line sometimes, for reasons I have never understood).
Things like:-

Code: Select all

if( cond )
   statement
   statement 
are obviously wrong and -Wmisleading-indentation will tell you.
Pi4 8GB running PIOS64 Lite

Heater
Posts: 16314
Joined: Tue Jul 17, 2012 3:02 pm

Re: Python 2 EoL...at least in theory

Sat May 23, 2020 10:41 am

Ah yes, good point.

That has always annoyed me. I think C should have always have required braces around the bodies of "if", "for" etc. even if they are only one statement.

Code: Select all

if  cond  {
   statement
   statement 
}
That would have saved half a centuries worth of confusion and the resulting bugs.
Then we would not need the silly round braces around the condition.
Having two syntaxes for the same thing is silly anyway.
Memory in C++ is a leaky abstraction .

User avatar
Imperf3kt
Posts: 3761
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Python 2 EoL...at least in theory

Mon May 25, 2020 12:03 am

ehem wrote:
Fri May 22, 2020 2:57 am
I ran across a presentation of someone talking about all the features they would include to make the most annoying programming language possible. Syntactically significant whitespace was near the top of the presenter's list.

One tab to rule them all. If you like 4 space indentations, set your tab stop to 4 spaces. Heck, even covers the person who likes 5 space indentations.
If you think python is bad then you've clearly never heard of whitespace.
https://en.wikipedia.org/wiki/Whitespac ... _language)

It has been used to hide Trojans and viruses in otherwise innocuous programs.
55:55:44:44:4C
52:4C:52:42:41

Heater
Posts: 16314
Joined: Tue Jul 17, 2012 3:02 pm

Re: Python 2 EoL...at least in theory

Mon May 25, 2020 3:49 am

Imperf3kt wrote:
Mon May 25, 2020 12:03 am
If you think python is bad then you've clearly never heard of whitespace.
https://en.wikipedia.org/wiki/Whitespac ... _language)
Sure we have heard of whitespace. I love the idea of a syntax highlighter for whitespace, as shown on that wiki page.
Imperf3kt wrote:
Mon May 25, 2020 12:03 am
It has been used to hide Trojans and viruses in otherwise innocuous programs.
Do you have a link to such a claim? Never heard that before.
Memory in C++ is a leaky abstraction .

Return to “Off topic discussion”