Live data from Hacker News

Using Rust for 'Scripting'

chriskrycho.com

101–110 of 126 posts

Re: Using Rust for 'Scripting'

#101

Earlier quoted context omitted.

Totally fair. I summed up that way because this is the kind of thing I'd have done with Python historically, and it struck me as neat that it's so easy to do with Rust. As someone pointed out on Reddit: this isn't really "scripting", and that's correct. I put it in "scare quotes" for a reason. ;p

Is it fair to assume the actual task was more complicated than renaming .cha to .txt and you just made it more generic here for example's sake?

No, actually: it really was that simple, and I told my friend it was a super simple thing.

I took the fact that it was so simple as an excuse to do the more complicated things alongside a very simple piece of code. That way, it's easy to see what the code does and then think about the implications of being able to run something like it (including something more complicated) cross-platform.

Re: Using Rust for 'Scripting'

#102
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…

My friend actually has the source code, so yes, he could do all of this. :) Also, worth note that these "twelve steps" are: - inclusive of literally everything including installing Rust and adding dependencies; this is like including "install Python" and "pip install" for a Python tutorial. The point was to be approachable for anyone . I think it succeeded. - inclusive of the "copy the executable to hand to a friend"…

> It's almost like I was intentionally using this tiny project (which isn't especially interesting in its own right; as many have noted it's a one-liner batch file) to provide a one-stop shop for the basics of getting a cross-compiled setup with Rust. ;)

That was my initial thought reading this. Even the most devout Rust enthusiast wouldn't go to this much trouble to avoid executing 'find' one would hope (yes, find does everything you need here for those wondering)

Re: Using Rust for 'Scripting'

#103
post #80
post #77

Earlier quoted context omitted.

You help a friend by giving him a one liner COMMAND.COM shell script, instead of turning it into a cross-compiling hackfest just because you're a Rust fanboy (in author's own words).

How is the one-liner shell script more helpful to the friend than the resulting binary? Yes it was convoluted but the point was the code author had to jump through hoops, not the end user.

Then the code author should have jumped through the hoops to learn Windows shell scripting, instead of purposely overcomplicating.

When I see things like these, it honestly makes me hate computers and IT.

Re: Using Rust for 'Scripting'

#104

It's a shame the author didn't frame this article differently by strictly focusing on how to cross compile a simple rust app on macOS and Windows. The focus on "scripting" seems to have really brought out the negativity in people here. I definitely learned something, I had no idea I could compile a Windows binary from my Mac.

The author here: I agree with your assessment. Apparently the scare quotes didn't convey my intent: it's easy to do something (including cross-platform) where I normally would have used a traditional scripting language, and the portability is nice. ¯\_(ツ)_/¯

I agree that it was very useful, despite the issue with the topic of choice. Thanks for writing it!

Re: Using Rust for 'Scripting'

#105

Earlier quoted context omitted.

Is it fair to assume the actual task was more complicated than renaming .cha to .txt and you just made it more generic here for example's sake?

No, actually: it really was that simple, and I told my friend it was a super simple thing. I took the fact that it was so simple as an excuse to do the more complicated things alongside a very simple piece of code. That way, it's easy to see what the code does and then think about the implications of being able to run something like it (including something more complicated) cross-platform.

Yeah, I read further in the comments and saw you say what I had meant here. Either the example was stripped down or there was a bigger picture reason why to do this rather than invoking 'find'. Thanks for writing this!

Re: Using Rust for 'Scripting'

#106
post #80

Earlier quoted context omitted.

How is the one-liner shell script more helpful to the friend than the resulting binary? Yes it was convoluted but the point was the code author had to jump through hoops, not the end user.

Then the code author should have jumped through the hoops to learn Windows shell scripting, instead of purposely overcomplicating. When I see things like these, it honestly makes me hate computers and IT.

No real hoops to jump; I'm sure I could have googled the batch script invocation for him easily.

Again: the point was simply to use an interesting "hook" and then segue into providing resources on cross-compiling with a super-simple example.

Re: Using Rust for 'Scripting'

#107
Its all about using the right tools / language for the job. And most of the solutions mentioned here are not the right tool for the job. Install python?? install this, install that. All the guy needs is a simple .exe file for windows that doesn't come with a manual howto install it.

Re: Using Rust for 'Scripting'

#108
post #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…

I've had great luck with Go as well. The cross compilation just works and the binary is easy to distribute.

Re: Using Rust for 'Scripting'

#109
post #42

Earlier quoted context omitted.

So, I'm going to stop you right there on the fast to bootstrap & run... Certainly Java is kind of a hybrid worst if both worlds kind of thing, but C/C++? For simple scripting problems you don't need complex build logic. You can usually get by with "cc foo.c -o foo", which you can embed in the source file. Sure, if you have library dependencies it can be a bit more involved, but most modern IDE's (even less than moder…

A bit tangential but here goes: I have some friends whose background is mostly algorithmic problems in competitive programming environments. I enjoy that kind of practice occasionally, but for them, it's the 90% of code they've written, and they are just too good at that stuff. This means they know C++ best, as this is usually the language you use in those competitions. It's interesting to see the approach to scripti…

Throw in cling or cint and you are good to go!

Re: Using Rust for 'Scripting'

#110
post #76
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.

Have you been using windows in the past 5 years? Accepting random binaries from the net and running them is the main software distribution model.

I am talking about scenario that "a friend" gives you binary to run. It is different from downloading software from a trusted source.
Post reply on HN