Live data from Hacker News

If AI writes your code, why use Python?

medium.com

761–770 of 1001 posts

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

#761
post #323

Earlier quoted context omitted.

No batteries!? Go has a huge stable standard library no other language even comes close to. Built in tooling for unit testing, performance testing, debugging, code formatting, package management, etc. And most go binaries can be compiled statically so libc is not even a dependency. Golang is the definition of batteries included.

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

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

#762

Earlier quoted context omitted.

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…

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, and not particularly intuitive, but it's not necessarily terribly confusing.

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

#764

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…

> Python is, thus, clearly superior to other languages in terms of ease of review. My experience has not been this. Dynamic languages make it harder to figure out things locally, unless someone has done the hard work of adding type hints.

Python has had type hints for like... Oh 11 years now. Just like C# has introduced var and quicker ways to write less, to the point it almost looks like JavaScript sometimes, but its because we can infer types pretty easily now. Rust has a nice system as well, forcing method signatures to declare types, everything is easier to infer from this.

Introduced in 3.5 (2015)

https://docs.python.org/3/library/typing.html

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

#765
because it's likely that a lot more of the training data is in python than in rust, so coding models are less likely to mess up python code? just based on PL popularity stats e.g. https://madnight.github.io/githut/#/pull_requests/2024/1 if the training data is crawled from real codebases then there's gonna be more python than anything else.

in my personal experience, the one time I tried to do something in rust, opus flailed for several feedback cycles and I finally had to relent and do substantial guiding/intervention. which was not great bc I have no idea how to write rust either.

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

#766

Earlier quoted context omitted.

> Python is, thus, clearly superior to other languages in terms of ease of review. My experience has not been this. Dynamic languages make it harder to figure out things locally, unless someone has done the hard work of adding type hints.

Python has had type hints for like... Oh 11 years now. Just like C# has introduced var and quicker ways to write less, to the point it almost looks like JavaScript sometimes, but its because we can infer types pretty easily now. Rust has a nice system as well, forcing method signatures to declare types, everything is easier to infer from this. Introduced in 3.5 (2015) https://docs.python.org/3/library/typing.html

Yet many projects don't use them.

Sometimes they are wrong (as they are more like a comment than a compiler directive).

My first task in any project was to figure out why devs don't have error highlighting on for bad types (often it's "it was red so we turned it off"), but good luck forcing others who don't do type hunting to start doing it when "it slows us down".

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

#767

Earlier quoted context omitted.

hmm, yeah given LLM's ability to churn out lots of code quickly and be overly verbose in that code that is a potential downside. That it could in a quick one time edit create so much intellectual overhead that Python might be the wrong language to understand what is going on. What language do you feel is easier to reason about in the large?

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.

In the window of Haskell-like and highly readable, I’d throw OCaml and F# out as strong candidates.

In practice your code can be cleaner than Python, deeply flexible naming capabilities including full sentences with backticking, efficient and powerful discriminated unions and types enable near-English domains, the type system keeps you honest and provides exhaustiveness guarantees, domain modules of applied functions are obvious and locally coherent domain grammars, and there is potent DSL support to create mini-grammars for legibility and expressiveness.

I used to write python by hand to reason then type it up in C#. F# is just as easy with a pen, but far more powerful and with a powerful type system and aggressive compiler. OCaml and F# are also highly token efficient languages, beating Python across the board for agentic work.

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

#768

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…

Is it though? You assume the abstractions in Python are battle tested and you understand them. Usually people are relying on arbitrary libraries so unless you’re constraining libraries and those libraries have good review processes, it won’t be long until high level functions you’re reading are generated by LLMs to, so to review your LLMs use of other LLM generated functions you have to drop down a few levels and review at that level.

At some point that becomes less sustainable and looking at something with less abstraction assures you’re at least looking at a baseline source of truth, even if the volume is massive.

There’s going to be a whole world in the knowledge economy, not just software but everywhere, around validation and sign off of information that we’ve taken for granted as a cost prohibitive process where only the best options make it to high levels of function and maturity.

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

#770
post #566

Earlier quoted context omitted.

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.

or the language was fundamentally designed to make mid level engineers more productive...
Post reply on HN