News for hackers. Stuff that matters.
Re:The Core of Rust by tracker1 on Thursday August 21, 2025 @03:42PM (#44977146)
I know this... my point was in that Rust didn't have this feature 5-8 years ago when I first started reading/learning about it. A lot of languages haven't had an active scripting-capable usage that can do this until fairly recently. C# even has it in .Net 10, though I'm not sure about dependency handling in that case.

I like and was commenting that rust has the cargo frontmatter instead of a separate cargo file, same for deno in that it can reference the repo/url directly instead of requiring a separate modules file/folder (like node package.json/node_modules) or even with python. You can reference the modules you need directly.

Re:The Core of Rust by ameliaquining on Thursday August 21, 2025 @04:06PM (#44977406)
A bunch of third-party Python package manager clients, most famously uv, support this now. They all use the same front-matter format (PEP 723). Unfortunately, pip (the first-party package manager client that's usually distributed with Python) doesn't support it yet: https://github.com/pypa/pip/issues/12891
Re:The Core of Rust by tracker1 on Thursday August 21, 2025 @04:58PM (#44978012)
Interesting... I'm not really involved in much/any Python development, but cool to know there are options out there. I've mostly just run existing projects as needed.
Re:The Core of Rust by kibwen on Thursday August 21, 2025 @05:09PM (#44978126)
To be precise, Rust files have supported shebangs since well before 1.0, there just wasn't really any built-in tool to point the shebang at. The new stuff in the relevant RFC is actually about Cargo, not Rust; the "Cargo frontmatter" syntax doesn't need to be added to Rust, it can just be stripped by Cargo before it hands off the file to rustc.
Re:The Core of Rust by epage on Thursday August 21, 2025 @05:45PM (#44978460)
T-lang and T-cargo still decided to add frontmatter to Rust, see https://rust-lang.github.io/rfcs/3503-frontmatter.html
Re:The Core of Rust by throw234234234 on Thursday August 21, 2025 @07:46PM (#44979572)
I remember when I saw this in F# interactive (C# didn't have a REPL at all at the time) when I first started using that language around 10 years ago. I thought it was immediately useful as a easy to write, but static typed Python replacement without all of Pythons dependency headaches for quick scripts. Because back then as compared to say C#/Java which required a lot of class files, boilerplate, etc F# read more like a scripting language which made it more suited to this. When they added the ability to pull in packages/dependencies inside the script directly that was great as well. e.g. Pull in a type provider, parse some JSON, make some API calls, create quick CSV's, whatever. Useful for quick scripts, data mangling or quick prototypes - you could just cut and paste the single script with a shebang, message it to someone on your team and it would run dependencies and all without the equivalent venv issues with a simple pasting into a text file. Install .NET SDK and that's it - it would run.

I think those features have since spread to C# interactive (probably inspired by the F# incubator IMO), as that language has done things to simplify its syntax to make single file apps easier. From your comment Rust seems to be taking a similar approach.

Re:The Core of Rust by lenkite on Friday August 22, 2025 @05:37AM (#44982565)
This is still a nightly feature as I just discovered when I attempted to run this sample.