Live data from Hacker News

If AI writes your code, why use Python?

medium.com

921–930 of 1001 posts

Re: If AI writes your code, why use Python?

#921

One obvious reason is Python's extreme readability, it has often been described as being as close to executable pseudo-code as one can get. If you're using an LLM to write code I think the rules would be 1. Use a language you know really well so you can read it easily, and add to it as needed. 2. Use a language that has a large training set so the LLM can be most efficient. 3. Use a language that is easy to read. If…

Haskell is more readable. It looks just like pseudocode. Change my mind.

If Haskell coders could get past their obsession with naming all the important functions using only punctuation characters that might be true.

Re: If AI writes your code, why use Python?

#922
post #887
post #843

Earlier quoted context omitted.

You joking? - strong typing - real concurrency (heaven forbid you want a background task without having to spool up an external message queue and worker) - immutability - limitations in error handling (sort of just typing really) - limitations in nullability (also typing) - memory layout is usually hidden or abstracted away - no actual private methods or classes That's far from a complete list, but maybe you're takin…

> strong typing Python is a strongly typed language. Strong and Static typing aren't the same thing.

You are obviously correct, but even if we let aside parent's confusion about strong/static typing, it's a weak argument.

Python does provide type annotations and extensive tooling to make static analysis, so this whole "missing abstractions to help with understanding" is simply false. You can even setup a python project to make annotations mandatory.

There are plenty of things to criticize about Python - performance, packaging and multiplatform distribution come to mind - but to think that it is missing the tools to help build and understand complex codebases is frankly absurd.

Re: If AI writes your code, why use Python?

#923

Earlier quoted context omitted.

>Lack of strictly enforced static typing make agents fail much sooner with Python. Just tell your agent "Use type hints. Add a pre-commit hook to run ruff, black, mypy, and pytest." It will save you 99% of headaches.

I've tested many flows involving linters. Results are far from ideal - agents tend to work around linters, mass-add ignore annotations, etc, especially in situations when fixing one warning/error triggers another (and that happens regularly).

LLMs really are just like an intern in their first coding job!

Re: If AI writes your code, why use Python?

#924

One obvious reason is Python's extreme readability, it has often been described as being as close to executable pseudo-code as one can get. If you're using an LLM to write code I think the rules would be 1. Use a language you know really well so you can read it easily, and add to it as needed. 2. Use a language that has a large training set so the LLM can be most efficient. 3. Use a language that is easy to read. If…

I've been using Rust more because of Claude, but I mostly do C# / Python otherwise. I can read Rust, and understand it, but I don't have the patience to fight the compiler, or the liberty of free time. I do however have in my brain plenty of architectural ideas I can convey to a model and get back a sound program.

Re: If AI writes your code, why use Python?

#925
Right, you should use Lean or Coq. They are cleaner mathematically, which means AI has a better chance with them. And you can have the AI write proofs about their correctness. The proof-checker can verify the proofs and give you more trust in the AI’s work.

This isn’t foolproof - you still have to understand what was proved. And it may take some work to understand the unproven parts of the code. But I believe this is the path forward.

Re: If AI writes your code, why use Python?

#926

Right, you should use Lean or Coq. They are cleaner mathematically, which means AI has a better chance with them. And you can have the AI write proofs about their correctness. The proof-checker can verify the proofs and give you more trust in the AI’s work. This isn’t foolproof - you still have to understand what was proved. And it may take some work to understand the unproven parts of the code. But I believe this is…

Poe's Law

Re: If AI writes your code, why use Python?

#927
post #479

Earlier quoted context omitted.

I never really understood what exactly is so readable about python. I've been developing in Python for 8 years now, and before that I was a C# developer, and I don't find Python to be that more readable. Sure there's less ceremony, and yes, you can have your project going with just a single file, but other than that...?

I think the meme come from the fact that in 00s and early 10s most people looked at Python code coming from C++ and Java. In Java bad OOP conventions were commonplace, like everything using getters/setters, deeply nested class hierarchies and insane patterns like AbstractSingletonProxyFactoryBean. It got impossible to figure out what's going on. C++ just got every possible feature that badly interacts with each other…

The AI boom has really carried Python up with it, but it was quite popular as early as the mid '00s. I remember grumbling in college around that time that the CS curriculum was shifting from Java to Python, because I didn't like Python and thought it was a worse first language.

Incidentally, even though I still hold those opinions, I can admit that history has solidly shown them to be unfounded.

Re: If AI writes your code, why use Python?

#928

Earlier quoted context omitted.

Surprisingly, LLMs are actually much worse at reasoning in Python than other common programming languages for agentic coding tasks. Data here: https://gertlabs.com/rankings?mode=agentic_coding

> Data here: https://gertlabs.com/rankings?mode=agentic_coding Oh wow, we got "tribal domination", "market simulator" and "adversarial customer service". I don't know what those are but it sure sounds like big torment nexus milestones Maybe we could at least play nicer games like hackenbush and act surprised when there's some wicked use-case that's isomorphic. EDIT: Ok fine. I like "Rubik's Cube Chess" a lot. Never h…

Not formally analyzed -- in practice, we see a lot of repetition/draws from code submissions. Our version is custom, and uses more pawns, which can move in any direction but don't upgrade to other pieces. We try to include just as many cooperatives games as competitive games, but both are important for measuring model ability in the real world.

Re: If AI writes your code, why use Python?

#929
"why use python " is a question I have asked myself for as long as Python has existed

Too capable for a job control language, interesting objection, but if a job control language is too capable, it becomes a job implementation language...

Too slow to implement applications. So many examples of big balls of Python code creaking and struggling, slowly. Just one example: my homeassistant instalation running three lights overwhelmed a Raspberry PI 4 causing it to crash once a week.

To me Python is a poster child for "popularity is not quality".

Post reply on HN