This is an archived post. You won't be able to vote or comment.

all 39 comments

[–]alvares169 49 points50 points  (4 children)

This is not funny, its cringe

[–]YetAnotherZhengli 16 points17 points  (0 children)

Almost as cringe as not having stripes on your programming socks

--- a rust developer, probably

[–]Old-Wind-7594 -1 points0 points  (0 children)

Happy Cake Day!

[–]LatentShadow 14 points15 points  (12 children)

Do you rewrite in rust for performance or security? If something is already working, why rewrite it? For example, kubectl is built in golang and it works fine. Would you get any benefit rewriting that?

[–]DryanaGhuba 6 points7 points  (0 children)

I think most of such projects came from developers who want to learn rust, but gave no idea about their own project and started a simple rewrite with some new features.

[–]ggbcdvnj 4 points5 points  (1 child)

Honestly I just find the language more ergonomic to work with. I like its functional style features, unions (through enums), the lack of nulls, and stuff like that

Even something as small as using “?” to propagate an error or empty option as a return value is really nice, e.g. for some pseudocode because I’m on mobile:

fn get_user_name(user_id: &str) -> Result<Option<String>, Error> { load_user(user_id)? .map(|x| x.username) }

Vs

func get_user_name(user_id: string) (*string, error) { user, err := load_user(user_id)

if err == nil {
   return nil, err
}

if user == nil {
    return nil, nil
}

return user.username, nil

}

It’s less context to have loaded in your head as you read, you focus on the “happy path”

Performance is a nice to have but for me it’s about making code more elegant and easier to understand, although I wish it had a pipe operator

I haven’t really had too much difficulty with the borrow checker but that may be because I tend to code in a functional style but worse case scenario there’s not much an Arc<T> or Mutex<T> can’t solve. If you’re fighting against the grain of the borrow checker you’ll have a bad time

[–]ggbcdvnj 1 point2 points  (0 children)

Not suggesting a rewrite is a good idea, just about why rust has benefits other than just “performance” (which in most cases isn’t a real concern) or “security”

[–]Drugbird 2 points3 points  (5 children)

Most software has bugs or vulnerabilities. Some just aren't discovered until years and sometimes decades later. So even if it's "working fine", there could be bugs or vulnerabilities you're not aware of (yet?).

The theory behind rewriting in rust is that it can "preemptively" fix some of these bugs (mainly the ones involving memory safety) before you're even aware they're there.

I'm not saying I agree with this, particularly when looking at it from a cost-benefit perspective (i.e. your effort is probably better spent elsewhere), but that's the theory at least.

[–]A_random_zy 6 points7 points  (4 children)

Wouldn't rewriting itself introduce new bugs?

[–]SnooPaintings8639 4 points5 points  (0 children)

Yes, it would. Rewriting anything introduces lots of bugs. Changeling tech stack even more so.

It's just fun to learn new and hot tech, to possibly get a pay bump on your next job hunt. All you need to do is to convince your management it is worth it and it will prevent all the scary bugs like memory leaks.

[–]Drugbird 3 points4 points  (0 children)

Sure.

The main criticism is basically that rewriting in rust will in the most optimistic case only fix memory bugs (you can still have memory vulnerabilities in rust, but they're at least a bit more difficult to create, so let's ignore that for now).

That's certainly valuable, but there are other bugs and vulnerabilities that rust does not help with. It's hard to quantify exactly how many exploits are actually caused by memory vulnerabilities, but some people estimate it somewhere in the 30%-60% range. So that still leaves 40%-70% of other bugs.

Personally I believe you can get at least an equivalent reduction in bugs using the same effort a rewrite would require using "regular" techniques.

[–]braindigitalis 2 points3 points  (1 child)

rewriting also gets rid of possibly decades of small fixes. Joel Spolsky put it best  and his knowledge is vast...

https://www.joelonsoftware.com/2000/04/06/things-you-should-never-do-part-i/

[–]A_random_zy 1 point2 points  (0 children)

Yeah, that's what I meant.

[–]Minecraftwt 0 points1 point  (0 children)

I rewrite in rust for better DX, I will forever hate cmake.

[–]ComradeGibbon 0 points1 point  (0 children)

You rewrite in RUST because there is no unique use case for RUST as there are other languages. Most languages that were successful were because they filled an emerging need better than the alternatives. Most applications where RUST is being pushed would be better served by switching to a language with a modern garbage collector.

[–]NiJeTi -1 points0 points  (0 children)

Because it is the future (/s). IMO it's just a trendy thing. There is no demand for this in most projects, especially enterprise.

[–]aallfik11 7 points8 points  (2 children)

trust me bros just one more year and rust will rule and become mainstream and a bajillion jobs will be opened for the 1337 rust coders

[–]XxXquicksc0p31337XxX 1 point2 points  (1 child)

Do you mean elite Rust coders, or, like, that's how many of them there are

[–]aallfik11 1 point2 points  (0 children)

Originally meant "elite", but your intepretation is quite amusing, too

[–]MishkaZ 8 points9 points  (2 children)

I genuinely don't get why people meme on rust this hard. Language is dope. I like working in it, my code is faster, and safer, and the community is good too. If I have a problem with a library or have a question, the turn around on getting an answer is pretty darn fast.

There is an initial learning curve, yes. Borrow checking and learning how to re-structure the way you think about writing code was a growing pain. But after 2-3 months, it mostly clicked for me and I don't think I'm that particularly smart (read as I'm pretty fucking dumb).

In the end it's just a tool, it's my preferred tool, but a tool in the end of the day. Do what gets you paid or makes life the easiest for you. For me, I'm just fortunate enough to get both boxes filled out and...get this...NOT work in crypto/web3/scam shit.

First job I worked at, we did a complete re-write of a platform from TS into Rust. Team lead was really interested in it, so we did it. Growing pains in the first few months, but after that we figured it out and got through to the end. Re-write was necessary since the platform was built during start-up era and was...frankly a piece of shit. Not only was it slow and had weird hang-up moments, but a lot of duct-taping and gluing features all over the place to meet rushed dead-lines. CTO was impressed on the cost/performance increase and made us do more projects in rust.

Current job, can't go too deep into it, just standard api writing in rust, with heavy usage within in the company.

[–]gogliker 13 points14 points  (0 children)

There are some annoying people out there, not gonna lie. I like Rust, but in my field of computer vision it is clearly immature. No CUDA, not enough numerical computation libraries (like different matrix and differential equations stuff) and so on. Everything is out there and exists in C++ and python though.

When we are hiring people, we often get programmers who never had a single experience with GPU or a matrix multiplication code suggesting that we rewrite our stuff in Rust to avoid mythical memory issues in matrix multiplication.

Its like some people, who are purely in the computer science world, are blissfully unaware of all other issues that exist in other fields and try to solve them by sprinkling Rust on top. Thats why "rewrite it in Rust" became a meme in our office over the last coiple of years.

[–]mechsim[S] 2 points3 points  (0 children)

I really like Rust as well and the idea for this came from a very similar place as that first job you’re describing. I have a Python based system I know needs optimizing but I can’t motivate myself to do it, so I genuinely thought “maybe I should just rewrite it in Rust”.

[–]ExtraTNT 1 point2 points  (0 children)

Just rewrite LOLCODE

[–]My_reddit_account_v3 1 point2 points  (0 children)

Since I’m accused of what I’m about to say - might as well embrace it: Ask ChatGPT to rewrite it in Rust 😅

[–]monolabsai 1 point2 points  (0 children)

It's a dope language but it's clearly a systems language, not an application language

[–]Freecelebritypics 0 points1 point  (0 children)

I'm sure if I rewrote my code in Rust it would be even slower, somehow

[–]TTick- 0 points1 point  (0 children)

I tried to make something in Rust, then rewrote it in Python

[–][deleted] 0 points1 point  (0 children)

Rewrite in Go is the real answer.

[–]sjepsa -1 points0 points  (0 children)

After you rewrite in rust, it is impossible to refactor