Live data from Hacker News

Using Rust for 'Scripting'

chriskrycho.com

51–60 of 126 posts

Re: Using Rust for 'Scripting'

#51
Nice to see how good Rust is for 'scripting'. I think Go would have been a better choice from a purely technical point of view - it's easier to write, and has even easier setup and cross-compilation than Rust. But I guess part of the point of this was to practice Rust so fair enough!

Re: Using Rust for 'Scripting'

#52

This is over engineering if I've ever seen it. For one this is a single line bash script that would allow you to even handle drag and drop. Best user experience. Second, if you're going to over engineering just look for someone who has already done that for you: http://www.den4b.com/products/renamer It's no use to engineer something that has been solved (unless you're learning) if there are already better solutions.…

I'm pretty sure the author was just practicing Rust. And although in this case using Bash would be fine, in most cases you shouldn't distribute Bash scripts. They're virtually always filled with bugs and they don't work on Windows.

Re: Using Rust for 'Scripting'

#54
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 agree. Instead the "friend" is taught the bad behavior of running untrusted (and I didn't see any tests, so untested and undocumented too) code in binary format on their machine. The glob-rename is exactly the sort of problem a script is supposed to solve easily. I feel the author justified the use of Rust and cross-compilation simply to avoid usage of a Windows OS (or VM) for such a trivial task. If the goal was t…

And as the author said, they don't know PowerShell or batch files very well. They also didn't pretend they had a strong justification for doing it. Rust was what they wanted to use, and hey look, Rust let them do it _and_ cross-compile it. I don't think there was an intention to say that everyone should do this instead of using shell scripts.

It's not untrusted code, it's code that a friend wrote to help you out. That's not at all the same as installing random untrusted code off the internet. I write code to help out my friends with things they want to do - are you saying they shouldn't accept it from me just because they can't code themselves? I can give them the source code, but what good is that to them when they can't program and don't want to?

Re: Using Rust for 'Scripting'

#55
post #35

The amount of contortions the author has had to go through is ridiculous, and all because the target operating system is Windows, and doesn't yet ship a production ripe UNIX userland (hence no AWK, sed, or zsh/tcsh/ksh out of the box). As a colleague of mine always says: give Wintendo no chance!

Despite that, Windows is still the most popular desktop OS in the world by an enormous margin. You don't help a friend who needs to rename a load of files by saying "well, it'd be much easier if you first installed Linux". Or cygwin, or even the Windows Subsystem for Linux if they're running Windows 10 Anniversary Update.

Re: Using Rust for 'Scripting'

#56

This guy has likely not prototyped in environment such as Jupyter notebooks or ptipython. It is not just language - there is whole ecosystem build around Python scripting: pandas, matplotlib, numpy, etc. And don't forget about debuggers and IDEs once your projects grow out of scripting environment. Did I mention hooking up to GUI or web app?

Which is all completely irrelevant for the task he had.

Re: Using Rust for 'Scripting'

#57
post #30
post #25

Earlier quoted context omitted.

The Windows rename command doesn't support recursively processing subfolders, but it can be achieved using one line of powershell: Get-ChildItem . -Recurse -Include *.cha | Rename-Item -NewName { $_.name -Replace '\.cha','.txt' }

From what I remember Include will only match items from the base directory and powershell gets stupidly complicated very quickly: http://flukus.github.io/2015/03/13/2015_03_13_Powershell-is-...

That compares Powershell to Nant. Nant tasks (inspired by Ant tasks) are more powerful than regular commands. Not even shell commands match those. He's comparing apples with an apple pie there.

Re: Using Rust for 'Scripting'

#58
post #38

Earlier quoted context omitted.

Python scripts can also be compiled to an exe file, although I think that the following batch one-liner is the best for this job: for /r startdir %%i in (*.cha) do ECHO ren "%%i" "%%~ni.txt"

Yep, one liner crushes the problem because a shell script is the perfect tool for the job!

EDIT: nvm, I can't read properly...

Re: Using Rust for 'Scripting'

#60
I think the author wanted to write "Using Rust instead of 'Scripting'". Perfectly makes sense. Nicer features, static types, compiled code, no runtime on the host system, etc. I prefer OCaml over Python,Bash etc for CLI apps, for the same reasons.
Post reply on HN