5 ms·
Just recently I heard that typed languages are best for agentic programming
by simianwords 10mo ago
Just recently I heard that typed languages are best for agentic programming
- reactordev 10mo agoSo add mypy to your pre-commit
- simianwords 10mo agoAll this but none of the performance benefits.
- deleted 10mo ago[deleted]
- shadowgovt 10mo agoIt's true; mypy won't make your Python faster. To get something like that, you'd want to use Common LISP and SBCL; the SBCL compiler can use type assertions to actually throw away code-paths that would verify type expectations at runtime (introducing undefined behavior if you violate the type assertions). It's pretty great, because you can run it in debug mode where it will assert-fail if your static type assertions are violated, or in optimized mode where those checks (and the code to support multiple types in a variable) go away and instead the program just blows up like a C program with a bad cast does.
- reactordev 10mo agoThe point about mypy was it does type checking (static analysis) for your Python code. Not speeding it up.
- Qem 10mo ago> mypy won't make your Python faster Mypyc will do. See https://blog.glyph.im/2022/04/you-should-compile-your-python-and-heres-why.html https://blog.glyph.im/2022/04/you-should-compile-your-python...
- __MatrixMan__ 10mo agoIf your code is talking to an LLM, the performance difference between rust and python represents < 0.1% of the time you spend waiting for computers to do stuff. It's just not an important difference.
- simianwords 10mo agoThis is clearly not what I'm speaking about - there are only a few applications that talk to an LLM.
- reactordev 10mo agoToday…
- __MatrixMan__ 10mo agoThe article is about Anthropic's contribution to Python. Pretty much all of their code talks to an LLM. And just a few comments earlier you said: > Just recently I heard that typed languages are best for agentic programming Are we not talking about using python (or some alternative) to constrain the behavior of agents?
- simianwords 10mo agoI was more thinking of python used as general purpose backend language. We can use LLM's to vibecode such languages.
- skeledrew 10mo agoI'd say most of us who prefer Python (a pretty significant number given it's the most popular language out there) don't care that much about performance, as today's machines are pretty fast and the main bottlenecks aren't in the language itself anyway. What we care about is usability/friendliness so we ourselves can iterate quickly.
- alex_suzuki 10mo agoOr ty: https://astral.sh/blog/ty https://astral.sh/blog/ty
- reactordev 10mo agoDamn… ok, I’ll try it
- danielbln 10mo agoTypes are best, period. Whether they are native or hints doesn't really matter for the agent, what matters is the interface contract they provide.
- simianwords 10mo agoI don’t get this argument because if we put the effort to get it typed, we don’t get one of the best benefits - performance.
- maleldil 10mo agoBut that's not the argument here. Python type hints allow checking correctness statically, which is what matters for agents.
- simianwords 10mo agoYes then you might as well use some other language that uses types but also gets you performance. I agree the ecosystem is missing but hey we have LLMs now
- solumunus 10mo agoPerformance isn’t the only important metric. There are other pros to weigh. For many apps a language might be performant enough, and bring other pros that make it more appealing than more performant alternatives.
- maleldil 10mo agoI don't understand why you keep bringing up performance. If you're considering using Python, as many projects are, performance is obviously not a concern. Python is a good language. Its ecosystem is rich, and I find it very productive. I want to use it, but I also want as much static analysis as possible, so I use ruff and pyright.
- wincy 10mo agoThat’s what makes types easier for me, too, so that makes sense.
- lambdaone 10mo agoPython is a typed language. Perhaps you were trying to say something different?
- simianwords 10mo agoIs it static or dynamic? Whatever rust is that python isn’t.
- lambdaone 10mo agoPython type hints are static - at the moment, they are advisory only, but there is an obvious route forward to making Python an (optionally) fully statically typed language by using static type checking on programs before execution.
- __MatrixMan__ 10mo agoRust is static. Python is optionally static.
- pantsforbirds 10mo agoThey clearly meant a statically typed language. Yes Python is Strongly Typed, but I think we all knew what they meant.
- exceptione 10mo agoFor any programming really, but I think Python got big due to a) the huge influx of beginners into IT, b) lots of intro material available in Python and c) having a simple way to run your script and get feedback (same as PHP) I say that as someone urging people to look beyond Python when they master the basics of programming.
- shadowgovt 10mo agoPython has a terseness that is hard to rival. I think that was a major selling point: its constructs and use of whitespace mean that a valid Python program looks pretty close to the pseudo-code one might write to reason out the problem before writing it in another language.
- exceptione 10mo agoI doubt that this is the selling point. Imho it is nothing special compared to Haskell, F# and the likes.
- shadowgovt 10mo agoPython doesn't require you to understand monads to write useful Python. To be clear: Haskell is great, but its entire vibe (lazy evaluation, pure functions) is entirely different from what Python's about. Someone who knows C++ or Java has a much bigger gap to jump to pick up Haskell than to pick up Python.
- exceptione 10mo ago> Someone who knows C++ or Java has a much bigger gap to jump to pick up Haskell than to pick up Python. True, they are all imperative c-style languages. > Python doesn't require you to understand monads to write useful Python. If that is the concern I would recommend anyone interested to dabble with F#. Part of its design philosophy is to keep the complexity out wrt type systems. It offers a vast vetted library¹, better dependency management², it is truly multi-paradigm (imperative, functional and oop), vastly better performance, and it is strongly typed without requiring type annotations³. I know I am not going to sell it to monogamous devs, but those that are open minded should give it a try. ___ ¹ This is something people will start to appreciate once they get serious about the risk of supply chain attacks. ² Python developers feel they are doing fine with pip or uv, at least in my experience, but then I find they haven't dealt with package mgmt in alternative languages. ³ Types in python are a hack, bolting on something afterwards will not reach what is possible with a language that has been designed with types as core element.
- pansa2 10mo agoAFAICT Python basically is a [statically-]typed language nowadays. Most people are using MyPy or an alternative typechecker, and the community frowns on those who aren’t.
- shadowgovt 10mo agoIt's a pretty nice best-of-both-worlds arrangement. The type information is there, but the program still runs without it (unless one is doing something really fancy, since it does actually make a runtime construct that can be introspected; some ORMs use the static type data to figure out database-to-object bindings). So you can go without types for prototyping, and then when you're happy with your prototype you can let mypy beat you up until the types are sound. There is a small nonzero cost to using the types at runtime (since they do create metadata that doesn't get dropped like in most languages with a static compilation step, like C++ or TypeScript). I can name an absolute handful of languages I've used that have that flexibility. Common LISP comes to mind. But in general you get one or the other option.
- pansa2 10mo ago> It's a pretty nice best-of-both-worlds arrangement It’s also a worst-of-both-worlds arrangement, in that you have to do the extra work to satisfy the type checker but don’t get the benefits of a compiled language in terms of performance and ease-of-deployment, and only partial benefits in terms of correctness (because the type system is unsound). AFAIK the Dart team felt this way about optional typing in Dart 1.x, which is why they changed to sound static typing for Dart 2.
- 9rx 10mo agoWithout dependent typing, it's the worst of all worlds anyway. You have to express types, but they aren't expressive enough to not have to also express the same in tests, leaving this weird place where you have to repeat yourself over and over. That was an okay tradeoff for humans writing code as it enables things like the squiggly line as you type for basic mistakes, automatic refactoring, etc. But that stuff makes no difference to LLMs.
- desireco42 10mo agoWhy is this getting downvoted... it is true. Also it is true that dynamic languages (like Ruby ;) and Python) are more efficient with tokens, like significantly then types like C, C++ or such. But Javascript and Typescript are using twice the tokens of Ruby for example and Clojure is even more efficient, obviosly I would add.
- minimaxir 10mo agoIt's not incorrect, but in the context of the given Hacker News submission it reads as "why fund Python at all?"
- oefrha 10mo agoJust recently I heard that they can donate to “typed languages” too, a donation to one language does’t preclude other donations, and given their cash injections they have a few $1.5m’s to spare.
- dude250711 10mo agoFor vibe code, since it's not important whether the output works, JavaScript is even better.