Live data from Hacker News

If AI writes your code, why use Python?

medium.com

931–940 of 1001 posts

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

#931

Earlier quoted context omitted.

You'll learn Rust faster with AI and should be able to solve it yourself. You're unlikely to wind up in such a situation though. The design work Claude does in Rust is really sensible and idiomatic, and I really don't think you'll be unable to refactor or redesign things. Claude is extremely good with Rust generation, refactoring, and manipulation. I'll go as far as to say that AI has removed most of the complaints p…

Come on now, how do you learn anything if you just tell claude to do something and feed it error messages?

Ask Claude to teach you about the language instead.

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

#932

Earlier quoted context omitted.

I dunno, as someone who doesn't program in Python, I find dunders to be very confusing. Like, how is this readable? _foo foo_ __foo _Foo__bar __foo__ foo__bar All of that is valid Python, and some of those forms mean different things depending on where they are used.

The second, fourth, and sixth form is options aren't used AFAIK. Otherwise, a leading underscore indicates a private method but isn't enforced. A double leading underscore is also a private method but is "enforced" by giving it an unpredictable name. Double underscore (on both sides) means the function is digging in to python's API, like if you want to give a class some behaviour with + or = or []. It's not trivial,…

The second form has no built-in meaning, but is frequently used in the wild. Often in local variables to avoid shadowing builtin types (`id_ = get_id()`) and in various libraries. Out of the top of my head, ORMs also use it to mangle reserved names.

edit: I googled a bit and PEP8 explicitly says "Thus class_ is better than clss". and "single_trailing_underscore_: used by convention to avoid conflicts with Python keyword, e.g..."

The fourth form is the mangling used for __x names internally (__x field in class Foo is actually _Foo__x

I don't know where GP saw sixth form, but considering all other forms are from real-world usage, someone probably uses it too.

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

#933
post #596

Earlier quoted context omitted.

Having used Python on and off for 20 years, my experience with LLMs writing Python has been mixed. I don’t think that’s necessarily because of a low-quality dataset, but rather because Python’s applications are so broad and the language has gone through several paradigm shifts over time: sync vs. async, typed vs. untyped, scientific Python looking very different from web application code, some people really wishing i…

> Having used Python on and off for 20 years, my experience with LLMs writing Python has been mixed. I don’t think that’s necessarily because of a low-quality dataset, but rather because Python’s applications are so broad and the language has gone through several paradigm shifts over time If there’s one language that is the prime example of this, it’s C++, and according to this benchmark it ranks incredibly high. I’m…

The more filters you apply (single model and single language, especially if you also filter by pipeline like agentic vs one-shot), the fewer samples, so there is variance. Known limitation that is inevitable with any finite budget. This is why we are selective about adding more languages because it will dilute the amount of samples we can run per language per model. But the aggregated statistics hold up well and are very consistent in our testing.

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

#934

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 also has a rather high number of footguns, which is not a feature of other equally-capable languages.

How to Shoot Yourself In the Foot:

https://www.eng.uwaterloo.ca/~comp03a/misc/humour/shootfoot....

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

#935

It's strange to me that this blog post was written in English. If AI is available, why aren't we all communicating in Lojban? [0] It's an obviously superior language. What does it matter that many people already communicate in English and much of computing depends on that language? AI doesn't care about that. Plus, if you ever need to edit Lojban without AI, you should be able to pick it up in a few weeks, right? [0]…

AI has not been trained on Lojban. And furthermore, this article is almost certainly primarily intended to be read by humans directly. I understand you're being facetious, but I'm not sure what point you're trying to make about programming languages in comparison.

[dead]

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

#937

I haven't read the article (because I hate Medium) but I reckon the biggest reason why LLM-assisted projects use Python is because there is a metric buttload of python code on the web to be slurped up and used as training fodder.

Now I'm curious: is a metric buttload much larger than an imperial one?

a metric buttload is exact 1.114 imperial heaps

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

#938

Earlier quoted context omitted.

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.

That’s just ordinary unfamiliarity with a language.

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

#939

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.

I tried that on a recent project. My conclusion: don’t use Python if you value your sanity. Ruff etc. are not type checkers, they’re the cargo cult equivalent of what a Python developer imagines a type checker would be like if they had one.

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

#940
post #641

Earlier quoted context omitted.

> AI makes Rust development go 10x faster. The borrow checker isn't even an issue. It's invisible now. What happens when things break and the AI agent can't fix it?

You'll learn Rust faster with AI and should be able to solve it yourself. You're unlikely to wind up in such a situation though. The design work Claude does in Rust is really sensible and idiomatic, and I really don't think you'll be unable to refactor or redesign things. Claude is extremely good with Rust generation, refactoring, and manipulation. I'll go as far as to say that AI has removed most of the complaints p…

> AI has removed most of the complaints people had with learning or using Rust.

Not even close. The problem is not only writing the code, it’s being able to review and understand it. An AI can’t magically transfer that knowledge into someone’s brain, they have to develop that knowledge themselves.

I’m dealing with this currently with a team of ML developers. A couple of them like Rust, the rest don’t know it. They’ve tried to submit AI-written PRs, but typically they’re incredibly over-engineered, e.g. changing 40 files when the feature really only needed changes to one or two. Or else they have other problems that the prompter wasn’t experienced enough to recognize.

Post reply on HN