Live data from Hacker News

How to not rewrite it in Rust

adventures.michaelfbryan.com

1–10 of 231 posts

Re: How to not rewrite it in Rust

#3
I think this is a clever concept and useful article. However, I have to disagree with the severity of this statement:

> at best, the temptation to RiiR is unproductive (unnecessary duplication of effort)

For tiny, mature libraries, this might be true.

But a rewrite in Rust can also vastly improve maintainability. If a library is under heavy maintenance (and will continue to be), your investment in rewriting it is likely to pay dividends by saving developers -- especially ones who are new to the library -- a lot of time.

Re: How to not rewrite it in Rust

#4
"A much better alternative is to reuse the original library and just publish a safe interface to it."

I think I must reject the premise a bit, unless I misunderstand how Rust works.

If you write a safe wrapper around unsafe code, is it not still the case, that if the unsafe code bombs out, it will take the safe Rust down with it, engulfed in shared flames?

(Unless you spawn unsafe code in its separate process or something elaborate like that.)

(Then again, from a practical standpoint the reasoning may be good. Maybe, even likely, the C library is very good and very battle tested. And very likely, my novice would be re-implementation in Rust would not be very good.)

Re: How to not rewrite it in Rust

#5
> This may be problematic because it’ll require all users of our chmlib crate (and their users) to have Autotools installed.

Autoconf creates a portable shell script, right? No need to have it installed just to build the project.

Re: How to not rewrite it in Rust

#6
I still have issues with Rust string handling. Half of the time I have no idea how to get strings out of libraries. I don't understand the intentions of the language creators at all. Does anybody have a great intro to Rust for software engineers who come from Python or something similar where high level types are the norm?

Re: How to not rewrite it in Rust

#7
post #5

> This may be problematic because it’ll require all users of our chmlib crate (and their users) to have Autotools installed. Autoconf creates a portable shell script, right? No need to have it installed just to build the project.

"portable" to different Unices, right? I'm on Windows, for example.

Re: How to not rewrite it in Rust

#8

I still have issues with Rust string handling. Half of the time I have no idea how to get strings out of libraries. I don't understand the intentions of the language creators at all. Does anybody have a great intro to Rust for software engineers who come from Python or something similar where high level types are the norm?

All of Rust's complexity for strings comes out of complexity due to UTF-8. Well, a tiny bit comes from the fact that Rust has pointers too, but most of it is UTF-8.

Did you happen to read the book? We cover strings early because this is a common pain point.

Also, if you have something more detailed than "get strings out of libraries", I can give better advice. It's tough to tell what the actual issue is.

Re: How to not rewrite it in Rust

#9
post #5

> This may be problematic because it’ll require all users of our chmlib crate (and their users) to have Autotools installed. Autoconf creates a portable shell script, right? No need to have it installed just to build the project.

The tree only contains configure.in, not the generated configure output, and Makefile.am, not the generated Makefile.in. You do need the entire autotools suite installed for it to build.

Why they published it like this is beyond me, however. The whole point of autotools is not making your users install them (unlike CMake and virtually every other build system for C there is).

Post reply on HN