Live data from Hacker News

If AI writes your code, why use Python?

medium.com

561–570 of 1001 posts

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

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

I agree, especially very "pythonic" structures if overly shortened are hard to decipher especially if you don't use or read python on a regular basis.

Often times when I am reading a medium or advanced python codebase I need to look into the function definitions and operator documentation to understand what is supposed to be returned. Where with C-like languages I feel it is easier to build that context because there is more context written and less tricky syntactic sugar.

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

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

[dead]

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

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

Other than that? Exactly that!

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

#564

Earlier quoted context omitted.

Why use Go when you can use Rust?

So I can test my feature today instead of waiting until it finishes compiling tomorrow.

this is the top reason for a reasonably complex project, but it can be worked around by preplanning crates.

the other reason is if you really want async as is in vogue nowadays, function coloring - but this is rapidly becoming irrelevant, see article.

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

#565

Earlier quoted context omitted.

Yeesh, is "never reading the code" really the modus operandi we want from AI? Microsoft, for all their warts, at least had the compassion to call their AI product "Copilot", suggesting we have some residual agency in whatever it is that it produces.

Let's say you get access to a microservice from another team in the company. Do you read through and audit every line of code? What if it's from an external vendor? A 3rd party SaaS? At which point do you stop caring about reading every line of code you run?

This is perhaps where our perspectives differ, because I see the usage of LLMs not as an external third-party (another team per your example), but instead as an extension of one's self. Given that lens, I'm highly sensitive to the quality and function of its output, because ultimately its contribution is my responsibility.

I appreciate not everyone feels this way, but that's why I personally would be anathema not to read its code.

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

#566

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.

Why? Go has a GC, is basically incompatible with C and very limited overall

'incompatible with C' isn't a serious problem nowadays and won't be a problem at all in a couple years.

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

#567
post #561
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 agree, especially very "pythonic" structures if overly shortened are hard to decipher especially if you don't use or read python on a regular basis. Often times when I am reading a medium or advanced python codebase I need to look into the function definitions and operator documentation to understand what is supposed to be returned. Where with C-like languages I feel it is easier to build that context because there…

> if overly shortened are hard to decipher especially if you don't use or read python on a regular basis.

Sure, but this is the case for any language.

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

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

Reaaaally?

I think a lot of the readability of python is in the fact you don't need to be recently familiar with it to pick up what its doing most of the time.

Over my career I've dipped in and out of rust, typescript, perl, swift, etc codebases. I'm no expert in any of these, but every single time I have to look something up to understand what this set of arcane symbols or syntax means.

When I dip into Python I just ... read it.

(None of this is to say I prefer Python, just that I really do get the readable thing)

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

#569

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.

So you would find bracketed code without any use of indentation easier to read than python?

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

#570
Lots of comments here already, just my two cents. I work in R&D and I prefer prototyping things in Python with AI (although we're a 100% Go shop) because:

1) Python is expressive and has packages for everything => faster iteration times because much fewer tokens

2) It doesn't require a compilation step, so when I'm quickly iterating on something, especially if my laptop doesn't have the target hardware, the flow "copy the sources to the target machine and restart" is superfast (a couple of milliseconds)

3) Python most likely represents the largest share of training data, so almost all LLMs can one-shot almost everything

And when my prototype is ready, and we want to go to production, I can ask the LLM to port it to Go with all the necessary conventions/ceremonies and all.

Post reply on HN