HACKER Q&A
📣 rlawson

Is ease in getting started the key for Python's success?


I am just an intermediate Python dev (but a senior Java dev with 20+ years). What I have come to realize is that Python is just as complicated as Java! However it is much much easier to get started with.

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.


  👤 isitmadeofglass Accepted Answer ✓
Python wins the triathlon by being second best in all the disciplines.

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#.


👤 carapace
I'm a Python fan, or was. Here's my $0.02:

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


👤 jjk166
Hammers are great when you're trying to hit nails, but you know once you start dealing with screws a hammer's not much better than a jigsaw.

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.


👤 brodouevencode
Of course. Low barrier to entry, and you can have a working application with minimal tooling. Setups and dependencies are flat and don't require a lot of knowledge on how they work (like the Maven ecosystem) or remembering a bunch of commands (like with golang) and adding dependency paths is easy (environment variables are very 12FA). The popular libraries and frameworks out there are very well written and always have been (quite unlike PHP and NodeJS) and aren't replaced every 6 months with Some New Big Thing (like with NodeJS). Then there's the syntax: it's just easy to pick up and flows naturally, and (as long as you follow PEP8) is aesthetically pleasing. It's a language you can ask a SE1 or sysadmin to write in and get decent results quickly.

👤 mw888
When I was getting started programming what I really wanted was to learn C or Haskell. When it came down to actually making some basic programs, it was always easiest just to use Python for it. It’s a good language on top of being ‘easy,’ and it’s easy to run and import libraries as well. It’s a really great little Swiss Army Knife.

👤 PaulHoule
Yep.

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.


👤 iforgotpassword
Old man yelling at cloud. I don't like python, so take this with a grain of salt. Or don't read it.

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".


👤 bmitc
I have software engineering experience, particularly in functional languages like F#, Elixir, and Racket. I find Python in no way easy to get started or simple. I worry that so many do because, from my point of view, it moves the needle of what's simple towards the complexity side of the meter. It's a concern because it sets the bar for what's simple way too low for people new to programming. So, they're going to go off doing "simple" things when they're not. Cf., the Python ecosystem. I have no trouble imagining that Python is a complete nightmare for large systems.

👤 mixmastamyk
Starting with the terminal and editor, yes quite easy. Then there’s the giant project monstrosity you mentioned.

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.


👤 atoav
What I really love about python is list comprehensions.

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.

👤 he11ow
I think the clue is in lazy people. I mean lazy in the sense of, "if you want to solve a problem give it to someone lazy". Python offers a huge ecosystem of useful code that mostly works and just does stuff.

If you're learning to code to get something done, the distance between "Hello World" and something useful is so, so short.


👤 ActorNightly
Not so much ease, as flexibility.

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.


👤 alexfromapex
Productivity is the main driving force of Python. You can prototype almost any type of app in it very quickly, with lots of libraries in the ecosystem to make use of, and it will have decent performance. If you need blazing speed you can write faster extensions in C. And it plays friendly across platforms, for the most part. People hate the white space but it enforces readable and maintainable code which plays into making teams productive.

👤 QuadmasterXLII
Python's feature is that it is so slow that you cannot write inner loops in it. As a result, people were dragged kicking and screaming into vectorizing their code, even before gpu accelerated array operations were common. Then, when gpu accelerated operations arrived, python was sitting on a gold mine of idioms for vectorizing _any_ loop and programmers who instinctually vectorized every loop.

👤 bravetraveler
I think there's something to it. I wore myself out on 'proper' development (C) nearly two decades ago. I just recently picked up Python because I was reaching the limits of BASH but didn't want to dive too deep.

Getting started hasn't hit that "ugh I hate doing this" nerve I typically get from writing code


👤 profwalkstr
I also have the same opinion as you do. I’m also a Java programmer who develops in Python sometimes. It’s easy to start programming in Python, but Python is a lot more difficult than Java to master. The Java language is a lot smaller than Python, you can keep the whole language in your head, unlike Python.

👤 aristofun
Nope.

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.


👤 throwaway_4ever
No, Python is not the easiest to get started with due to the configuration in the beginning involving virtual environments and different Python versions from system (venv, pyenv, conda, and all the differing tools and tutorials one comes across).

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.


👤 sidcool
Yes. And JavaScript too. Also the availablity of tutorials and help

👤 oweiler
Java nowadays doesn't require 'a lot of tooling' to get started. jbang.dev makes it extremely easy to get started with Java, with basically no setup.

👤 faangiq
Python syntax is very elegant. It appeals to people with good taste. Try writing a dict comprehension in Java.

👤 mountainriver
One of the best entry points for python is Jupyter. In teaching people programming this is invaluable.

It also reads easy, boots quick, and is on every machine