Java is aimed squarely at professional devs and requires a lot of tooling and support. Python requires almost nothing (interpreter + editor + a basic understanding of lists/dicts and control flow) to get started.
But do a big project with a large team and you'll quickly discover the rough edges and debates - a few that have come up lately for me at work - typing or no typing, oop or functional? pytest or unittest? poetry vs pipenv vs ... ? Occasional runtime errors. Project layout and organization (makes me miss maven sometimes). Don't get me wrong - I really enjoy working in Python but I believe it would be a niche language if it were not so approachable to the beginner.
Matlab is better at linear algebra, R is better at statistics, Mathematica is better at notebooks, C# is better at desktop applications, C is better at low level, JavaScript is better at web, Perl is better at job security. And so forth and so forth. But if you ever spent time with python in any one of those fields and though “ok, I don’t hate it but still prefer the leading player” and then switch to doing something else and you have the option of using the second best tool, or spend a ton of time learning the best, your bound to just go “I’ll just use python”
> discover the rough edges and debates - a few that have come up lately for me at work - typing or no typing, oop or functional? pytest or unittest? poetry vs pipenv
None of that has anything to do with python, it’s just the typical team bike shedding debate about what tools and features to use. There’s always going to be the typed vs untyped debate. But normally that’s settled when you decide to use node, or when you decide to use rust. Using one unit test framework or another is always potential discussion independent of python, and you’ll always need the team to deal with versioning and dependencies.
If your “rough edges” in python is literally just that your team can’t agree on things, your not going to have it any easier by switching to Rust or Perl, Julia or C#.
Python is a very complex dynamic system that pretends to be a very simple dynamic system.
Before Python 3 it was (on the surface) very simple and easy to learn. It was often called "runnable pseudocode".
However, as you and I and many others have seen, once a Python script grows beyond a certain size/complexity the dynamic simplicity begins to become a liability rather than an advantage.
BEGIN RANT
After Python 3 the language has become much more complex on the surface level. Also, features like type hints etc. that make it more tractable to large team projects have been added.
These developments move Python away from it's sweet spot or niche of optimal applicability. The closer Python becomes to being a slow interpreted version of Haskel or OCaml (or Julia, etc.) the more irrelevant it becomes, eh?
END RANT
No tool is right for every job. Python's good for quickly writing relatively simple programs. Writing relatively simple programs turns out to be an incredibly common use case.
The fact people are so willing to drag python out of its comfort zone into extremely different use cases instead of learning other languages better suited to those tasks is a testament to just how valuable a simple and readable language is to most people.
I think Python is particularly suitable for the "non-professional programmer", somebody who has some other skills and uses a computer to put those skills on wheels.
I never understood the beginner friendliness much.
For me it already starts with the concept of significant whitespace. It's stupid I hate it. Read a more involved function that might have a depth of 3 or 4 nested loops and ifs and suddenly you can't tell if it's closing 2 or three levels if the start of the last block is a little further away. "Use an ide" - ok you first told me it's a simple and beginner friendly language and then I already need a fancy ide to be able to read the code.
"It helps beginners to format the code properly by preventing them from messing up the indentation wrt logic" - ok fair.... You want to make the user write clean code from the beginning by giving them no chance but to do it right. But then we get to classes. There are no visibility modifiers! All methods are public. Suddenly all good intentions to guide the apprentice to do the right thing are out the window. You never learn to think about internal state, helpers and public methods that change the object's state in a consistent manner. You can reach into the object and fumble with internal state. "Ok just make it clear through naming which methods are in-" STOP! Yes that's what an experienced programmer might do when they already understand those concepts in the first place. But again it's contrary to the whole significant whitespace argument.
Oh boy, and then the explicit self parameter. Just why? It's there in the method's definition, but you don't need to pass it when calling (unless you would call it as a static method on the class and... just why)? I don't see how this asymmetry is better than just having that implicit magical this-pointer around in other languages. Sure it's not a make it or break it, but it feels so clumsy and just bad, like "hey that makes implementing classes a bit easier so lol f- it".
The sizable stage in between is what most fail to mention, pyflakes. You can get very far with just pyflakes and some tests if you’re a good developer. It finds the first 80% of bugs with very low effort. Most of my projects need nothing else.
The biggest will benefit from flake8 and typing as well, but there is a bit of a cost in complexity. Paid for with piece of mind.
Instead of
processed = []
for part in unprocessed:
if part.tag in ["good", "circled"]:
processed.append(part.name)
You can do processed = [part.name for part in unprocessed if part.tag in ["good", "circled"]]
In one line.
If you're learning to code to get something done, the distance between "Hello World" and something useful is so, so short.
In the end, the thing that matters the most for software is being able to get logic into code as efficiently as possible. This includes being able to write concise code, being able to execute it and see results, debug it efficiently, use libraries easily, and deploy it to production. Python has all of this.
The rest of the stuff, like strong typing, memory safety, e.t.c are at best academic. The supposed advantages of those just don't hold up once you start to look into the real world. Linux, which runs on most devices that support an os hardware wise, is written purely in C. Python is used as a backend for very big projects like Youtube, Instagram, Spotify, e.t.c. Its also used to run Openpilot (https://github.com/commaai/openpilot), which has performance on par with Teslas autopilot.
Meanwhile in Java world, with strict typing, you have egregious vulnerabilities like log4shell, amongst others (https://java-0day.com/).
Language evolution is also a thing to look at with this stuff. The more "strict" you try to make a language, the worse its going to become as people are necessarily going to find hacks around it. With java, type safety strict features like having getters and setters get abstracted away behind an annotation processor that hacks the AST (Lombok), and thats not only considered ok, but is encouraged to be used. With C++, template metaprogramming got extremely out of hand with https://www.boost.org/, where the error messages for one thing used to be pages long. Rust manage to sneak this under the radar with the unsafe clause, which is going to see standard use in many codebases, thus negating any of its advantages.
In the end, good code comes from good developers, full stop. Every codebase will necessarily have tests for production deployment, and anything that language features don't catch during compilation or static checking can be checked with testing if you have developers that understand what they are doing and can write appropriate testing frameworks.
And based on that, its pretty attractive to use Python especially when you consider developer time. And the flexibility means you can write your code in different forms to suit your use case, where it be OOP with MyPy type checking, functional, imperative, or super complex if you want.
Getting started hasn't hit that "ugh I hate doing this" nerve I typically get from writing code
Just occasional facts that Google founders knew and used it + it has been used in some academia played a crucial role in its promotion.
It has nothing to do with the propeties of the technology as often the case (js is another example).
There are better languages, ruby being far superior to python in devx etc.
No, the key to Python's success is that it's the most English-like language. It's succinct and reads very well. While most langs use &&, ||, and !, Python uses 'and', 'or', 'not', 'in', 'with', etc. This is a huge boon for novices that aren't comfortable by the sudden influx of symbols compared to natural language. Thus, it's adopted by most intro to programming university curriculum and leads to popularity by virtue of a lang many people have experience with.
It also reads easy, boots quick, and is on every machine