Live data from Hacker News

If AI writes your code, why use Python?

medium.com

531–540 of 1001 posts

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

#531

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…

> 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. But it's LLMs that read it not humans. At least that's the trend > Use a language that has a large training set so the LLM can be most efficient. It's pretty efficient with Rust.

But plenty of humans like to be able to read the generated code and understand / edit that.

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

#532
I had gpt-5.5 translate microgpt.py into a C++ version recently. I had to steer/convince it to use data oriented design to avoid excessive pointer chasing, but the end result was as expected: Now 500 LOC instead of 199, but speedup was 100x. That speedup is definitely worth doubling the line count. And frankly, modern C++ can read very nicely, even compared to Python.

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

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

The "other than that" is whitespace, not brackets. Whether that's a big deal is up to you, but the carry on effect of that is that the code is indented the way the control flow interprets it, so there are no bugs from misplaced braces. (Plenty of other bugs for other reasons, unfortunately.)

Python and C are the only language in which I have experienced that class of bugs. And that is due to if statements without brackets in C and because Python has meaningful indentation which people have accidentally messed up when refactoring.

And today with autofotnatters I think only Python is still vulnerable.

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

#534
post #479

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

"whitespace, not brackets" from a sibling comment touches on it, but a lot of people, beginners especially (but not uniquely), are put off by symbols when reading code. Python is less symbol-heavy than most languages, by using whitespace and syntax and words (eg. `and` not `&&`, explicit `lambda x:` rather than `x =>`) in their place. It doesn't go so far as COBOL as to be cumbersome, but far enough to make a difference to a lot of people.

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

#536
post #533

Earlier quoted context omitted.

The "other than that" is whitespace, not brackets. Whether that's a big deal is up to you, but the carry on effect of that is that the code is indented the way the control flow interprets it, so there are no bugs from misplaced braces. (Plenty of other bugs for other reasons, unfortunately.)

Python and C are the only language in which I have experienced that class of bugs. And that is due to if statements without brackets in C and because Python has meaningful indentation which people have accidentally messed up when refactoring. And today with autofotnatters I think only Python is still vulnerable.

If you are messing up indentation accidentally during refactoring there is either something wrong with your tooling (including your text editor) or you are letting things get too far out of hand before starting the refactoring.

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

#537

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…

Python is locally readable. Reasoning about larger systems in Python is where things get really hard, because you have to describe how many small individually readable things interact with each other in a very limited vocabulary.

I’m curious about the design space of languages & frameworks which are lower level than LLM prompts but higher level than Python, Ruby and Common Lisp.

Do you have any recommendations for systems where reasoning about large systems is easier than in python?

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

#539

Earlier quoted context omitted.

The "other than that" is whitespace, not brackets. Whether that's a big deal is up to you, but the carry on effect of that is that the code is indented the way the control flow interprets it, so there are no bugs from misplaced braces. (Plenty of other bugs for other reasons, unfortunately.)

I find brackets help me understand structure from a distance much better than whitespace. Misplaced brackets seem like a thing from the past to me when we didn't have IDEs. I don't remember ever having a bug due to that.

> I find brackets help me understand structure from a distance much better than whitespace.

I can't imagine how. Whitespace physically lays out the block structure on the screen; braces expect you to count and balance matching symbols, and possibly scan for them within other line noise.

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

#540
post #354

Earlier quoted context omitted.

and yet dynamically typed elixir wipes the floor with go. https://github.com/Tencent-Hunyuan/AutoCodeBenchmark/blob/ma...

LLMs get ridiculous with elixir, especially with the repl, runtime, and ability to hot reload / directly test functions. It's really surprising to me it hasn't caught on more but I guess you have to see it to believe it.

built my startup in elixir and can concur. elixir has a relatively consistent syntax that makes for a pretty good target for llms.

In my opinion, the only thing holding elixir back as an llm deliverable is that there's not as much training data for llms to work with.

Of course if we had a new AI that could be trained on a minimum of existing training data, common lisp would absolutely beat out everything else. everything you mentioned about elixir (repl, runtime, and ability to hot reload / directly test functions) are possible and were invented in lisp with an AST instead of a syntactic language as the ultimate build artifact. CL lets you recover from exceptions and rewind the stack before reloading your fixes and continuing. I can't even fathom the workloads an LLM could conceive of working with that.

Post reply on HN