Saturday, July 31, 2021

 126: Python: Stuck with it on the PI

Python: why I hate it. (and prefer PHP in many ways)


1. Beyond trivial programs the group-by-indent sucks. Give me {} any day.


2. No static local variables. I know there is a work-around but it’s lame. Scope can lead to error.


3. No auto convert between string and numeric. Constantly using int(s) and str(n). There could be a “strict” directive for the fussy. Also, watch out for accidentally calling a string “str”.


4. 1/5 = 0 BUT 1/5.0 = .2 ALSO 1.0/5 = .2


5. No case/switch 


6. Many Python errors are only caught when the code is executed. It is tiresome trying to test low-probability error conditions.


7. Too many ways to do (almost) the same thing. Too much to learn. Leads to “personalized” code.


8. No ++ or --, pre or post. Only v += 1


9. I prefer && and || to ‘and’ and ‘or’. ’Natural language’ my ass.


10. Object-Oriented: barf! O-O should be spelled ‘Oh-oh’. I was at Bell Labs when C++ happened. I considered it an empty bottle with a fancy label. I was wrong — it’s worse than that. C is far from perfect but the only good thing about C++ is that you can still write C. You can mostly ignore O-O in Python — but not mostly enough. And why is string-length() better than length(string) — esp. since there is str(n), etc.?


11. __main__ == natural language?