Live data from Hacker News

If AI writes your code, why use Python?

medium.com

671–680 of 1001 posts

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

#671
I am surprised that Python is being "threatened by AI writing code", as per the article, but that the said-article never wondered if the AI was more efficient writing in Python or what else.

I mean, the Python ecosystem is qualitative and generally well-documented. What if the AI spent 30% less tokens generating code than e.g. in Rust?

Or is there a kind of information theory where, given the same goals / tests, the AI will spent roughly the same in any language?

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

#672

Really glad to see someone asking this question. After building a fairly significant AI tool using Python tools, I really wish AI/ML tools would all be rewritten to use an actually performant language - say, Rust - without transitive dependency hell on all the package versions.

The vast majority of Python's AI/ML ecosystem is already written in C/C++ and uses interop glue to call it from Python. But agreed on the transitive dependencies, it's a nightmare

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

#673
post #533

Earlier quoted context omitted.

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.

Ah, the old "you're doing it wrong" argument. Moving code from one place to another (copy/paste from online or just from one file to another) is a fairly common source of bugs for a lot of people when it comes to Python. At some point, it becomes clear is an issue with the language, not the people.

I enjoy Python, but the significant whitespace is _not_ one of the reasons.

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

#674
post #21

You can of course use any language but here is my advice: you should use the language that you know best to make your life as uncomplicated as possible when you want to understand what the LLM was creating. Remember, you are the judge whether the code is OK and if you use assembler you might get really performant code, but can you trust it? Of course it might be a good incentive to learn rust or go. Or challenge your…

If I were a billionaire I would bought enough tokens to rewrite all public source code in F# or OCaml. :)

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

#675

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…

My preferences are always Go first and Python if there are specific libraries that make my life easier. Go is a simple target for LLMs as the language has changed very little and with the Jetbrains go-modern-guidelines[0] skill the LLM can use the handful of recent additions effectively And with Python there are things like ruff and pydantic that can enforce contracts in the code. [0] https://github.com/JetBrains/go-…

The folks I work with rave about how well the LLMS work with Go.

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

#676
post #14

Python has a much more mature ecosystem than Rust, especially for AI/ML stuff. I ran into a rust crate that purported to do a certain ML algorithm but did not do it correctly. I managed to write a replacement with Claude though. I do think enforcing correctness at the type system level is a good idea for AI, which is why I often choose languages like C# and Rust over Python. However, for some things Python is definit…

I think the AI/ML ecosystem is a bit of a mess overall, things tend to work out of the box in Python because that's what everyone targets, but it doesn't necessarily say that much about maturity and robustness.

In Rust you can use many C++ frameworks like libtorch or ONNX or specialized libraries (llama.cpp, whisper.cpp ...) via their bindings. Native projects such as Candle or Burn are not feature complete yet, but I assume they'll eventually get there and drive bigger communities compared to C++.

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

#677
Although well orchestrated agentic workspace could write most (if not to say 100%) of the code for me, I'd still feel more comfortable to have it use a language that I feel myself confident with. Not necessarily because I'd want to read through the code. But still, occasionally it is easier for me to check something out by looking directly into the code rather than wasting time and tokens to haggle with AI model on some nitti-gritty detail. And, more importantly, I want to be able to understand the maintenance of and be able to troubleshoot the deployment stacks related to the programming language -- their virtues, their quircks, their security postures etc etc etc.

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

#678

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…

tbh python seems really unreadable to me, and i'm saying that as someone who's first [non-Scratch] programming language was that. stuff with syntax closer to C or javascript seems easier to see [C?] where stuff starts and ends

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

#679
post #584

Earlier quoted context omitted.

Haskell would be my vote, and Rust too, actually, both because of their very strong type systems. The type system lets you very quickly figure out what something is before you figure out what something does , and it turns out that separating those two concerns as hard as those two languages do often results in doing the whole one-two punch faster.

Haskell does not qualify for a large training set, though. (Nor for readability in my opinion) I think I have never seen haskell software made wih LLM's but well, aside from university, I have not seen Haskell code at all. (Also Haskell purists I would associate with people who avoid LLM's) I would rather go with Rust given these choices. But I have good results with typescript (or javascript for simpler things). Rea…

I used Claude to generate Haskell and it works really well. Claude struggles sometimes with respecting abstraction boundaries, but Haskell enforces parts of those boundaries in its type system better than a lot of other languages (if a module can’t do IO, for example).

Works well, in my experience. Sometimes the agent does weird stuff that you have to rewrite, but I get the sense that this happens in any language.

Maybe Haskell’s training set is not large enough, but it seems to work despite the smaller training set.

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

#680

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 amazing for scripting. Python is terrible for writing big systems. Projects whose V1 is written in Go/Rust/C++ don't normally go out and re-write V2 in Python. The reverse is really common. Even many famous Python packages are now Python wrappers. https://ashishb.net/programming/python-in-production/

If you use the typing system (which I do religiously) Python becomes a lot easier to reason about in larger projects it also makes linters and refactoring tools easier to use.
Post reply on HN