- cross-posted to:
- [email protected]
- cross-posted to:
- [email protected]
I started using it as an alternative to Octave/Matlab and Perl. Python is better at general programming than Octave/Matlab, and better syntax than Perl (IMO) while being almost as easy to do the same stuff I was using Perl for. It’s very good for quickly writing small scripts. Issues can arise on large projects/teams because of stuff like type safety, and it also has issues with performance.
From an administrator POV, python is great for scripting, automation, and AWS boto work.
I think it’s just because it is always recommended as an “easy” language that’s good for beginners.
The only other thing it has going for it is that it has a REPL (and even that was shit until very recently), which I think is why it became popular for research.
It doesn’t have anything else going for it really.
- It’s extraordinarily slow
- The static type hints are pretty decent if you use Pyright but good luck convincing the average Python dev to do that.
- The tooling is awful.
uv
is a lifesaver there but even withuv
it’s a bit of a mess. - The package system is a mess. Most people just want to import files using a relative path, but that’s pretty much impossible without horrible hacks.
- The official documentation is surprisingly awful.
- Implicit variable declaration is a stupid footguns.
The actual syntax is not too bad really, but everything around it is.
syntax is bad for list operations, also there are situations where you need to count the number of parentheses you closed, which wouldn’t happen of you were able to use fluent interfaces
I think it’s just because it is always recommended as an “easy” language that’s good for beginners.
The only other thing it has going for it is that it has a REPL (and even that was shit until very recently), which I think is why it became popular for research.
If that’s the case, then why didn’t Javascript take its place instead? It’s arguably even better at Python in both of those areas…
But worse in everything else. And the runtime-platform is a mess.
I think Python is superficially easier since you don’t have to declare variables, printing is a little easier, etc. And in some ways it is actually easier, e.g. arbitrary precision integers, no
undefined
, less implicit type coercion.But I agree JavaScript is generally a better choice. And it is actually more popular than Python so…
My opinion: Python may not be the best at everything it does, but it’s in the top 3-5 languages in the following areas:
- Very easy to install, write and understand
- Great libraries for a lot of applications
- Large community, lots of people with experience in it
It will always be a practical choice for those reasons. There are probably a lot more as well that I can’t think of at the moment.
Very easy to install
This has to be a joke.
Yeah, thought the same. Python isn’t intuitive to install new packages.
Python is not the best at anything, but is the second best at almost everything. That’s the reason I use it. Everything I need to do, I know I can do it in python, maybe isn’t going to be the better or faster it could be, but it will work.
Yeah, Python is fast enough. Being assembly-fast is just not that important for a lot of things.
This. As a chemist I just need to do rather simple calculations, plots and sometimes use a package or two. My total yearly compute time is like 1 hour in python. Spending 5 years learning c, assembly, data science and what not just to reduce that to 1 minute is not really worth it.
I would add its a easy Scripting language. No compilation problem, richer that shell/bash makes it a powerfull choice.
And a really dont like it.
It is far more then that. It is a full up programming language.
I never understand why people think compilation is a barrier. But sure most python is not compiled.
If compilation takes more than a few single-digit seconds, IME, it breaks the development flow when you’re working on small fixes.
Having worked on large C++ projects, the solution to this issue is using a good IDE with an LSP. But it is quite a regrettable situation because setting up an LSP can be a difficult, and they also tend to break quite easily. Understanding how to make an LSP work is an important productivity skill in those kinds of positions.
And ccache or ninja. Something that reduces the amount of stuff that has be rebuilt.
Interesting, I had never heard of ccache before, though yes, all good build systems (CMake, Ninja, etc.) should cache intermediate object files.
But the projects I was working on were so large that even binary and unit test executables were so large that even they would take ~20 seconds to link. You can’t use caching to alleviate that buildtime cost unfortunately.
Python is largely compiled. All the pieces of a compiler are built into how it processes things. Almost nothing works on an interpreter model anymore, where each line is parsed and executed before handling the next. Unix-style shell scripts are one of the very few exceptions. I believe JavaScript also starts being interpreted in the browser in order to start executing immediately, but then a compiled version is swapped into the runtime as soon as it’s ready.
Depends on what you mean by compiled. Python typically translates to meta code and that is interpreted. True compilation to binary runs about 100x faster. Python is slow though there are faster versions and ways around it.
I mean that there are successive steps to transform the entire code into tokens, the tokens into an AST, and the AST into some intermediary or final form.
True compilation to binary runs about 100x faster.
No, it doesn’t. Take a look at any of the number of projects that have attempted to compile Java to native code over the years. You’d be lucky to see any substantive gain at all. They sometimes have a use for packaging everything up in a single distributed binary, but you don’t do it for speed.
Things like C and Rust are fast because the language semantics can be compiled in a fast way.
We will have to disagree on that. This is all problem spectific, but I have found C code integrated via ctypes, cffi, or by a C extension is over 100x Python alone. Interestingly Python, Numba, and Numpy together which is a more pythonic solution can get to those speeds too.
All of the other approaches I have tried are much slower: Nuitka, Cython, Numpy alone, PyPy, etc.
To get best speeds one has to compile for your specific architecture and enable things like vectorization, auto parallel, and fast math. Most default builds including libraries do not do that.
This is all problem spectific, but I have found C code integrated via ctypes, cffi, or by a C extension is over 100x Python alone. Interestingly Python, Numba, and Numpy together which is a more pythonic solution can get to those speeds too.
Of course you did. Those are changing the semantics of the language. For example, things like Numpy store arrays more like how C does it than Python. That makes all the difference, not merely compiling to native code.
Python has essentially usurped BASIC.
Yeah, you can use it both for full applications (web or desktop) as well as simple scripts. The flow of getting from something simple to a full blown application is pretty smooth and natural - better than just starting out in Java or C++ and taking at least an hour before you get anything that runs.
The libraries part is enormous. Researchers just pull up math engines, database access is a breeze, and so on.
You got a specific need, there is a library for it. It’s like C/C++ without the hassle.
Python is popular because it’s whitespace based syntax make noobs think it’s easy to read. This and it’s pre-installation on Linux made it popular amongst academics who embraced it for data analysis. This lead to a lot of data scientists embracing it and writing libraries for it which created a virtuous cycle in that arena.
And it’s a damn shame because Python, and it’s whitespace nonsense and lack of type system, is a horribly impractical language for building anything at scale.
It does make it easier to read. We primarily use indentation to match brackets, so clearly, indentation is the most important readability feature between the two, not brackets.
Try reading the same piece of code: without brackets, and then without whitespaces and tell me which is better.
Whitespaces as syntax force you to indent your code properly and not be misleading.
Brackets are infinitely easier because any IDE (and most text editors) have a dead simple linting plugin which auto indents for you and lets you know when you fucked up. Your editor can barely do anything with whitespace only because everything is valid syntax.
Also lemme take this opportunity to say fuck yaml for exactly this reason.
I literally do that professionally, and I’m telling you that brackets are inarguably better.
You are used to whitespace; I have literally spent months refactoring and upgrading a react frontend and a python backend and am telling you that brackets are a single character and far more predictable, and then your IDE / Linter / Formatter can reliably use them to fill in the perfect indentation and whitespace.
My first professional language was Python, but I have since tried a half dozen others and would never choose to go back to a whitespace based language unless there was a good reason.
I’ve written C, JS, PHP, and a few others. Today I write Python almost everyday and wouldn’t trade it for any of them. Maybe Rust, but not because of brackets.
White space nonsense. Yes and no. I do not enjoy tracking down white space issues until I remember the alternative. Matching brackets, writing begin/end statements, and worst of all looking at code that appears well indented until later you find it is not. and it runs totally differently then it looks. Similar issues with semicolons.
Pretty much everyone uses LSEs these days so frankly matters less either way most of the time.
Instagram’s back bone is written in python. I’d say that’s pretty scaled.
No, it’s not. It was rewritten in Facebook’s version of PHP when they bought them.
Here’s a blog post from meta, they introduced immortal objects to python to help with their Instagram scaling.
https://engineering.fb.com/2023/08/15/developer-tools/immortal-objects-for-python-instagram-meta/
Huh, TIL, I didn’t realize they kept the gateway servers in Python.
Typing thing is way over blown. What did suck before Python 3 was indeterminate type result from the / operator. You never know if it would be integer or floating division looking at the code. Now it is floating.
It’s not made for scale. Use C/C++ or something if you want scale.
Or you know, TypeScript, Go, C#, Java, Swift, etc. etc.
Python isn’t great at anything except for having a lot of data science libraries already written for it.
Not only data science libraries, there is a library for about anything. Which is not the case for your list of languages.
Edit: not all languages in the list.
When you understand how python works, it’s quite simple to use too, and has lot less clutter than say java or c#.
Not only data science libraries, there is a library for about anything. Which is not the case for your list of languages.
Java has an excellent ecosystem for libraries. And a much more mature one in most cases than Python. The Spring framework alone is simply amazing.
Go’s ecosystem is pretty good as well and getting better.
When you understand how python works, it’s quite simple to use too, and has lot less clutter than say java or c#.
The problem is that many python devs consider things like “type hints” and “classes” to be “clutter”. It takes a lot of discipline to write managable python. Being “newb friendly” is a curse. “stringly typed” crap does NOT scale well.
It can scale though. It parallelizes really well if you use queuing systems to distribute the load. You just have to make sure that the hot loops are in C/C++, and it is very easy to interface with compiled binaries via the C API.
It can scale though.
So can assembly. But it takes a tremendous amount of discipline.
Python’s curse is that it’s popular with “newbs” who think it’s okay to use dictionaries for everything and that type hints are “clutter”.
Agreed. I have seen a lot of Python code that was really painful to massage back into a more structured object hierarchy. Java certainly does a bit better in that respect, and as a language, it does a much better job of encouraging better practices, but I think it’s also largely due to the kinds of people that use those languages as well.
Instagram runs on django.
It has optional typing
It has optional type annotations for use by linters*
Good point!
It’s kind of crazy how problematic pip is, though. There are enormous ecosystems like conda, poetry, arguably Docker all built around “pip not working right.”
I see so many people want to install vllm or something with like a 95% crash and burn rate if they aren’t already proficient with Docker, complete with the spare disk space to basically ship a whole other machine.
Meanwhile, massively complex Rust or Go or whatever packages… just work. With the native tooling, for me.
To be clear, I like Python, and I believe many issues can be smoothed with time (like improving its JIT and maybe encouraging more typing in codebases). But pip and its ecosystem are forever cursed.
uv. Is like cargo for Python.
It doesn’t work with some projects, unfortunately.
pip is easily the worst thing about Python. But now that we have
uv
I would say the worst thing is the package/import system. I’m pretty sure only 1% of developers understand it, and it only really works properly if your Python code is a Python package.If you treat Python as a scripting language and just scatter loose files around your project and run them directly, it doesn’t work at all. Pain everywhere. Which is dumb as fuck because that’s like 80% of how people use Python.
Ugh yes I hate the import system too. I have to look it up every time and still don’t understand it, and it’s a hair away from messing up existing projects to the point where sometimes it does.
I want to love uv, but:
-
It breaks some random compiled C packages. I ran into this the other day, and the associated issue on the package was basically “shrug we see it’s breaking, this dev is doing some weird shit”
-
I’d prefer to use the optimized/patched build of Python CachyOS provides (and the optimized Python compiled system packages), though this is largely OCD.
-
It’s not optimal for some PyTorch stuff, which is its own little ecosystem nightmare
-
People used to shit on npm all the time, and I believed them, because I didn’t have experience with anything else.
Then I tried pip. Holy…I had to beg npm forgiveness for ever doubting it
Yeah.
I mean, npm deserves some healthy fear/skepticism, but everything is relative.
npm was bad, for a very long time. Then they fixed it, because they actually listened to other languages and did what they did. Python still refuses to do that. It’s quite insane because Ruby has had a solution for 15+ years at this point and Python could have directly copied it but refuses to. Python is absolutely the worst language I know of in regards to tooling.
I’m glad it’s not just me lol every so often I’ll think “I haven’t done a python project in a while I’ll try FastAPI” or something and I have so many issues just getting the env set up.
It’s so ridiculous that many projects don’t even support pip+venv (much less system python packages. shivers). They literally check if that’s what you’re trying and pre-emptively fail.
Some projects become impossible to run in any combination because some dependency (looking at you, sentencepiece) no longer works outside a narrow set of circumstances, unless you hand build some obscure github PR, disable all the dependency checks and cross your fingers and hope the wheel builds.
And I’m sorry, but I don’t have 200GB of space, tons of spare RAM, and an intricate docker passthrough setup for every random python project. I just have like four different 3rd party managers (conda/mamba, uv, poetry… what’s the other one? Ugh)
Because it’s actually good and also easy.
it’s as essy ss the code you’re maintaining is.
it has fewer guardrails than most languages, that would prevent you from writing shit code
The blog gives a few vague answers, none of which shed any light on how Python became so popular. If I had to guess, much of it’s popularity came from being embraced as a data analytics tool – which is honestly a great use case for an interpreted scripting language – and its subsequent adoption by academia, introducing it to an entire generation of CS grads.
Python has advantages and drawbacks like any programming language. It’s not my favorite language and it’s not my least favorite. It’s not going anywhere anytime soon.
I would argue it’s because it is Good Enough. The most popular solutions to things are rarely the optimum ones but the ones that are generally applicable.
For example, I could fight with bash’s unpleasant syntax or I could do it more easily (but less efficiently) with Python. Would it be as performant? Absolutely not - but the performance gains wouldn’t be worth the time and maintainability.
I’d say libraries is why it is popular. Also, I’m not a Python developer, and I don’t bother with libraries.
In the Python documentary they mention the early creation of numeric as an alternative for closed options like Matlab; which led to Python being used in the sciences and data processing. Then later it became the natural choice for machine learning in the early 2010s and the AI explosion of 2020+.
Presumably because it minimizes developer time in writing code and is easy to use and it come with great libraries. That is why I have been using it since 1998.
Edit: People use to think I was crazy using Python. It was interesting seeing people slowly get a clue over the years.
It minimizes greenfield development time and increases it later for anything at scale. It’s the mongodb of programming languages.
deleted by creator
???
Yes sorry. Wrong thread. Someone was talking about AI somewhere. For Python, I agree with your comment.
That doesn’t sound like much of a “gotcha”. The requirements for small stuff and big stuff are drastically different.
But isn’t mongo webscale?? °O°
Good thing python only gets used for small stuff then /s
…and people use MS Excel as a database, it’s not the fault of the tech that people force things to do things they’re not designed for.
Reason I started using Python. C takes too much effort, Excel VBA is nut over 100 lines. Matlab or Python would be the next step. Matlab is nuts too in many ways.
I started doing CS50 way back when and pretty much bailed when it got to C. I could understand it but it felt like I had to build the entire universe to do the simplest of things.
I like that with Python I can knock something together quickly enough to justify the time it takes. Having to do something manual and repetitious at work? Knock out a Python script to make it less error prone in future. If it took a lot of time I’d just have to suck it up and suffer through.
You seem to think I’m saying python shouldn’t be used at when all I said was it increases development time for projects at scale.
Fair enough, it read to me as a “gotcha” (as in “if python is do great then why can’t it…”). I’ve spent too much time on places like Reddit where every interaction is three seconds from becoming a knife fight!
Python is one of 4 key programming languages in world. C as a systems/performance/building block language (which I get has competitors). Javascript for node performance and web language. J as being the most powerful syntax/paradigm and best designed language.
Python has to be the most important due to all of the support it has, including C++ and other building block language/library imports that allows it to be the LLM integrator choice. A field that moves so fast, you couldn’t import libraries fast enough in another environment. Another shoutout to J is that its terseness is a good LLM fit due to less token consumption. But integrating with python is essential.
Because most people are lazy hacks.
What is so lazy about Python?
Dynamic type systems are meant for beginner/toy languages. Hacks that don’t care about understanding their own code tend to use Python. Their code is often riddled with bugs that they are none-the-wiser about.
If you write your code in Python, you might as well admit that you don’t care to understand what your code is actually doing.
You can write Python code about 5x faster then C. Add libraries even faster.
I mean… C is a low bar. You can write Typescript, Rust and Go code 5x faster than C too.
Go might be a close 2nd language wise but not the others. All of the above have a pretty narrow application range too. Even with a good lamguage, you would have to have the libraries too and pypi is pretty big.
All three of those languages have library ecosystems at least as good as Python’s. Typescript is just as easy to learn and as fast to write as Python. I don’t see why you’d think Python is faster. If I add up all the time I’ve lost to Python’s terrible tooling it’s quite a lot slower!
Rust is definitely harder to learn - I’ll give you that. But once you have learnt it it’s just as fast as Typescript and Python. Especially if your “fast to write” metric measures to when you program is correct.
Lazy is an overly harsh and judgemental way to put it (virtually all programmers start with some high level simplified language), but the sentiment arises because it’s syntax is designed to be easy for people writing code, but at the cost of people maintaining code.
The whitespace delimiters, the lack of type system, the lack of semi-colons … They’re all things that people who haven’t programmed before think make programming easier. In reality they all make in the wild production programs waaay harder to maintain.
There’s a reason that JavaScript has been surpassed by TypeScript for professional developers, and it did so remarkably quickly. All that ‘extra’ information that seems pointless for a new dev to express, in reality constrains your program, makes it more readable and understandable, reduces the amount of tests you have to write, and makes it easier for someone else to come in and make a change to it and be confident they haven’t broken anything.
Python’s type system is dramatically better than Javascript’s though. Try doing things like
'' + True
and Javascript will do incredibly stupid things. Python will just give you a type error. Also, look at things like==
vs===
in Javascript as well. That’s the biggest reason why Typescript replaced it overnight. Python has found a better balance between productivity and error safety.In my opinion, the biggest shortcoming of Python’s dynamic typing system is that you need to have very thorough test coverage to be sure that your code doesn’t have semantic errors (a lot more than, say, Java). It has gotten better with the introduction of type hints, those I don’t have much experience with them, so I can’t say how much.
In my opinion, the biggest shortcoming of Python’s dynamic typing system is that you need to have very thorough test coverage to be sure that your code doesn’t have semantic errors
That is a large shortcoming.
Sure, but as with all things, it can depend on a lot of factors. All code needs some degree of testing, though one could certainly argue that Python needs more than Java and Java needs more than Rust/Haskell/etc. So you could argue that the productivity gain of using Python is offset by the productivity loss of extra testing. It’s still hard to say which one wins out in the end.
People underestimate the cost of testing.
- It has to actually happen to be effective and is something that can be dropped under time pressure where something built into the language cannot.
- Test code is also code that is not guaranteed to be correct, and also incurs it’s own maintenance tolls
Removing the need for entire classes of tests cases is a huge win
Nah, I recently had to create a program that turned a bunch of extracted CSV files into an XML file for government reporting. I also had to parse some provided government XML files to add things into my output.
This was going to be run by non-technical people on any OS so I went for python because “install python, download this file and click on it” was easy. Python has a big standard library so I could do everything I needed in it. I was considering using Go but asking people to open the terminal and build something was probably a bridge too far.
Distribution usually isn’t considered a strong point for Python, though.
For other languages that build a static executable, the more expected method of distribution would be some automated workflow that builds artifacts for various os/architecture-triplets, that you can then just download off the project page.
Distribution usually isn’t considered a strong point for Python, though.
It depends. If it’s a simple script with no external dependencies, then it’s very easy to distribute. But if your application has external dependencies and you are trying to install it on your host (and you aren’t using docker or similar technologies), then yes, it’s harder than just shipping an executable or .jar file. The fact that Python’s standard library is so comprehensive helps a lot in this regard, but it only works up to a certain point.
It depends. If it’s a simple script with no external dependencies, then it’s very easy to distribute
it really isn’t. Try distributing anything that needs openssl under the hood (which is part of Python’s stdlib). I spent years deploying Python and Ruby tools next to each other to other devs machines. Python is incredibly hard to distribute, even to the same OS across a company. I really think that most people that think “Python is easy” actually haven’t ever tried using other languages and seen how easy it is there. Even Java jars are easier to deploy than Python, both if you’re making an executable and if you’re just having the user build or run the code directly. The only thing that is even close in difficulty from all the top languages for deployment is C/C++. Everything else is vastly easier. Part of that comes from Python’s ridiculous tooling (15+ different tools at this point https://chriswarrick.com/blog/2023/01/15/how-to-improve-python-packaging/) and part of it comes from the fact that Python chooses to bundle old or out of date versions of libraries causing conflicts in newer systems, like OpenSSL.
I use it as a beginner cuz it’s easy to use but guess I’m lazy since I didn’t start on a language that’s more in depth
As a beginner, you’ll eventually run into enough issues with your code that you will start to ask “is there a better way?” My answer will be: yes. Strongly typed languages are FAR superior because they force you to make your code robust and eliminate most runtime errors by default. You’ll eventually come around (unless you’re in a company with a hack culture or are surrounded by hacks that don’t know any better).