Live data from Hacker News

Using Rust for 'Scripting'

chriskrycho.com

61–70 of 126 posts

Re: Using Rust for 'Scripting'

#61

Was it too difficult to ask his friend to do right click -> create text document-> open it and write 'ren STAR.cha STAR.txt' -> save it as rename.bat and double click on it? Seriously, I'm not sure if this whole thing is a joke... edit: not sure why I cannot write the jolly character here

https://news.ycombinator.com/formatdoc

Re: Using Rust for 'Scripting'

#62
post #20

I love this idea. There's an implicit assumption that the reason scripting languages are suitable for scripts is that they play fast and loose with type systems, which allow enough shortcuts and escape hatches to be productive. But that's only part of the story. Along with typing, scripting languages also had the major advantage of being fast to bootstrap and run (`ruby script.rb`) and were fully "batteries included"…

>[...] the standard library is about as complete as you can get (and probably better than the classical scripting languages — all of Ruby/Python/Perl missed a good API for some things like HTTP, which led to the rise of separate packages like Faraday/Requests/etc)

What? Rust basically has no standard library. At least Python doesn't require pulling in third-party libraries to do globbing, create a zip/tar, create a tempfile or send/serve http. Hell, it doesn't even do command-line arguments outside of manually parsing and iterating over the args vector.

Re: Using Rust for 'Scripting'

#63
As someone who only very recently caught the Rust bug; seeing a reasonably small, familiar example like this is really helpful. Thanks for sharing. Maybe I can learn something by seeing if I can introduce threads/channels to the renaming part of the script as an exercise.

For anyone else curious about Rust, my own learning spree was triggered after reading the "A very brief intro to Rust" Slide Deck [1] by Ashley Williams [2].

[1] https://ashleygwilliams.github.io/a-very-brief-intro-to-rust...

[2] https://twitter.com/ag_dubs

Re: Using Rust for 'Scripting'

#64
post #11
post #4

>Writing it in Rust means I can compile it and hand it to him, and he can run it. And that’s it. As wonderful as they are, the fact that languages like Python, Perl, Ruby, JavaScript, etc. require having the runtime bundled up with them makes just shipping a tool a lot harder—especially on systems which aren’t a Unix derivative and don’t have them installed by default. I'm wondering what part of the twelve step compi…

> I'm wondering what part of the twelve step compilation process was found to be easier than simply installing Python on the target machine? That part is something that you can control. Giving instructions for someone non-technical to install Python and run a script with it, and then helping them figure out how to interpret those instructions, is a heck of a lot more complicated. And yeah, you can diddle around with…

> Giving instructions for someone non-technical to install Python and run a script with it, and then helping them figure out how to interpret those instructions, is a heck of a lot more complicated.

Training someone to accept binary file and run it without question is just dangerous.

Re: Using Rust for 'Scripting'

#65

Doesn't Windows have a built-in JavaScript runtime, the Windows Script Host? Sure, it may not be a very pretty language either, but it's still relatively sane compared to batch scripts. (I can't speak of PowerShell.)

I do like activex/js and wsh, but Wsh might require permissions to modify the filesystem, so installation/setup step can be harder than just copying and running a statically compiled executable.

Re: Using Rust for 'Scripting'

#66
post #64
post #11

Earlier quoted context omitted.

> I'm wondering what part of the twelve step compilation process was found to be easier than simply installing Python on the target machine? That part is something that you can control. Giving instructions for someone non-technical to install Python and run a script with it, and then helping them figure out how to interpret those instructions, is a heck of a lot more complicated. And yeah, you can diddle around with…

> Giving instructions for someone non-technical to install Python and run a script with it, and then helping them figure out how to interpret those instructions, is a heck of a lot more complicated. Training someone to accept binary file and run it without question is just dangerous.

Big difference between "run a binary from me" and "run a binary from anyone"

Re: Using Rust for 'Scripting'

#68
> As wonderful as they are, the fact that languages like Python, Perl, Ruby, JavaScript, etc. require having the runtime bundled up with them makes just shipping a tool a lot harder

Not true for js on Windows, though. Windows runs JScript natively (same language as JavaScript, only a different name).

Re: Using Rust for 'Scripting'

#69
post #66
post #64

Earlier quoted context omitted.

> Giving instructions for someone non-technical to install Python and run a script with it, and then helping them figure out how to interpret those instructions, is a heck of a lot more complicated. Training someone to accept binary file and run it without question is just dangerous.

Big difference between "run a binary from me " and "run a binary from anyone "

Not really. It rather easy to assume someone's identity online and then make target person to run the binary without thinking twice, especially if such practice is already established.

Re: Using Rust for 'Scripting'

#70
This topic is dear to me, I often deal with people without any software stacks on their machines and strict IT limits on installing new things. If I were on the same OS as the target user, I'd use pyinstaller. I've used it with very few issues over the past year on many projects. Most of them included Flask/Bottle and parts of numpy, it all worked like a charm. Cross compilation in Python is a bit of an issue, I for one have not resolved it in a satisfactory fashion (not saying it can't be done).

If one wants to be closer to the metal, Go's cross compilation works out of the box, without all the LLVM/MSVC work that Rust requires (for now, that is). As long as you use the standard library (and packages dependent on the standard library), it will work right away. I've cross compiled Go from my Mac for Windows users when I couldn't get my Python setup to do so, worked perfectly.

(Sure, you can script easy things as shown in other comments, this is a bit more general.)

Post reply on HN