News for hackers. Stuff that matters.
Re:3rd Edition of Programming: Principles and Practice Using... by gorjusborg on Friday April 19, 2024 @12:04PM (#40088494)
The idea of using Rust for scripting is bizaar.

I can understand not wanting to use Python for everything, but I see the problem being the 'use it for everything' not the language choice.

Use the tool that excels at the job. There is no language that is good at everything.

Re:3rd Edition of Programming: Principles and Practice Using... by natsucks on Friday April 19, 2024 @12:41PM (#40088966)
Rust is cool now. Python is not cool anymore.
Re:3rd Edition of Programming: Principles and Practice Using... by smallstepforman on Friday April 19, 2024 @01:22PM (#40089527)
The current project I’m working on has tons of resource caches (for performance), with tons of non-owning pointers sharing cache references. I’d hate to do this in opinionated languages like Rust.
Re:3rd Edition of Programming: Principles and Practice Using... by steve1977 on Friday April 19, 2024 @01:03PM (#40089282)
I think Python fell victim to the Peter Principle. It got promoted beyond its competence.
Re:3rd Edition of Programming: Principles and Practice Using... by germandiago on Friday April 19, 2024 @03:55PM (#40091300)
Python does well for several reasons.

Some that come to my mind: its versatility binding native code and its easy-to-fit in your brain mental model for many tasks. The fact that you can script with Python without a compilation step also helped a lot to spread its popularity I think.

Re:3rd Edition of Programming: Principles and Practice Using... by rightbyte on Friday April 19, 2024 @06:11PM (#40092480)
The way you define the entry point function is so bizarre I assume scripting was the original use case.
Re:3rd Edition of Programming: Principles and Practice Using... by germandiago on Saturday April 20, 2024 @04:21AM (#40095741)
Could be. But it also gives you the flexibility to set tests inside the module files.
Re:3rd Edition of Programming: Principles and Practice Using... by AnimalMuppet on Friday April 19, 2024 @01:14PM (#40089414)
Having to use the wrong tool is not cool, ever. So I don't care how cool Rust is right now, I still am not going to use it for scripting.
Re:3rd Edition of Programming: Principles and Practice Using... by weinzierl on Friday April 19, 2024 @01:36PM (#40089723)
Have you tried it? How would you know that Rust is the wrong tool.

I'm indifferent when it comes to Python vs Rust for scripting, but I'd take Rust over a shell script (of any variety) any day.

Re:3rd Edition of Programming: Principles and Practice Using... by AnimalMuppet on Friday April 19, 2024 @05:30PM (#40092133)
There are many things I have not tried, ranging from Rust to heroin. "You don't know because you haven't tried it" is really bad epistemology.

It's also totally impractical. Rust isn't the only language I haven't tried; there are more than a thousand of them. I'm not using JOVIAL for scripting, or Fortran, or a bunch of others. No, I haven't tried any of those either. No, I'm not going to.

Turning specifically to Rust, I don't use it for scripting because it's not what I look for in a scripting language. It's compiled; I look for a language that doesn't have that extra step. It has the borrow checker; I don't write scripting code that needs that level of discipline and care.

In fact, most of my scripting is of the form "pick some bits out of a text file". For that, Perl is my tool of choice. Sure, other languages have regexes. None of them do it as cleanly and simply as Perl. (Note well: "clean" does not apply to the Perl syntax...)

Re:3rd Edition of Programming: Principles and Practice Using... by n_plus_1_acc on Friday April 19, 2024 @12:43PM (#40088995)
cargo -Zscript is in nightly
Re:3rd Edition of Programming: Principles and Practice Using... by weinzierl on Friday April 19, 2024 @01:32PM (#40089664)
> The idea of using Rust for scripting is bizaar.

Not at all, I do the same.

Re:3rd Edition of Programming: Principles and Practice Using... by steveklabnik on Friday April 19, 2024 @01:50PM (#40089906)
Incidentally, this thing comes up a lot: Python vs Rust for scripts. I wrote a comparison four years ago:

https://news.ycombinator.com/item?id=22712441

And updated it six months later:

https://news.ycombinator.com/item?id=24595081

That's still how I'd do this task today.

Anyway, I don't think that Rust is always a great choice for scripting, but if you already know Rust, it's totally fine at it.

Re:3rd Edition of Programming: Principles and Practice Using... by germandiago on Friday April 19, 2024 @03:41PM (#40091164)
Same for C++ with a good options library and std::filesystem IMHO. You can kind of script with that. I did it and was surprised it did well for some of my engine tooling.