Live data from Hacker News

Why Not Rewrite It in Rust? (2016)

transitiontech.ca

71–79 of 79 posts

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

#71
post #58

Everyone seems to act like the only option is to rewrite everything or nothing. Isn't possible to have rust and C talk to each other, and progressively rewrite the most relevant parts of the code in rust?

You could make a case for sharing a wasm-style byte array with a C subprocess, but Rust objects won't be safe if C can address them.

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

#72
post #11

Earlier quoted context omitted.

Rust may hopefully get better autocompletions if they work on their Language Server implementation. C# compiler was explicitly rewritten so that it is IDE friendly and I fully agree with this decision. That said even good, old Java has excellent tooling support that I do miss from all these hip languages (such as Rust).

The compiler team is planning on following in C#’s footsteps with the rust-analyzer project.

That would be great! One thing that makes working with a language pleasant is good tooling.

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

#73
post #30

Earlier quoted context omitted.

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);

steve, think I sent you an email before and you responded, but just wanted to say again the Rust Book is a work of art. Since I read it and emailed you, I completed a fairly non-trivial Grad School project entirely in rust. I took a lot of the shortcuts, but the rust book was an excellent primer.

Best intro documentation of any language I have tried to learn recently.

EDIT for those who havent seen it: https://doc.rust-lang.org/book/

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

#74

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.

The old system needs a big change; it's flaky and riddled with security flaws because the old language encourages undefined behavior. C was a big improvement on assembly, but it's also the leading reason everything we rely on fails frequently.

I agree! But the cost of such a move across the industry would be incredibly high, probably taking decades of highly expensive investment. Is it really worth the cost for all projects?

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

#75

Earlier quoted context omitted.

The fastest and easiest way is to use format!. let cat = format!("{}{}{}", s1, s2, n);

steve, think I sent you an email before and you responded, but just wanted to say again the Rust Book is a work of art. Since I read it and emailed you, I completed a fairly non-trivial Grad School project entirely in rust. I took a lot of the shortcuts, but the rust book was an excellent primer. Best intro documentation of any language I have tried to learn recently. EDIT for those who havent seen it: https://doc.ru…

Thank you! <3

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

#76
post #28

Earlier quoted context omitted.

Because 'R' as a name is already taken. Even if it weren't, it would lead to too many bad pirate jokes.

Call it "Dust" instead of "R".

Call it 'IronDust', put it on the CLR, and have all of the meta jokes.

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

#77
post #35

Earlier quoted context omitted.

> 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 projec…

Maybe. But even with the old code base for reference, it's easy to not see that those weird lines right there are written the way they are to handle two different corner cases (and of course there's no helpful comments to explain it). This is especially true if you're rewriting from $MORE_OPAQUE_LANGUAGE to $CLEARER_LANGUAGE. There can be a lot of not obvious things going on in the opaque stuff, and you can drop thin…

> There can be a lot of not obvious things going on in the opaque stuff, and you can drop things you need in the rewrite unless you are very careful.

If the knowledge is so opaque as to be nonobvious from the code in front of you, then it's already an accident waiting to happen: someone making normal maintenance changes to that code (not a rewrite) would be equally likely to break those properties.

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

#78
post #5

Earlier quoted context omitted.

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.

VS Code support is good too. https://areweideyet.com/

Such tables are tricky. What does it mean to have syntax highlighting? For languages like C, it means that keywords, numbers and strings are colored differently. But for languages like Java/C# it's not enough, expectations are different. For such languages you expect class names to be colored differently than variable names, and IDEs for other languages rarely provide that.

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

#79
post #53

Earlier quoted context omitted.

The fastest and easiest way is to use format!. let cat = format!("{}{}{}", s1, s2, n);

They should do string interpolation like C# since C# 5. Really easy to use, type safe and avoids a lot of mistakes.

It is possible to do string interpolation in Rust with a macro:

https://docs.rs/interpolate/0.2.3/interpolate/

Post reply on HN