Hacker News new | ask | show | jobs
by itsweller 3498 days ago
This 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, the code is concise and readable, and the article was a short, pleasant read.

2 comments

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 Rust's type system helps a bit, because it forces me to consider weird portability issues (such as the way Windows permits slightly invalid Unicode, which Rust represents as OSString instead of String).

And of course, cross-compilation with MinGW is a real help. Sadly, OpenSSL still poses a fair number of portability issues, since it's notoriously difficult to link statically.

Yup, as someone who's done x-platform C++(Windows/OSX/X360/PS3/etc) for a large part of my career the cross platform support is incredibly well done.

Not having to deal with differences between MSVC, LLVM, GCC and other obscure toolchains is a blessing.

This is one reason why I enjoyed using Java so much in the early days, even without JIT.

The differences between MSVC, LLVM, GCC are nothing to worry about, compared with the early days of C89 or C++ARM in the process of being standardized, coupled with different levels of POSIX support.

> such as the way Windows permits slightly invalid Unicode

Windows allows invalid UTF-16 while Unixes allow invalid UTF-8.

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.

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!
For future reference the DOS command 'ren' does this.