r/ProgrammerHumor • • 3d ago

Meme someoneIsScreamingToUseRust

Post image
827 Upvotes

85 comments sorted by

147

u/Arnold_Rambo 3d ago

I am hearing a lot about rust, what's so special about it?

Is it's demand increasing?

210

u/itsTyrion 3d ago

it kinda is?

TLDR, you can do lower level tasks at speeds of plusminus C++ but it comes with a bunch of stuff for memory safety unless you explicity ask (e.g. for C interop) with the "unsafe" keyword.
In a time where CVEs drop by the tens, it's become yet more relevant.

makes it much harder to have memory safety issues like use-after-free, double-free, type confusion, out of bounds write, or overflow.

But, you pay with a learning curve that's pretty steep because more stuff is strictly enforced to be verifiably compile-time safe.

It will of course not protect you from CVEs from logic errors.

Also the userbase can be a bit of a cult, think "I use arch btw", that's part of why you hear about it a lot

60

u/entronid 3d ago

atp though i hear people talk about rust users talking about it being memory safe more than rust users

9

u/NotADamsel 2d ago

Because actual rust users don’t really care after a point. We care that it’s memsafe and very fast, or memsafe and can run natively on something, or memsafe and lets you say that you use Rust. If the only reason that you’re choosing Rust is memory safety you’re nuts, because we’ve got a whole planet full of memsafe langs that suck a lot less to work in and are just fine for 90% of what an app/web dev would want to do.

16

u/Arnold_Rambo 3d ago

Thanks for the reply!

6

u/Aldebaraaaaaaan 2d ago

It's so true, i love rust and i use arch, i was thinking i was special but i'm just caricature.

6

u/itsTyrion 2d ago

up the stairs to the 2nd floor, into the hallway, 3rd door to the right, pick up your free striped thigh highs

3

u/MadCervantes 1d ago

Cool kids are using nixos now haven't you heard?

2

u/headedbranch225 2d ago

Yo I am the same

10

u/ilnarildarovuch 3d ago

Not only a learning curve, but also to be enforced with rust ideas, rust-only supported architectures and funny experience when linking with another native code :D

19

u/No_Belt_9829 3d ago

Rust doesn't choose where to compile, it fully depends on LLVMs target architecture support. Rust can even compile to 7th generation consoles like PS3 (PPC64 ELF) and Xbox360 (PPC64 COFF/Xenon), tho they are not these targets specific and require a bit of fuckery to actually work. But they work!

2

u/ilnarildarovuch 3d ago

Still not tier1..

3

u/entronid 3d ago

fwiw im targeting a tier 3 target right now and i have std support and compiles for both my system and the target with 2 lines of config

-8

u/ilnarildarovuch 3d ago

Ah, it's slower than C and sometimes C++. Forgot about it

5

u/Nervous-Potato-1464 3d ago

It's absolutely a pain to program anything in. Holy fuck I wont do it. Also fuck macros.

2

u/headedbranch225 2d ago

What is wrong with macros, it's a very simple way to prevent code duplication, e.g if you are defining a struct with a lot of elements and want to rename the fields with serde, you can generate the definitions with a simple macro, and you can also define more complex macros that actually run code to generate stuff, and aren't just like more powerful C macros (macros by example)

1

u/Nervous-Potato-1464 2d ago

I don't like things that hide stuff personally.

48

u/Drfoxthefurry 3d ago

It's rust, 50% of its users are femboys and 90% of its users are required to recommend others use it or rewrite programs in it

7

u/glemnar 3d ago

The other 50% are furries

28

u/Arnold_Rambo 3d ago

I need a serious reply, man.

Too much unnecessary humour kills it.

I know I am in a programmerhumour sub, but I asked for the real reason

13

u/vivaaprimavera 3d ago

The compiler has some strict enforcement that can even "block" if variable memory allocations can't be determined at compile time (buffer overflow protection?), the full lifecycle of a variable has to be "verifiable" (no use after free or null pointers).

For someone who once had a life altering malloc issue, it pretty much sell the language.

1

u/Xlxlredditor 4h ago

Life altering? I'd like the story behind that if that's not a HIPPA violation or something

1

u/vivaaprimavera 3h ago

Life altering for me... It was a niche product and the demo (no second chances) to a customer failed because of a memory bug wasn't caught in the tests.

1

u/Xlxlredditor 2h ago

Ah man that fucking sucks

1

u/rosuav 2d ago

Yeah, except that every major Rust app uses the "unsafe" keyword to bypass those checks. Meanwhile, Fil-C can compile ordinary C code and is memory safe.

If malloc issues are the problem, use a higher level language with garbage collection.

0

u/ScallionSmooth5925 2d ago

Why would I choose this over something purely functional?

2

u/vivaaprimavera 2d ago

Compiled, speed, easy to make bindings for python (had memory issues with python). Seemed the logical choice.

3

u/ScallionSmooth5925 2d ago

Clean can reach the same spead as C. A lot of functional languages can be compiled. And you can build libraries if you whant. The pureness also alows for drastic obtimalizations that otherwise wouldn't be posible 

1

u/vivaaprimavera 2d ago

Might have a look at it. Thanks

1

u/Sarmq 2d ago

Clean can reach the same spead as C.

Does it in practice?

2

u/ScallionSmooth5925 2d ago

It can when done right. The naive approach is usually 1.5x slower. But it's much simpler to parallelise when you need a lot of computation fast

1

u/headedbranch225 2d ago

With things like rayon, parallel computation is pretty much drop in if you are dealing with a lot of vectors and stuff

2

u/pretty_succinct 2d ago

If you need a real answer you wouldn’t be looking in a programmer humor subreddit.

Furries, femboys and memes are the best we can do.

0

u/Medical-Hunt774 2d ago

If you need serious answer it's been like decade people talking about Rust. But it was usually used in some experimental projects, crypto startups and open source projects that try to rewrite something in Rust.

6

u/JVApen 3d ago

Rust is a programming language that forces memory safety by emposing strict rules on how you can use memory. (Only allowing 1 write access or multiple readers, no mix) It does have an escape hatch with unsafe.

It's especially useful in places where security is important like webbrowsers (where is was created) and operating systems. At those places it's definitely getting traction like on Android and Linux.

At the same time, other people already indicated that they are moving again away from it as it's too restrictive and doing a small change causes huge refactoring to keep the borrow checker happy.

Personally, I think it's a good replacement for C as everything interfaces with C and you can plug in new code in rust with your existing C code. Do you on the other end want to improve your C code gradually, C++ might be the better choice. It's also recommended by many people as replacement for C++, though I don't see that happening as you have to compromise your C++ design to create a C-API in order to interface with Rust. If anything, I expect more from Carbon for that. Though just like C is still around, while C++ is proven to be superior, C++ will stay here with rust, Carbon, Java, C# ... around.

6

u/Hohenheim_of_Shadow 3d ago

Rust does not have a stable ABI. This is a pretty huge deal when trying to replace C as a huge part of what C does is provide valuable libraries and services to other languages.

If you are idk, Python, you can have your code directly call out to a C library and it'll just work. It can get a bit tricky when you depend on specific versions of a library, but that is a workable problem.

With a Rust library, you could write your Python to successfully pass binary data to it in a format the Rust library understands, RustC updates and suddenly your program stops being compatible with the exact same library version.

The "solution" to this is called "hourglass APIs", where you don't call Rust functions, but C functions implemented in Rust. Which means a lot of the advantages of Rust kind of die when used as a library language because end users of the library still have to deal with simple C constructs. You can't pass a Rust String from Rust to X language, you have to pass a C String.

C++ has a similar problem, but ABI breaking changes are way rarer.

3

u/hyker1811 3d ago

Rust has been growing in popularity since LLMs became more and more mainstream.

Rust can write programs with speeds comparable to C/C++ but it has a bunch of added guardrails that ensures memory safety in compile-time.Thus far Rust was niche because working within those guardrails were really very frustrating and for a programmer, working with C/C++ was a much better developer experience.

Since LLMs write code now and they don't care about developer experience it makes much more sense to use Rust instead of C/C++. You basically have a very strict linter ontop of your low-level code built into the language.

11

u/InfiniteEnter 3d ago

I was intrigued by rust and wanted to learn it. But now it's kinda starting to sound like a language that is only used by vibe coders

30

u/FinancialTrade8197 3d ago

Mostly it's just cause it's really good for agents + a selling point.

Agents don't write the safest of code, so the compiler can guide them with that instead. That has caused a lot of AI projects to be written in Rust.

3

u/ariZon_a 3d ago

it's mostly that rust is harder to write so the code that's out there is of a higher quality (supposed to be) so whatever the model ingested is of higher quality from the start. ai is a shit in shit out machine.

8

u/helicophell 3d ago

No, rust is demonstrably a better language for AI to write in

AI code agents run in loops that pass when errors clear. It's test driven development

When a compiler fails on code, that is a failed test

A language like Python, which doesn't do static typing, is worse for AI Agents because you can get a runtime error instead of compile time

So by doing the opposite by adding memory safety to compile time / linter, you prevent AI code that doesn't do proper memory safety (and some other fuck ups). Strict languages are better for AI Agents

For the record, I don't like vibecoding. But I'll at least stay informed about it

2

u/SirCheesington 3d ago

Everything you're talking about is language infrastructure and ecosystem. Really, actually, default language infrastructure and default language ecosystem. You can do typechecking in python. You can enforce also, if you want, create poison types which fail at compile time if you use them wrong. The language itself has little to do with this. So saying it's a demonstrably better language is a bit silly. You can set up an environment for just about any language that an AI agent can leverage as well as a default or presumed rust environment.

1

u/headedbranch225 2d ago

You can set up that, yes, but it requires more tools and vibe coders to actually know the reasoning for doing it, which — given they are usually not programmers, or don't want to bother reading the code — is unlikely to be done by them

1

u/ariZon_a 3d ago edited 3d ago

i mean higher quality compared to what you could do in another language to bring in the same features/functionality. at the end of the day the ai is still basically trained on what programmers did up to the moment the training started.

you're not wrong, the ai will go into a sort of feedback loop when writing rust and compiling but the training also is a big part of why it does what it does. the model is not going to be perfect with only training so the test driven developpement style saves its ass on edge cases.

1

u/Wonderful-Habit-139 3d ago

It's not higher quality. Just protected well enough thanks to the guardrails.

1

u/ariZon_a 3d ago

which forces programmers to write better code.. which ends up being higher quality code compared to what you could do to achieve same functionality in another language

4

u/Wonderful-Habit-139 3d ago

No. LLMs still do not write idiomatic Rust code. You can still write bad Rust code in the confines of what's allowed to be compiled.

I'm not talking about Rust versus another language.

15

u/airodonack 3d ago

Lots of talented devs use Rust. Not just vibe coders. All the reasons it’s good for vibe coders are also good reasons for competent coders.

3

u/Mojert 3d ago

You shouldn't let that dissuade you from learning Rust (or any language) if you actually want to learn it. Rust can be neat and does things differently from other languages, so even if you don't end up using it, time spent learning it is not wasted time

1

u/DragonSlayerC 19h ago

It was exploding in popularity before AI. Honestly it may be even more important now as AI is very good at finding security bugs, and ~70% of security bugs are from memory handling, and Rust completely fixes that problem without needing garbage collection like other memory-safe languages.

2

u/SoulArthurZ 3d ago

the compiler does not compile code that would give memory issues in almost all of your code. Furthermore, the type system encourages less lazy design and discourages bad practices. For example, enums in C are just an alias for a number, but in rust they can hold arbitrary values. You can only use those values when matching a variant, and you'll get a compiler error if you forget a variant! Stuff like this makes the language a joy to write, makes refactoring easier, and really gives credence to "if it compiles, it works".

If youre interested in learning i could give some pointers on where to start

2

u/the_horse_gamer 2d ago

with languages like C/C++ you are able to write more performant code, but at the expense of memory safety issues

Rust's goal is to allow you to write code with equal performance to C/C++ (can actually be better due to aliasing guarantees and errors as values) without the risk of memory safety issues

and it's a modern language, so it gets to enjoy the benefit of hindsight, and build in ergonomics like discriminated unions and traits.

1

u/mrzerom 3d ago

Kinda, I've seen it being used for small devops utilities in place of go/python.

I've also heard that LLMs have a good time with the compiler, so maybe that pushes the "demand" but not really.

1

u/tylerr514 2d ago

I'll start by saying that paying jobs for Rust are slowly increasing but not very common.

Rust is special because it offers memory safety and performance without needing a garbage collector.

One of its biggest features is the borrow checker, which enforces ownership and borrowing rules at compile time. This prevents issues like use after free, dangling pointers, and data races before your program even runs.

For example, Rust won't let you modify a variable while an immutable reference to it is still being used. This prevents unexpected changes to data that another part of your code expects to remain unchanged.

fn main() {
    let mut value = 10;
    let reference = &value;

    value = 20; // Compile error
    println!("{reference}");
}

The compiler rejects this because "reference" is still being used when we try to modify "value". It even gives us a very helpful error message:

error[E0506]: cannot assign to `value` because it is borrowed

3 | let reference = &value;
  |                 ------ `value` is borrowed here
4 | value = 20;
  | ^^^^^^^^^^ `value` is assigned to here but it was already borrowed
5 | println!("{reference}");
  |            --------- borrow later used here

A few other things worth mentioning:

  • Memory safety: Rust uses ownership to manage memory, ensuring resources are properly allocated and released. This eliminates many common manual memory management bugs, such as accidentally freeing memory that's still being used.

  • Null safety and error handling: Null does not exist in Rust. Instead, Option<T> represents values that may or may not exist, while Result<T, E> handles operations that can succeed or fail. You have to explicitly handle both outcomes, commonly through "match" or the quirky looking syntax if let Some(t) = thing { ... } for Option and if let Ok(t) = thing { ... } for Result.

  • Concurrency safety: The type system catches many threading and data race issues at compile time. For example, it prevents multiple threads from modifying shared data without proper synchronization. This can occasionally be frustrating when seemingly sound code refuses to compile.

  • Zero cost abstractions: High level features compile into efficient machine code without unnecessary runtime overhead. You get things like iterators and generics without necessarily paying a performance penalty for using them.

  • Cargo: Built in tooling for package management, building, testing, and dependency management. Managing dependencies and building projects is generally very straightforward.

Rust definitely has a steep learning curve, particularly around ownership and lifetimes, but I'd argue C++ is a lot more complicated. You start to appreciate just how many things the compiler catches before they ever become problems.

1

u/Specialist-Leek-357 3d ago

long story short, it's like the new standard. comparable to C in performance but much safer from low level error.

the only downside i can feel so far is the size kinda massive, my 400kb rust app project folder is around 300 MB, this wont happen with C++

2

u/k-mcm 3d ago

Doing things that appear to be extremely unsafe is what makes C and C++ potentially so fast. C++, Go, Rust, and Java are all about the same speed for simple and safe code. The main difference between them being tailored to different uses.

1

u/Anreall2000 3d ago

Not really, having low level abstractions is what makes languages potentially fast, also C++ and Rust ideology are zero-cost abstractions, which very simplified is tradeoff for speed to compile time.

Go in your example, really prefer compile time over perfectly optimized abstractions.
Java don't have a lot of low level abstractions.

Also yeah, languages with runtime gonna be slower due to garbage collection and other stuff. It's just happen so, that there aren't that many new languages without runtime, Rust is the last popular one, and C++ is kinda terrible and outdated in many ways. C is good, but don't have that many level abstractions.

Unsafe memory management is kinda low level abstractions, but it's rarely utilized.

-4

u/Faholan 3d ago

Java? Fast???? You must be kidding. Let me remind you that Java isn't native code, it is interpreted by the Java Virtual Machine, which is a beast, plus it's dynamic dispatch which is necessarily slower than static dispatch

1

u/k-mcm 3d ago edited 2d ago

It compiles on demand. Simple code will benchmark similarly to C++.  The optimizations are different, so it will be a little faster or slower for different tasks.  The JIT can inline virtual methods based on live analysis, which is why it's sometimes faster. 

75

u/HumanMan_007 3d ago

Rust is very cool but C is probably a better first language.

13

u/Bemteb 3d ago

320x200 is an interesting screen ratio. Might match the resolution of the monitor shown maybe?

23

u/thondat 3d ago

it's the resolution of VGA mode 0x13, which was popular for its simplicity: just a flat pixel buffer at 0xA0000 with one byte per pixel as an index into a 256-color palette.

6

u/ekauq2000 3d ago

And now I’m taken back to QBasic and SCREEN 13.

12

u/igorski81 3d ago

It's indeed not 4:3 (which would've been 320x240) but there was a time when there were non square pixels (which is why Dooms cacodemon looks like a sphere in the sprite, but was designed to appear as an ellipse by the designers and on the screens of the time).

1

u/SylviaJarvis 3d ago

Also explains why Hell's inhabitants were all so...chonky.

2

u/ilnarildarovuch 3d ago

It's VGA 13h videomode with raw pixels (it's mapped to memory), so when writing to memory it's changing data on screen

2

u/ilnarildarovuch 3d ago

Half of all modes are text, other raw modes are in smaller resolution. (Higher only with VESA, but it's another thing)

9

u/kutac56 3d ago

Actually watched part of that one to learn how to use SDL for something. Was a pretty good tutorial

9

u/New_Salamander_4592 2d ago

I like graphics programming. Making games in c++ with openGL is a pretty fun inbetween of "CODE THIS FROM SCRATCH" and "I made a game in unity with prefabs :)". It's not too tough to grasp but still requires that you implement things like aabb collision by hand.

Though it was pretty annoying trying to find an audio player library because apparently one of the more popular c++ audio libraries has been not only abandoned but had it's online access points evaporated.

3

u/orlinthir 2d ago

I did aabb and swept aabb by hand. It was fun but had its torturous moments. What's wrong with sdl mixer as an audio library?

2

u/New_Salamander_4592 2d ago

yknow despite having done stuff with SDL3 in the past, I never came across SDL mixer when I was looking up usable audio libraries.

The one I was rec'd by the openGL resource I was looking at was irrKlang whose download page currently reads "Downloads are only available for existing licensees anymore, sorry." for both the regular and pro version, mispelling included.

Personally I ended up using miniaudio since it was only a header and class file and the documentation made enough sense to me at the time.

7

u/dryroast 3d ago

Having done SDL programming in C and Rust, I would say Rust can get in the way a bit if you're not used to the memory safety. I love graphics programming it's so much fun.

7

u/BugFeaturesOnly 3d ago

Me: "I'm gonna build a 3D game engine from scratch in C!"
Also me 4 hours later: Staring proudly at a single red pixel on a black screen

6

u/SeriousPug 3d ago

Sometimes you don’t want memory safety in favour of high speed. That’s what C is for

-3

u/-Ambriae- 3d ago

I would argue 1. C doesn’t mean higher performance, in fact for a newbie it might be slower to do things in C for a variety of reasons, 2. Yes you want memory safety. You just do.

That said, C is great for learning, and I would 100% recommend learning it before rust (even though I would nearly always choose rust over C for projects)

4

u/SeriousPug 3d ago edited 3d ago

1- Give me a single example where C loses in performance compared to other level languages.
2- rust std lib is full of unsafe calls. There are several stuff at kernel, driver level that are not memory-safe by design because ehm performance

Said that, i agree with your last point

2

u/-Ambriae- 3d ago

Well, ripgrep vs grep. More broadly speaking highly concurrent (multithreading and/or async) applications (which are completely doable in C, but require substantially more work, and thus are discouraged by the language itself). Another example would be highly monomorphised code, such as rust’s iterators, chumsky’s parsers, etc… not strictly speaking impossible to do in C, but allows for a high level of abstraction and code reuse whilst remaining aggressively optimised in practice. C specifically struggles there, especially in the world of data structures, there’s a reason people are still to this day using linked lists for everything… That said I do agree a language like rust has a similar problem with self referential data structures.

2. Rust stdlib is full of unsafe calls because A. It’s built to expose a safe API on top of unsafe constructs (such as the ISA or syscalls or FFI), B because unsafe is not an anti pattern. Many people write unsafe code in rust, it’s not to be avoided like the plague, you just need to be careful.

2

u/Yesterday622 2d ago

Peek and poke? lol

0

u/[deleted] 3d ago

[deleted] — view deleted comment

2

u/sisisisi1997 3d ago

Average C programmer when someonenuses something new instead of the language that came out in the 50s.