upvote
3 reasons why Python is much better than JS for this IMO.

1. Large built-in standard library (CSV, sqlite3, xml/json, zipfile).

2. In Python, whatever the LLM is likely to do will probably work. In JS, you have the Node / Deno split, far too many libraries that do the same thing (XMLHTTPRequest / Axios / fetch), many mutually-incompatible import syntaxes (E.G. compare tsx versus Node's native ts execution), and features like top-level await (very important for small scripts, and something that an LLM is likely to use!), which only work if you pray three times on the day of the full moon.

3. Much better ecosystem for data processing (particularly csv/pandas), partially resulting from operator overloading being a thing.

reply
> In JS, you have the Node / Deno split,

You do? Deno is maybe a single digit percentage of the market, just hyped tremendously.

> E.G. compare tsx versus Node's native ts execution

JSX/TSX, despite what React people might want you to believe, are not part of the language.

> which only work if you pray three times on the day of the full moon.

It only doesn't work in some contexts due to legacy reasons. Otherwise it's just elaborate syntax sugar for `Promise`.

reply
> JSX/TSX, despite what React people might want you to believe, are not part of the language.

I think you misunderstood this. tsx in this context is/was a way to run typescript files locally without doing tsc yourself first, ie make them run like a script. You can just use Node now, but for a long time it couldn’t natively run typescript files.

The only limitation I run into using Node natively is you need to do import types as type imports, which I doubt would be an issue in practice for agents.

reply
Yes, thank you for pointing that out. Forgot that there's a another thing named "tsx" out there.

I wouldn't call it running TS natively - what they're doing is either using an external tool, or just stripping types, so several things, like most notably enums, don't work by default.

I mean, that's more than enough for my use cases and I'm happy that the feature exists, but I don't think we'll ever see a native TypeScript engine. Would have been cool, though, considering JS engines define their own internal types anyway.

reply
> JSX/TSX, despite what React people might want you to believe, are not part of the language.

Similarly: TypeScript, despite what Node people might want you to believe, is not part of the JavaScript language.

reply
Yes. As pointed out by someone else I misunderstood and it's the other tsx they were talking about.

I've always used ts-node, so I forgot about tsx's existence, but still those are just tools used for convenience.

Nothing currently actually runs TypeScript natively and the blessed way was always to compile it to JS and run that.

reply
People have to look into Typescript as a JavaScript linter and a babel replacement, nothing else.

In fact, the team has back pedaled into trying to make its own thing like in the early days.

reply
In Python you also have plenty of implementations to choose from, incidentally many of them have evem better performance than CPython.
reply
>In Python, whatever the LLM is likely to do will probably work.

Do you not realize how this sounds?

>many mutually-incompatible import syntaxes

Do you think there are 22 competing package managers in python because the package/import system "just works"?

reply
Having been doing Python for over a decade and JavaScript. I would pick Python any day of the week over JavaScript. JavaScript is beautiful, and also the most horrific programming language all at once. It still feels incomplete, there's too many oddities I've run into over the years, like checking for null, empty, undefined values is inconsistent all around because different libraries behave differently.
reply
TBF is the Python ecosystem any different? None and dict everywhere, requirements.txt without pinned versions... I'm not complaining either, as I wouldn't expect a unified typed experience in ecosystems where multiple competing type checkers and package managers have been introduced gradually. How could any library from the python3.4 era foresee dataclasses or the typing module?

Such changes take time, and I favor an "evolution trumps revolution"-approach for such features. The JS/TS ecosystem has the advantage here, as it has already been going through its roughest time since es2015. In hindsight, it was a very healthy choice and the type system with TS is something to be left desired in many programming languages.

If it weren't for its rich standard library and uv, I would still clearly favor TS and a runtime like bun or deno. Python still suffers from spread out global state and some multi-paradigm approach when it comes to concurrency (if concurrency has even been considered by the library author). Python being the first programming language for many scientists shows its toll too: rich libraries of dubious quality in various domains. Whereas JS' origins in browser scripting contributed to the convention to treat global state as something to be frowned upon.

I wish both systems would have good object schema validation build into the standard library. Python has the upper hand here with dataclasses, but it still follows some "take it or throw"-approach, rather than to support customization for validations.

reply
It was better because it had no silent errors, like 1+”1”. Far from perfect, the fact it raised exceptions and enforced the philosophy of “don’t ask for permission but forgiveness” makes the difference.

IMHO It’s irrelevant it has a slightly better typesystem and runtime but that’s totally irrelevant nowadays.

With AI doing mostly everything we should forget these past riddles. Now we all should be looking towards fail-safe systems, formal verification and domain modeling.

reply
Conflating types in binary operations hasn't been an issue for me since I started using TS in 2016. Even before that, it was just the result of domain modeling done badly, and I think software engineers got burned enough for using dynamic type systems at scale... but that's a discussion to be had 10 years ago. We all moved on from that, or at least I hope we did.

> Now we all should be looking towards fail-safe systems, formal verification and domain modeling.

We were looking forward to these things since the term distributed computing has been coined, haven't we? Building fail-safe systems has always been the goal since long-running processes were a thing.

Despite any "past riddles", the more expressive the type system the better the domain modeling experience, and I'd guess formal methods would benefit immensely from a good type system. Is there any formal language that is usable as general-purpose programming language I don't know of? I only ever see formal methods used for the verification of distributed algorithms or permission logic, on the theorem proving side of things, but I have yet to see a single application written only in something like Lean[0] or LiquidHaskell[1]...

[0]: https://lean-lang.org/

[1]: https://ucsd-progsys.github.io/liquidhaskell/

reply
For historical reasons (FFI), Python has access to excellent vector / tensor mathematics (numpy / scipy / pandas / polars) and ML / AI libraries, from OpenCV to PyTorch. Hence the prevalence of Python in science and research. "Everybody knows Python".

I do like Typescript (not JS) better, because of its highly advanced type system, compared to Python's.

TS/JS is not inherently fast, it just has a good JIT compiler; Python still ships without one. Regarding security, each interpreter is about as permissive as the other, and both can be sealed off from environment pretty securely.

reply
A big benefit of letting agents run code is they can process data without bloating their context.

LLMs are really good at writing python for data processing. I would suspect its due to Python having a really good ecosystem around this niche

And the type safety/security issues can hopefully be mitigated by ty and pyodide (already used by cf’s python workers)

https://pyodide.org/en/stable/

https://github.com/astral-sh/ty

reply
(Pydantic AI lead here) That’s exactly what we built this for: we’re implementing Code Mode in https://github.com/pydantic/pydantic-ai/pull/4153 which will use Monty by default, with abstractions to use other runtimes / sandboxes.

Monty’s overhead is so low that, assuming we get the security / capabilities tradeoff right (Samuel can comment on this more), you could always have it enabled on your agents with basically no downsides, which can’t be said for many other code execution sandboxes which are often over-kill for the code mode use case anyway.

For those not familiar with the concept, the idea is that in “traditional” LLM tool calling, the entire (MCP) tool result is sent back to the LLM, even if it just needs a few fields, or is going to pass the return value into another tool without needing to see (all of) the intermediate value. Every step that depends on results from an earlier step requires a new LLM turn, limiting parallelism and adding a lot of overhead, expensive token usage, and context window bloat.

With code mode, the LLM can chain tool calls, pull out specific fields, and run entire algorithms using tools with only the necessary parts of the result (or errors) going back to the LLM.

These posts by Cloudflare: https://blog.cloudflare.com/code-mode/ and Anthropic: https://platform.claude.com/docs/en/agents-and-tools/tool-us... explain the concept and its advantages in more detail.

reply
Oh, I did not mean to imply it (Monty) wasn't secure; just that pyodide used the same sandboxing tech that JS uses.

You guys and astral are my favorite groups in the python ecosystem

reply
Why do you think python without access to the library ecosystem is a good approach? I think you will end up with small tool call subgraphs (i.e. more round trips) or having to generate substantially more utility code.
reply
"But MCP is still useful, because it is uniform"

Yes, I was also thinking.. y MCP den

But even my simple class project reveals this. You actually do want a simple tool wrapper layer (abstraction) over every API. It doesn't even need to be an API. It can be a calculator that doesn't reach out anywhere.

as the article puts it: "MCP makes tools uniform"

reply
lol "agents are better at writing code that calls MCP, then using mcp itself"

In hindsight, it's pretty funny and obvious

reply
Agreed, however AI adoption is finally putting pressure on CPython to have a JIT in the box, so there is that.

And on GPU side, the existing libraries provide DSL based JITs, thus for many scenarios the performance is not much different from C++.

Now NVidia is also on the game with the new tile based architecture, with first party support to write kernels in Python even.

reply
For me it's the opposite. I'm actively looking for tools in Python because at least they're gonna be lightweight and easy for me to debug.

Really tired of every AI-related tool released as of late being a half-GB node behemoth with hundreds of library dependencies.

Or alternatively some cryptic academic Rust codebase.

reply
Tangentially i wonder if the recent changes in the GIL will percolate to mercurial as any improvements.

Yep still using good old hg for personal repos - interop for outside project defaults to git since almost all the hg host withered.

reply
I remember the time when Python was the underdog and most of AI/ML code was written in the Matlab or Lua (torch). People would roll their eyes when you told them that you were doing deep learning with Python (theano).
reply
Python has the advantage that everybody sort of knows it is bad and slow, which is an important trait for a glue language. This increases the incentive to do the right thing: call a library written in C or Fortran or something.
reply
It might be slow, but it is definitely not bad. In the contrary, it is a great language. The closest to pseudocode you can get in a mainstream.
reply
That used to be true, but much of modern python code I see looks nothing like pseudocode. That advantage was lost around version 3, if not even before that.
reply
Python has uv, ruff, ty
reply
Can we please make as little js as possible?

Why would one drag this god forsaken abomination on server-side is beyond me.

Even effing C# nowdays can be run in script-like manner from a single file.

Even the latest Codex UI app is Electron. The one that is supposed to write itself with AI wonders but couldn’t manage native swiftui, winui, and qt or whatever is on linux this days.

reply
My favourite languages are F# and OCaml, and from my perspective, TypeScript is a far better language than C#.

Typescript’s types are far more adaptable and malleable, even with the latest C# 15 which is belatedly adding Sum Types. If I set TypeScript to its most strict settings, I can even make it mimic a poor man’s Haskell and write existential types or monoids.

And JS/TS have by far the best libraries and utilities for JSON and xml parsing and string manipulation this side of Perl (the difference being that the TypeScript version is actually readable), and maybe Nushell but I’ve never used Nushell in production.

Recently I wrote a Linux CLI tool for managing podman/quadlett containers and I wrote it in TypeScript and it was a joy to use. The Effect library gave me proper Error types and immutable data types and the Bun Shell makes writing shell commands in TS nearly as easy as Bash. And I got it to compile a single self contained binary which I can run on any server and has lower memory footprint and faster startup time than any equivalent .NET code I’ve ever written.

And yes had I written it in rust it would have been faster and probably even safer but for a quick a dirty tool, development speed matters and I can tell you that I really appreciated not having to think about ownership and fighting the borrow checker the whole time.

TypeScript might not be perfect, but it is a surprisingly good language for many domains and is still undervalued IMO given what it provides.

reply
I would say the same about Python, a language that has clearly got far too big for its boots.
reply