I like #Python. It was the first programming language I tried, it had a reputation of being easy to learn and yeah, it was. What I don't really understand is how it has become so popular (# 1 in the TIOBE index...) and pervasive (you find it in areas where it seems like logic for a scripting language, but in others where you wouldn't bet for it too). It shines where it shines, but aren't really there better options in some of the niches it is being used for?
@array There really is very little you need to go outside python for, so people don't.
Scripts? Check. Well-factored applications? Check. Static type-checking? These days, check.
It really is a wide range, and while it is not too performant, most of the time your code is waiting for I/O or a human. When performance is actually needed, heavy calculations go into pandas and numpy and on the other end things like protocol parsing go into gunicorn and starlette.
Python's got you covered. Best language for almost nothing, good enough language for almost everything. More boring than Ruby, less line noise than Perl.
@array Python gets used by a lot of non-programmers, (Data-scientists) and the like, because it's easy to write stuff in, so I think that is a part of it. It also early got good bindings to Machine Learning Suites, which did propel it forward, I think python's popularity has a lot to do with the libraries that is available to it, it's the thing that makes me want to try it out again some times :)
Every language has either wild package names or a community so small that only one person wrote an html parser and can call it "html".
> solving problems through syntax
Every language except Lisp and friends.
> PEP 8 linter
Run your code through the "black" formatter. It's nice to write code your friends can read. Every language should come with a style checker and a formatter.
> different versions of pip for every Python version
That's how they coexist. If you don't like it you can instead my-python-version -m pip.
> conflicting solutions
Pick a set that suits you. I enjoy using pyenv+pip-tools.
> package management is horrible
It installs stuff and dependencies and struggles with the same tradeoffs and intrinsic complexities as any package management system.
> "Pythonic" code is meaningless
It's nice to write code friends can read.
> only know Python
It really is a very good hammersawscrewdriver. I would love an excuse to use one of the other languages I learned, but I don't have one.
> non-standard nomenclature
CS calls these abstract data types lists and dictionaries. Programmers mix them up with implementation details and call them arrays and hashtables even when they're not.
> quotes in Python
Yes, they are different from bash. Just different arbitrary rules.
> pass things by value
Don't? I admit sometimes I would like to have more immutable types to make sure code I call behaves, but it's seldom a real problem in practice.
> GCC knows you want to import screencapture.h
What? No it doesn't unless you include.
> 4 SPACES
Arbitrary conventions are arbitrary. Please follow conventions. It's nice to write code friends can read.
@array I have a harsher opinion of Python than other people (as in I believe it is, and excuse my advanced Ancient Albanian Sign Language, dogshit). Python is lucky it can access C and Fortran because otherwise no one would use it in any scientific context. To rapid-fire the shit I hate about Python:
The package names are so inconsistent (PyPy, PyPi, NumPy, SciPy, SymPy, PyGtk, Pyglet, PyGame, SQLAlchemy, BeautifulSoup...)
It loves solving problems through syntax and badly-written abstractions instead of using the language itself
Good luck making a program that doesn't make the PEP 8 linter trigger-happy
You need different versions of pip for every Python version (go right now to your terminal and do ls /usr/bin/pip{2,3}* 2>/dev/null) and there are multiple conflicting version management solutions (pyenv, venv, poetry...)
The package management is horrible (shit, it makes CPAN look like something God sent from the heavens)
"Pythonic" code is meaningless and mostly means you copy obtuse shit from SO (you might as well copy Perl too)
A lot of Pythoners seem to only know Python and are unwilling to learn everything else because for them everything is a nail
The same people love to use non-standard nomenclature for shit already established in the CS community (they call arrays "lists", they call associative arrays/hashes "dictionaries" etc.)
Wait until you play with quotes in Python
You have to work hard to pass things by value (the most reliable method so far is a=copy.deepcopy(b) because not all objects have .copy())
if you do something like gcc -o screencapture.exe screencapture.c -lscreencapture, GCC knows you want to import screencapture.h, but in Python if you do the same thing it wants to import the local code first (glhf if you have a screencapture.py file...)
Even though the docs also accept tabs, PYTHONERS SCREAM AND WANT 4 SPACES!!!! Nothing else allowed.
@clacke Yeah, it's really pervasive. And very good at what's good, as I said, I like it too. It's just the point that you raise, "best language for almost nothing", that brings me some doubt. As in, why not just use "the best tool for the job", when there are arguably better options in some domains? Using Python for *everything* sounds just a bit... Lazy, I guess? :P
There is great momentum in a community that already knows a language and wants to *do work* with that. (i.e. that is not primarily programming, but merely *using* programming to achieve some other goal.)
So, those people will reach for what they already know, which in this case is #Python; and if it is good enough, then other niche special-purpose tools don't even get investigated.
A special property of Python is impressive support for so many use cases; people try it, it just works!
Your prototype *will* be put in production. You have two choices: - Expect that and embrace it - Make sure the prototype is as close as you can get to 100% useless for production
@array@clacke all the more reason to see its position as a very good prototyping language. Perfect for demonstrating what the final program should do, much of how it can work and good enough to use until the "production" replacement is completed.
At least people starting today won't have to suffer the big bang breaking change of Python 3, but the lesson learned was instead "let's break small things every 'minor' release".
@clacke@array@a13cui for me, I liked Python the language, but hated the deployment model and breaking changes. To get consistent development and production you often had to turn to virtual environments and could not depend on the "system" python. This was especially true when many distros still bundled python2 but everything needed to be in python3 as demanded by real world users. Ruby bundler felt cleaner than that, and ruby could be monkey-patched with language feature backports.