muglug
2 days ago
> Rust is the best general-purpose language for the new world of AI-driven development.
Funny, the Python guys say Python is the best general-purpose language for AI and the Go guys say Go is the best general-purpose language for AI etc etc
Tuna-Fish
2 days ago
I've found that the guardrails of a strong, expressive type system are amazing for LLMs, especially if you don't use the top-of-the-line models but stick to the cheaper options. Agents need feedback to do their magic, and the type system is great for that.
But on the other hand, the compile time of Rust is really counterproductive. On large, established projects, most prompts I write now spend more time compiling on my machine than they spend outputting tokens. In a way this is great because the tokens are the expensive part, but it does mean that when faster LLMs will come, they will not meaningfully improve iteration speed for me.
I wonder how much of the compile time of Rust is inherent to the type system. There might be room for a language with slower runtime speed (GC?), but as good of a type system as Rust, so long as compile times are much faster. Switching languages has never been easier, anyone have any suggestions? IMO hard requirements are algebraic types and error handling based on them.
dabinat
2 days ago
Compile times in Rust are partly the amount of analysis that occurs, partly that it uses LLVM which is optimized for creating fast code at runtime but not necessarily fast-compiling code, and partly the fact that the Rust compiler is inefficient and does the same work twice or recompiles things it doesn’t need to.
But you can speed things up a lot by organizing your project into separate crates (which are compiled in parallel) and tweaking compiler flags. I speed up a large project by 7x this way.
Also, if you’re using fat LTO in release builds, switch to thin. It’s almost as fast at runtime and much much faster to compile.
scns
2 days ago
> There might be room for a language with slower runtime speed (GC?), but as good of a type system as Rust, so long as compile times are much faster.
There is OCaml which compiles very fast in debug mode.
stymaar
2 days ago
> But on the other hand, the compile time of Rust is really counterproductive.
Since it's going to be mostly cargo check and incremental builds, I don't think it matters in practice.
selfhoster1312
a day ago
Even incremental builds can be slow depending on eg. what macros you use. For example, i had bad surprises with askama which is a delight in most cases, but really makes compilation slower as you add more templates. On a project with ~20 templates, incremental build in debug mode now takes ~40s on a very fast machine.
pjmlp
a day ago
OCaml, Haskell, F#, Standard ML.
The big difference to Rust is the availability of interpreters, REPL, which can equally load compiled code, and full blown AOT for release builds.
Rust's problem isn't type system, rather lack of tools.
jaen
a day ago
Python has a strong, expressive static type system with a very fast type checker (Pyrefly).
selfhoster1312
a day ago
I love python for some stuff, but i definitely would not say it has an expressive type system. Enums are a second-class citizen, and typed dicts are definitely not as convenient as i would like. And to my knowledge, type checkers don't support proper exception catching rules; rust also has no guarantee that a function won't panic, but usage of Result type makes it less of a problem (because panic is more or less exclusively for unrecoverable invariant violations), and there's ecosystem tools to make sure you don't ever panic.
jaen
20 hours ago
If by enums you mean sum-type ADTs (like in Rust), then Python is certainly quite expressive - it has union types, which can represent polymorphic variants - those are slightly more expressive than pure Rust-style ADTs since you can arbitrarily subset or extend the enum cases.
@dataclass @final class CaseA[T]:
field: T
type MyEnum[T] = CaseA[T] | CaseB
This also gets exhaustiveness checking in `match` statements (depending on the type checker). Overall, enums have a similar style to Scala and Java >=21 (mixing OO + ADT). I guess syntactically it can be slightly verbose depending on the exact situation...
I wouldn't call them second class, but yeah, not a lot of existing libraries use this style.Typed dicts (with the latest PEPs) are an improvement over any other language besides TypeScript. Yes, in TS, certainly `Partial` / `Pick` / `Omit` and intersection types make modeling the web API swamp easier, and that's one place TS is superior to anything else.
Python does have the Type Manipulation PEP 827 [1] out to give it similar powers to TS, but I feel that's unlikely to be implemented soon / as-is.
Having an effect system for exceptions would be nice indeed. That's actually something I'm looking into (having an "allowed exceptions" annotation for functions and then checking it at test-time via failure injection and possibly in type checkers).
tmpz22
2 days ago
Can your team read and audit Rust code as fluently as Go or Python?
I realized all the Rust code produced meant squat if it couldnt be audited well afterwards.
Tuna-Fish
2 days ago
Auditing Rust is much easier and faster than either Go or Python. They both contain a lot of footguns that are not always immediately apparent from visible code. Rust is much more explicit.
lucideer
2 days ago
This is assuming equal familiarity with all languages but I presume this comment is more referring to talent pools & experience. A good engineer can traverse & review many languages but most are quite restricted in the scope of what they can easily read - they miss a footgun or two in python but they're not grokking any of the rust whatsoever.
binarin
2 days ago
It's the Python guys whom I totally don't understand - it's all fun and dandy until you try to maintain and cleanup a legacy codebase of tens of millions lines of code in any dynamic language :)
With or without AI - doesn't matter. Only at that point you gain understanding of the limitations both of LLMs and of dynamic languages.
edit: Forgot about "Nightmare" difficulty - try enjoying dynamic languages and LLMs when your legacy codebase is earning tens of thousands $ per second.
infamia
a day ago
Unless you're doing something really dynamic, I don't really understand this position and would like to learn more. for most cases gradual typing is a great option that can be done incrementally in Python (two things even cheap agents are really good at).
binarin
a day ago
You can't forbid people doing something "really dynamic". And in a sufficiently big system, over long period of time, this stuff will accumulate - 100%. Then you'll get to a point where answering questions like "is this piece of code still alive" with enough confidence is almost impossible.
The question is where the "enough confidence" border lies - and in the worse case the only way to do some reliable investigatios would be printf debugging or its alikes.
infamia
a day ago
It sounds like your app is using a lot of dynamic techniques like meta-programming? If so, that makes a lot of sense. Most of the apps I've seen use very little use of meta-programming and friends and incremental typing worked rather well.
orf
a day ago
> your legacy codebase is earning tens of thousands $ per second.
Your legacy codebase generates ~300 billion a year?
binarin
a day ago
Okay - not earning, but processing. Adjust the figure a bit for varying traffic patterns during week and seasonality, and it'll be kinda like that.
nobleach
2 days ago
I have prompted a LOT of Go in the past few months. While LLMs do indeed know Go very well, the amount of over-abstraction I'm seeing is awful. It's not at all indicative of code that I'd write myself. The whole point of Go is to have a language that is immediately approachable by juniors. And I've tried to keep my code in that lane. The reason I won't prompt Rust at all, is that I know it'll output working code... that I likely will not understand. (that's not the LLM's fault)
lucideer
2 days ago
I don't write Rust & have no horse in this race but my intuition on this is you have 3 scenarios:
1. Humans writing code: here the usability, readability, accessibility of the language matters - strictness can be a hurdle depending on how a language is designed, so ultimately it's a trade-off.
2. Humans reviewing AI-authored code: here the requirements of (1) still apply to the code reviewer
3. Autonomous agents writing code: above requirements no longer apply so having a strictly-defined language with tight guardrails is the primary consideration.
I think most people are operating workflows in category (2), but it seems uncontroversial to say Rust is more suited to category (3) than python or golang. Typescript, Haskell, Elm, Ocaml could be considerations but you'll find Rust hard to beat here. Certainly neither python nor golang are in the running at all.
throwawayqqq11
2 days ago
None of the other languages are as strict as rust is. With eager clippy and cargo lints and software design as close to the type system as possible, LLMs have tight guard rails to land on point.
chaostheory
2 days ago
There is some truth for all three.
1. Python has a lot of training data
2. Go runs with the philosophy of one same way to do stuff even further than Python. It’s also typed
3. Rust’s type system and strict compiler is what helps keep AI on guardrails
geodel
2 days ago
Well, Rust is great for Fearless AI-driven development.
polotics
2 days ago
Do you have any substantial sound metrics and study? I can think of many ways for a Rust program to not remove all fears that it will not do what I intended, doubly so for a vibe-coded Rust program.
moritz
2 days ago
You‘ll notice a lot of "I found"s and "my hunch"s and similar in the comments.
There aren’t many comparative benchmarks, and obviously the design of such a benchmark is difficult, but, e.g. https://arxiv.org/abs/2508.09101
In this benchmark, models can correctly solve Rust problems 61% on first pass — A far cry from other languages such as C# (88%) or Elixir (97%, no static typing whatsoever).
tancop
a day ago
First pass is not that important today. All coding agents run until they get it right or hit a limit.
Having to tweak code and compile more often makes things slower, but strict compilers also help you find bugs faster and navigate the codebase. I think the two effects balance out and leave you with safer code in the end. And that's not counting the performance benefits of a compiled language.
cbsmith
2 days ago
Yeah, but only the Rust guys are right. ;-)
carllerche
2 days ago
Exactly my point. Everyone says agents are “best” at their language. Which probably translates to agents generate equally well for all programming languages. So, why would you not pick the programming language that gets you the best (fastest, least memory) end product?
moritz
a day ago
assembler?
tamimio
2 days ago
Never met a person who said python is the best except the python-cult. Legacy language that should be gone, it’s a scripting language that got known by data scientists as a replacement of R because they are not developers, they wanted something hacky and dirty to do things quickly, it was never meant for serious programming, something you can see in the dependency hell, indentation, syntax, performance, etc, and then you see people are trying to use it in UI or even robotics, what are you doing?! Maybe before llm it was an easy hacky way, now it should die for good.