Earlier quoted context omitted.
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.
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).
Using Rust for 'Scripting'
91–100 of 126 posts
Re: Using Rust for 'Scripting'
#92Earlier quoted context omitted.
>[...] 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 t…
it sort of does, though. Trying to use urllib2 is like pulling teeth
>>> import httplib, json
>>> conn = httplib.HTTPConnection("httpbin.org")
>>> conn.request("GET", "/get")
>>> res = conn.getresponse()
>>> print res.status, res.reason
200 OK
>>> data = json.load(res)
>>> print data
{u'origin': '0.0.0.0', ...}
>>> conn.close()
[1] https://docs.python.org/2.7/library/httplib.html#examplesRe: Using Rust for 'Scripting'
#93It'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. ¯\_(ツ)_/¯
Re: Using Rust for 'Scripting'
#94I 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 t…
zip = "0.2"
tempfile = "2.1.4"
getopts = "0.2"
hyper = "0.9.12"Re: Using Rust for 'Scripting'
#95While this can be seen as an interesting exercise, I can't help but feel that rust isn't the best tool here. First, there are a handful of existing tools, as other have pointed out (I would personally go for AntRenamer). Then, there are a few scripting languages already installed (admittedly maybe not the best or most well-known). A quick Google search would probably have given a result right away, since this is a pr…
For MSVC over MinGW/Clang: part of my point here was to first learn and then document for the community how you do cross-compilation for MSVC. There are lots of projects out there where being able to link against MSVC is important, and it's also harder than linking against MinGW (which would have just been `rustup target add x86_64-pc-windows-gnu` and `cargo build --release --target=x86_64-pc-windows-gnu`, I believe; no extra linker stuff needed), so there's more value in documenting it and putting it out there for MSVC.
Re: Using Rust for 'Scripting'
#96One could also use Haskell [0] for scripting [1] using the turtle [2] library. turtle is a reimplementation of the Unix command line environment in Haskell so that you can use Haskell as both a shell and a scripting language. [0] https://www.haskell.org/ [1] http://www.haskellforall.com/2015/01/use-haskell-for-shell-s... [2] http://hackage.haskell.org/package/turtle
Re: Using Rust for 'Scripting'
#97http://www.pyinstaller.org/ Single file executable. Job done. Of course, if you want to write something in Rust, it's not much use.
Re: Using Rust for 'Scripting'
#98gci c:\somedir -r -filter "*.ext1" | %{Move-Item $_.FullName -Dest ($_.DirectoryName + "\" + $_.BaseName + ".ext2")}
Re: Using Rust for 'Scripting'
#99This reads less as “Python style scripting in Rust” and more as “I like Rust, also it’s cross-platform.” Not that this is a bad thing, but it feels like a bit of a far cry from my hacked together workflow of throw code in iPython and write out when I’m happy. I don’t see anything here that makes Rust any more attractive than whatever your multiplatform language of choice is for this use case scenario. That being said…
I've been using Rust to build a relatively large cross-platform command-line tool, and I've been genuinely impressed at how easy it is to get things to work on Windows. The Rust standard libraries Just Work on Windows, and they provide pathname handling, threads, environment variables, and a wealth of other tools. Many third party libraries will build for Windows without any problems as well. I actually do think that…
Windows allows invalid UTF-16 while Unixes allow invalid UTF-8.
Re: Using Rust for 'Scripting'
#100This reads less as “Python style scripting in Rust” and more as “I like Rust, also it’s cross-platform.” Not that this is a bad thing, but it feels like a bit of a far cry from my hacked together workflow of throw code in iPython and write out when I’m happy. I don’t see anything here that makes Rust any more attractive than whatever your multiplatform language of choice is for this use case scenario. That being said…
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