Live data from Hacker News

If AI writes your code, why use Python?

medium.com

781–790 of 1001 posts

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

#781

Earlier quoted context omitted.

> Go has a huge stable standard library no other language even comes close to Well, Java and Python do.

Python has a quite random collection of stuff, and it's often quite low quality and people don't use it anyway. I wouldn't say it is close to Go. I haven't used Java for a decade or so but as I recall its standard library was pretty bare bones (similar to Rust). Apparently C# has a pretty comprehensive standard library but I've never used it.

>Python has a quite random collection of stuff, and it's often quite low quality and people don't use it anyway. I wouldn't say it is close to Go.

People who came into Python for ML and Data Science, and just care for their array and ML libs maybe.

But long time Pythonistas absolute use Python's standard library - and it's hardly "quite low quality". "Batteries Included" is one of the community slogans.

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

#783

No reason, unless the project is simple. The more you can offload onto your compiler/typer - the shorter is the feedback loop, the better agents work. Lack of strictly enforced static typing make agents fail much sooner with Python. In my opinion, Rust and Scala are the best targets for agentic flows - and, coincidentally, they have the most advanced typers among mainstream languages. But any statically typed languag…

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

The list of tools that Pythonheads present as a definite solution to their problems changes every year, yet the results are still far behind Rust/Scala/Kotlin/C#.

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

#784
post #782

If ai writes my code, the code is the documentation/context. Why use any programming language, if we’re going to be maximalists?

Because programming languages are the clearest way we can write down instructions for computers to execute without ambiguity.

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

#785

But under this frame, it appears that the developer's task involves prompt engineering. This is not the case. Even if an agent generates 90% of the code, each and every diff is going to be in my review queue. Code readability of Python isn't an advantage during write; it's an advantage while reviewing. As an agent generates a piece of code, I will have to read the code, comprehend the code, and determine whether it d…

> Code readability of Python isn't an advantage during write; it's an advantage while reviewing. This is completely subjective though. I personally find that Python's lack of static types makes code very difficult to reason about. Yes, some devs will write decent comments and name things in a way that's easier to read, but most devs are lazy (myself included) and things get out of hand quickly. But this is also a sub…

I would go even farther and say that static types are a tool designed specifically for a code reader.

When you're writing the code, you know what the types are, as you literally just created/wired/whatever them. Static types become a benefit only when you visit code without that fresh context. For instance, third party libraries are far easier to use when the interfaces are typed.

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

#786
The static vs dynamic language debate is decisively over and static has won. I called this out back in 2023, and I've only become more convinced since then.

Statically typed languages are easier for the reader because you can see the types and quickly jump to their definitions (or even just hover over them in some IDEs).

They're easier for the AI because they provide natural guardrails and feedback to guide it, as well as much more confidence to the programmer that the code does what it is supposed to. Rust even provides strong guarantees about correctness across threads, which is so helpful to multi-threaded code.

The fact that they run faster and use less memory is just icing on the cake.

Even just last year the AI could not handle the borrow checker well. Today I think it is better than me at handling tricky lifetime issues that ocassionally happen in multi-threaded Tokio code. I've been doing almost 100% Rust development over the last 3 years, and the experience is now very good. I don't write code by hand any more, nor do any of the 50 engineers where I work.

I imagine it does quite well with Go, since it's such a simple language. And Go is very readable, and compiles very fast. If you can afford the GC in your problem domain, it might be a good fit. You would have to be so careful with introducing concurrency, because it would be so easy to introduce race conditions that both the AI and human reviewer might miss. I haven't tried to use Go in anger yet with LLMs, so this is all just speculation.

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

#787

But under this frame, it appears that the developer's task involves prompt engineering. This is not the case. Even if an agent generates 90% of the code, each and every diff is going to be in my review queue. Code readability of Python isn't an advantage during write; it's an advantage while reviewing. As an agent generates a piece of code, I will have to read the code, comprehend the code, and determine whether it d…

> Code readability of Python isn't an advantage during write; it's an advantage while reviewing. This is completely subjective though. I personally find that Python's lack of static types makes code very difficult to reason about. Yes, some devs will write decent comments and name things in a way that's easier to read, but most devs are lazy (myself included) and things get out of hand quickly. But this is also a sub…

Python has type annotations now [1] that type checkers, IDEs, etc. can use.

[1] https://docs.python.org/3/library/typing.htmlhttps://docs.py...

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

#788
The article gives zero examples of someone even attempting to transpile something from Python.

Numpy is two decades old. The lesson of "don't write everything in Python" is old news and LLMs just add a little momentum to that.

Glue languages will always exist and Python is the best at it.

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

#789

Earlier quoted context omitted.

Just use Go. LLMs have seen a ton of it, they write it well, it compiles practically instantly, and it has all the advantages of a typed compiled language. I created a big Python codebase using AI, and the LLM constantly guesses arguments or dictionary formats wrong. Unit tests and stuff like pydantic help, but it's better to avoid that whole class of runtime errors altogether.

But what is the selling point for Go? I get that it is allegedly hailed to be a simple language with basically no batteries included, but why is that a selling point? Does Go excel at anything no other language does?

Golang truly excels at cross compiling.
Post reply on HN