Live data from Hacker News

Why Not Rewrite It in Rust? (2016)

transitiontech.ca

31–40 of 79 posts

Re: Why Not Rewrite It in Rust? (2016)

#31
My humble opinion: it is almost never worth rewriting a large codebase in a new language. The only exceptions are if (a) the old language is so old that it lacks an active community and is no longer being improved, or if (b) the old system needs so many changes that you might as well rewrite it anyway.

Re: Why Not Rewrite It in Rust? (2016)

#32
post #30

Earlier quoted context omitted.

If you haven't already, check out the Rust By Example section on this: https://doc.rust-lang.org/rust-by-example/std/str.html

The frustrating part was concatenation, it was surprisingly annoying to combine a few strings and an int into a single string.

The fastest and easiest way is to use format!.

  let cat = format!("{}{}{}", s1, s2, n);

Re: Why Not Rewrite It in Rust? (2016)

#33
post #16

a reminder that "rewrite it in rust" is not usually a ground up rewrite, it's an effort to translate the c into a safer language as you go, it doesn't just burn it down, salt the earth and start over. Have a look at remacs [1] to see how this works in practice. 1: https://github.com/remacs/remacs

And it will all be well taken if RIIR folks show things they have done themselves instead of telling others what they need to do.

Re: Why Not Rewrite It in Rust? (2016)

#34

As a D user, I am looking at Rust with curiosity, but haven't yet seen any reasons that would make me switch.

Sum types (and therefore a nice way to do e.g. validation or error handling). A better OO model (particularly when it comes to secondary concerns like serialization or comparison). Safe scoped resource management (with memory-safety without GC as a secondary benefit). A more standard/better-understood way of doing what D calls "compile-time reflection" (if I understand what D's doing there correctly).

Re: Why Not Rewrite It in Rust? (2016)

#35
post #19
post #4

Writing a few lines of "why not rewriting it in XXX" is more a sign of inexperience or immaturity in my humble opinion. Maybe it is a good idea, but if you are going to propose to a dev team a massive rewrite that will take months or years, you should at least have the decency to analyze the code base, do a small POC, profile some part and point out where the improvement could happen. (And if you've discovered someth…

Programmers, especially naive ones, tend to think asymptotically. We focus on what would be the most theoretically ideal and write off pithy concerns like "time" and "effort" as implementation details. I'm guilty of this myself. Rust is this unusual situation where a new language is in many ways a strict improvement over a very widely-used preexisting language. That is extremely rare. So I think that's where the reli…

> those projects also benefit from decades of refinement and bug fixes. Rewriting them means losing all of that.

Not my experience at all, having spent a significant chunk of my career doing rewrites for scalability. Having the existing codebase makes it very easy to benefit from the accumulated knowledge, while at the same time doing a pass through that can catch a lot of outright errors. If you can rewrite a project incrementally while keeping it working (and for C->Rust, you can), then the arguments against rewriting your code don't apply, and I'd actually consider full rewrites a useful exercise even if you weren't rewriting to a better language.

Re: Why Not Rewrite It in Rust? (2016)

#36
post #26

I feel like all the language comparisons are largely missing the point, at least for me. I don't write (mostly orthodox) C++ because it's a great language. In fact, I think it's a terrible language, hampered by a myriad of systemic issues that will never be addressed and seem to be getting worse over time. However, I also don't write code in a vacuum and other things matter more to me than language features. First-cl…

If you had a code base in Rust would you consider rewriting it in a language with First-class GPGPU support, a mature ecosystem (including some of the highest quality, most efficient code that exists), vastly superior tooling and multiple established compilers?

If my code runs slow because of lacks in one of the things you list I'll probably rewrite that part of my code. Note that I wouldn't rewrite everything, at least not at first.

In almost all cases though, the that fact that my codebase is working means the ecosystem, tooling and compilers are good enough as is and so I won't have a compelling reason to rewrite. I can get great programmers productive in Rust faster than the boss can figure out that neither I nor the new guy knew anything about rust on the first day.

Typically the only time the factors you mention come into consideration is a brand new project. I will generally know before I write the first line of code if I need GPGPU support or not. I ecosystem, tools, and existence of compilers are just a few of trade offs I will consider.

Re: Why Not Rewrite It in Rust? (2016)

#37
This is somewhat reminiscent of people who complain endlessly when a piece of software is still 32-bit, for purely nebulous reasons. People want things to feel clean and new, or they get an icky feeling that never seems to go away.

Re: Why Not Rewrite It in Rust? (2016)

#38
I was tinkering with crosscompiling Rust to arm/aarch64 just yesterday. Rust has a ways to go before it can catch up to C/C++ for cross compiling.

Edit: I should explain a bit. C has had the concept of cross compiling baked into it for decades. It's a well established, easy path. By dint of C, C++ comes along for the ride. Lots of linker is magic required for bare metal C programming. Weird flags required for arch-linux-gnueabi cross compiling. Rust is very new and just doesn't have that history yet. It's an opportunity for someone who has a lot more spare time than myself. :-)

Re: Why Not Rewrite It in Rust? (2016)

#39
I have some toy search technology (indexer and query processor). I started in C and did a series of rewrites, learning and changing something significant each time.

On version 6 I switched to Rust (having only just started learning the language) and it feels pretty unlikely I'd switch back.

The rookie mistake isn't to want a rewrite. It's to ridicule something you haven't tried in earnest.

Re: Why Not Rewrite It in Rust? (2016)

#40
post #5

As a D user, I am looking at Rust with curiosity, but haven't yet seen any reasons that would make me switch.

I think Rust is such a well designed language. But as someone coming from more high-level languages I sometimes feel a bit lost due to not getting as much help from the IDE as I'm used to for C# in Visual Studio and Java in IntelliJ. For Rust I've only tried IntelliJ with the Rust plugin, which seems like the best choice for what I'm after.

The level of IDE integration has little to do with whether a language is 'high-level'. In fact, the more abstract a language, the more likely it is to be difficult to do complicated analysis.
Post reply on HN