8 ms·
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
by bryanrasmussen 6mo ago
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 your language has a small training set or you don't intend to do much addition or you don't really know any language that well or are restricted from using choice 1 for some reason, 2 and 3 move up, and python has a large training set and it is easy to read.
- simonask 6mo agoPython is locally readable. Reasoning about larger systems in Python is where things get really hard, because you have to describe how many small individually readable things interact with each other in a very limited vocabulary.
- ant6n 6mo agoThat’s true. Once you have APIs and want to use classes to create larger structures, the language is full of warts.
- cturner 6mo agoI have built large systems on python that use classes, for more than ten years. I came to it from Java, ten years. As a rule, I avoid implementation inheritance. Occasionally I need to facade a library that assumes implementation inheritance to avoid it spreading into my codebase. When the codebase hits a certain size, I hand-roll some decorators to create functionality like java interfaces. With that done, and a suite of acceptance tests, I find it scales up well.
- bryanrasmussen 6mo agohmm, 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?
- hiAndrewQuinn 6mo agoHaskell 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.
- lukan 6mo agoHaskell 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). Really large set of examples. Tools optimized for it, agents debugging in the browser works allmost out of the box. And well, a elaborate typesystem.
- yakshaving_jgt 6mo ago[dead]
- klodolph 6mo agoI 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.
- co_dh 6mo agoI used Claude that created a terminal based table viewer from rust first, to lean , and finally to Haskell. https://github.com/co-dh/tv-hask/tree/main https://github.com/co-dh/tv-hask/tree/main I give up rust because it’s not functional enough. There aren’t many things Claude can prove about a table viewer, and Haskell fits very well, and have enough libraries. Claude is pretty good at Haskell. I barely write Haskell before but I do know monad.
- bazoom42 6mo agoFor larger systems you create your own modules and abstractions, so comprehensibility at higher level does not depend so much on the language.
- sundarurfriend 6mo agoThe tools the language gives you to create those abstractions make a lot of difference, however.
- mbreese 6mo agoBut every abstraction that an LLM has to write is a choice. Your way of writing Python may not match that choice. The next run of the agent might not choose the same way. Because the language gives you many different tools, an LLM generated codebase can get inconsistent and overly complicated quickly. The flexibility of Python is a downside when you’re having an LLM generate the code. If you’re working in an existing codebase, it’s great - those choices were already made and it can match your style. When an LLM has to derive its own style is when things can devolve into a jumbled mess.
- andyferris 6mo agoTo me applying LLMs to a python (or similarly dynamic) code base where it’s currently spaghetti and monkey patched, it can miss things just like I can. But… I have to admit Opus 4.7 has been very pragmatic in detecting root causes and proposing sensible fixes to bugs in this situation (ie bugs encountered in production not compile time). It’s also fine at matching current styles and conventions (which is great if they are good styles and conventions). In terms of new code, rust would have been near impossible to write with such a high degree of non-local reasoning, so I’m assuming these bugs wouldn’t be present.
- gbro3n 6mo agoThe larger models really are more reliable at following instruction and reasoning their way to solutions. I haven't found that the harness makes that much difference. CoPilot, Claude, Pi, all see similar results for me. What really does make a difference is clean task separation and a clear plan / todo / implement workflow. I've consolidated a lot of the way I work with agents in https://www.agentkanban.io https://www.agentkanban.io - the task board keeps the tasks discrete and minimal. I built in plan todo implement into the agent instruction that binds the board task to the chat.
- scared_together 6mo agoI’m curious about the design space of languages & frameworks which are lower level than LLM prompts but higher level than Python, Ruby and Common Lisp. Do you have any recommendations for systems where reasoning about large systems is easier than in python?
- skydhash 6mo agoYou have to go into live programming, code in a system, and saving images. Readability is no longer a factor, what you want is easy access to documentation, quick navigation, and a playground.
- splitstud 6mo ago[dead]
- simonask 6mo agoAnything with a good, static type system will be an improvement, in my opinion. Types exist to encode invariants in an enforceable way, after all. Rust is the gold standard among imperative languages, but it’s standard fare among functional languages such as Haskell, OCaml, F#. You can also get really far in C++ if you have the stomach for it.
- scared_together 6mo agoI have used Rust, Java and TypeScript before, so I understand that static typing is a major help. But I don’t think types are really sufficient to solve the problem you identified earlier of understanding how “many small individually readable things interact with each other”. Maybe you meant that phrase in a different sense than I read it, but it seems to me that there are still a lot of small individually readable things to keep track of in Rust.
- bootsabota 6mo agoThis is why good design documents will always be necessary. When I work with AI I always have it keep an up-to-date architectural document committed to the repository. Also, we need to be able to understand what is happening under the hood somewhat, so I very much agree the readability is crucial. And frankly, rust is not up there in the readability realm. I think all the previous language designs still hold for their respective use case. AI written or otherwise. Why? Because performance acceptability is domain specific, and also the algorithms complexity generally determines overall performance. For example, move the performance critical stuff into a Python C extension like Torch etc…
- neuronexmachina 6mo agoAlthough it's not part of core Python, tach is pretty handy for specifying and enforcing those larger-scale interactions: https://github.com/tach-org/tach https://github.com/tach-org/tach
- nrub 6mo agoYeah, that's cool, but it would be almost completely unnecessary if python just had actual private methods/classes/properties. It's a lot like pydantic, which is completely unnecessary if you had strong typing.
- nostrademons 6mo agoLocally readable is what I want for LLM-generated code, though. If I need to change the whole architecture, I re-prompt the LLM and have it rewrite the code for me. The changes that I'd need the code to be human-readable for are quick fixes where the LLM got something simple wrong and it'd take longer to explain to the LLM where it went off-track than to just fix it myself.
- moffkalast 6mo agoSo in short, use Javascript /s
- slifin 6mo agoI would assume it's important to know what's in that training set too Because I get reliable generation out of "niche" languages already Is it code with lots of SQL injections used in a different domain to your own? It's maybe not good to conflate quantity with quality
- fragmede 6mo agoThis is dated, but a professor told me that LLMs are really really good a generating bad pandas code because it's been trained on so much of it!
- DaanDL 6mo agoI 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...?
- bazoom42 6mo agoC# is also a great language, but notice how it have been moving closer to Pyhon-style syntax. E.g. now you can initialize a list like [a, b, c]. They wouldn’t add that syntax if they didnt think it was an improvement. Less ceremony and boilerplate means more readable code.
- fragmede 6mo agoThe "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.)
- strangegecko 6mo agoI 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.
- zahlman 6mo ago> I find brackets help me understand structure from a distance much better than whitespace. I can't imagine how. Whitespace physically lays out the block structure on the screen; braces expect you to count and balance matching symbols, and possibly scan for them within other line noise.
- polytely 6mo ago
- teleforce 6mo agoI think this is where D language make an excellent alternative to Python for AI assisted coding [1]. 1) It's a very consistent language even if you compared to the other popular languages namely Python, Rust, C++ and Go. Try to perform doubly linked list with them and compare them all [1]. 2) It's probably the most "Pythonic" among the compiled language according to Walter. 3) It utilizes GC by default, you can also manage your own memory and you can hybrid. 4) It compiled fast and run fast, heck it even has built-in REPL eco-system. 5) Regarding the small training set, with recent self-distillation fine-tuning approach it should be good enough, D (actually D2 version) has been around for more than a decade [2]. [1] Looking for a Simple Doubly Linked List Implementation: https://forum.dlang.org/thread/osmecwfnpqahoytdqpkr@forum.dlang.org https://forum.dlang.org/thread/osmecwfnpqahoytdqpkr@forum.dl... [2] Awesome D: https://github.com/dlang-community/awesome-d https://github.com/dlang-community/awesome-d
- PunchyHamster 6mo ago> 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. But it's LLMs that read it not humans. At least that's the trend > Use a language that has a large training set so the LLM can be most efficient. It's pretty efficient with Rust.
- subscribed 6mo agoBut plenty of humans like to be able to read the generated code and understand / edit that.
- bioneuralnet 6mo agoOne could argue that with AI writing so much code, the ease with which humans can read & understand it (for review purposes) is even more important than before.
- ashishb 6mo agoPython 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/ https://ashishb.net/programming/python-in-production/
- kurtis_reed 6mo agoPython is faster to write so obviously you'll see things built in Python first more often than the reverse. What's that quote -- "Better to remain silent and be thought a fool..."
- ashishb 6mo agoIndeed. Python is faster to write and harder to maintain over the long run. The "faster to write" advantage becomes less relevant if most code is going to be auto-generated. The "harder to maintain" might still remain more relevant.
- tclancy 6mo ago>harder to maintain over the long run. First off, this is begging the question. Second, if you never get to a point where you need to maintain something, who won?
- marliechiller 6mo agoI dont know if the reasoning for a rewrite is purely for maintainability though. Ive used python at scale and its fine if you have reasonably good code hygiene. The reason I'd want to rewrite in any of those languages is they're significantly faster _and_ are maintainable at scale.
- ashishb 6mo ago> Ive used python at scale and its fine if you have reasonably good code hygiene. True but that's the problem. Once you have a big enough team, it becomes an uphill battle to maintain that.
- fennecfoxy 6mo agoI think that pseudocode aspect is what makes it hard/frustrating to read for me. I'm more of a c++/TS/etc user, so I miss braces a lot. I think a basic Python script sure it's easy to read through, but a large project starts to get quite ugh. I am very jealous of Python's numerous built-ins though. I was looking for a JS sum function the other day and was surprised to see node.js still doesn't have a built in + you still cannot reference operator functions.
- fennecfoxy 6mo agoLmao are people really -ing me because I don't like Python. Tribalism is present in all areas of human life I suppose. You people should grow up. Programming languages are tools, not pets.
- FartinMowler 6mo agoBut at least JS now has a built-in leftpad function ;) (called padStart).
- LukaD 6mo ago> 2. Use a language that has a large training set so the LLM can be most efficient. I seriously doubt this is really the case. From my experience coding agents just love writing bad python code. It always needs explicit instructions for example to use uv instead of raw dogging pip. There is a lot of python code out there because it is being taught as a beginner language and because of that there is necessarily a lot python code written by beginners. That's my explanation at least for bad LLM generated python code.
- theshrike79 6mo agoMy 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-modern-guidelines https://github.com/JetBrains/go-modern-guidelines
- RHSeeger 6mo agoThe folks I work with rave about how well the LLMS work with Go.
- javier123454321 6mo agoNo, I think the argument from the article is pretty good. Use a language that has a lot of guard rails built in.
- nicman23 6mo agoor a compiler that makes the llm sad
- deleted 6mo ago[deleted]
- psychoslave 6mo agoDisagree, it's verbose, but it's full of needleslly verbose stuffs, use many _ for everything and the rest, and other opaque conventions. Not that any other dev ecosystem is free of any of these issues, but Python just don't shine much on them. If anything in term of script language, Ruby provides a far more solid ground for compact and readable exposure of ideas through something close to prosaic expression.
- nicman23 6mo agoc llm code is more readable as it probably trained on better code
- odyssey7 6mo agoHaskell is more readable. It looks just like pseudocode. Change my mind.
- p-t 6mo agotbh 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
- randusername 6mo agoPython is great at AI code gen for a combo of reasons: big stdlib, readable, 3rd party libraries to do most anything with great online documentation, big mind-share and presence online. The big one to me is that it's interpreted. Claude Code does these wild `python -c` "one-liners" that end up spanning a hundred lines or more. It's so ingrained that it does this for solving general problems to create on-the-fly system reports, not just when you specifically are using it for Python development. One of my more interesting experiments has been "mirroring" a Python codebase I maintain with a synchronized one in another language the AI maintains.
- jelder 6mo agoThere's a huge difference between a program which can be verified as correct by static analysis, and a program which can only be verified as correct by running it. Python is the latter (though maybe in between with gradual typing). The iteration loop just collapses when an agent is driving an LSP in a statically typed language.
- niam 6mo agoPython does have a huge training set, but I figure lots of that training comes from disciplines where maintainability or system design isn't as heavily incented. Reports, notebooks, dashboards, etc. My early experiments with LLM Python seemed to give me that impression, but I'm wondering if it's better now or people have other experiences.
- pplonski86 6mo agoPython outputs is also very versatile. You can use Python to build command line script, web application, desktop app with GUI, notebook with data analysis, or Python package and share with others. It is many ways how Python code can be used by final user.
- hn-acct 6mo agoI personally don’t find it readable at all.
- seunosewa 6mo agoLess verbose languages also use fewer tokens, saving precious context.
- bfrog 6mo agoFunny, I need an LLM to figure out what most people consider "readable" python as its highly unreadable to me. The lack of types, top to bottom flow, and more tends to make it all very confusing for me to read anything python that's > ~1000loc
- stackghost 6mo agoAs much as I dislike writing Go, I think it's pretty close to the ideal LLM language. There's usually one very obvious correct way to accomplish things, there's a ton of training data, it's GC'ed, the standard library is expansive and of good quality, there's a large ecosystem of 3rd-party packages, etc. About the only place where I don't think Go works for agent-heavy workflows is that it's not very concise. It takes a lot of Go code to express what other languages can do in many fewer lines, and I think this wastes Context Window but also just makes it harder to keep everything in my poor little human brain. LLMs also do a pretty good job writing modern C++. I much prefer writing Common Lisp but I've noticed that LLMs (claude 4.6+ and GPT 5.x) aren't nearly as good at writing Lisp than they are at more mainstream languages, plus Lisp's syntax makes it a little hard to read sometimes, especially if you're not in the habit of reading it every day.
- speleding 6mo ago> ... something you know well and is easy to read ... For this reason I tell my LLMs to use Ruby whenever possible. In one rare case where the performance of my script was critical, I told Claude to convert the working ruby script to Rust. It got it right in a single shot.
- pmarreck 6mo agoPython also has a rather high number of footguns, which is not a feature of other equally-capable languages.
- fuzztester 6mo agoHow to Shoot Yourself In the Foot: https://www.eng.uwaterloo.ca/~comp03a/misc/humour/shootfoot.html https://www.eng.uwaterloo.ca/~comp03a/misc/humour/shootfoot....
- giancarlostoro 6mo agoI've been using Rust more because of Claude, but I mostly do C# / Python otherwise. I can read Rust, and understand it, but I don't have the patience to fight the compiler, or the liberty of free time. I do however have in my brain plenty of architectural ideas I can convey to a model and get back a sound program.