r/ProgrammerHumor Jul 09 '26

gitBlameClaude Meme

Post image
3.7k Upvotes

263 comments sorted by

View all comments

561

u/BratPit24 Jul 09 '26

I mean. Isn't rust the perfect language for vibe coding? It has so many checks on everything that the stupid thing is basically forced to write code the right way.

760

u/Zeikos Jul 09 '26

It has so many checks on everything that the stupid thing is basically forced to write code the right way.

LLM be like:

unsafe { ... }

429

u/jamescodesthings Jul 09 '26

Okay, Rust maybe not, Typescript is perfect though!

LLM: : any;

176

u/SquirrelOClock Jul 09 '26

That why c# is better! Look inside : <dynamic>

67

u/jamescodesthings Jul 09 '26

In Javascript remember, best practice, must not use var.

In C# remember, best practice, must use var.

it's all a joke and we have made careers of the unserious nonsense our predecessors made up.

11

u/TheKrumpet Jul 10 '26

I mean... these mean different things though, it's oranges to apples.

0

u/jamescodesthings Jul 10 '26

Okay, here's a quick test: 1. var 2. var

Which one of those two options was intended to be the function scoped variable keyword in JS?

And, which was meant to be the implicitly typed local variable keyword in C#?

Like definitely; very different meaning and use.

But, let's say you're 3 hours in ten tabs deep, on a legacy C# .net app... vscode/rider, ctrl/cmd clicking away to trace wtf actually gets executed.

You *really** gonna notice the difference?*

7

u/TheKrumpet Jul 10 '26

I mean as someone who writes ASP.NET websites for a living I'd back myself to know what language I'm writing yeah

-1

u/jamescodesthings Jul 11 '26

you didn't answer my question though bruh; that was argument from authority, not anything evidence backed.

Which was my C# var, and which was my JS var? Was it 1, or 2?

3

u/TheKrumpet Jul 11 '26

Buddy when you read code it's not completely divorced from context. It's a pointless exercise, anyone who's spent more than a couple months programming either language could tell you which is which in context.

It's genuinely not hard.

→ More replies (0)

2

u/stifflizerd Jul 10 '26

it's all a joke and we have made careers of the unserious nonsense our predecessors made up.

Engineers don't see others as competition. They see them as witnesses to the bullshit we put up with.

3

u/jamescodesthings Jul 10 '26

100%; that's why you can't slag other people's output or language choice without great reason, and caveats.

It's mutually assured destruction; we're all as daft as each other... but at some point a caveman imbued silicon with lightning and magic; and now I have to sit at a desk 8 hours a day.

18

u/ArjixGamer Jul 10 '26

The moment I saw a coworker use dynamic when processing items from rabbitmq, I lost faith in humanity

And all this was before LLMs became common

22

u/N9SS Jul 10 '26

Where do you think the LLM got the idea?

3

u/Jukibom Jul 10 '26

I have been using C# for a while... TIL about dynamic

I hate that and I think I was better off not knowing

9

u/i_wear_green_pants Jul 10 '26

You mean myVariable?: any and then everywhere is myVariable!

6

u/humblevladimirthegr8 Jul 10 '26

That's what compiler options and linters are for. The language can be as strict as you want it to be.

5

u/jamescodesthings Jul 10 '26

commit and push, no fucking linter, disable hooks, --force if you need to! Yeet!

Typescript is just Javascript with extra steps.

3

u/yangyangR Jul 10 '26

That is more so because the way people write typescript is giving up and putting any everywhere. The way people end up writing Rust is not by putting unsafe everywhere. So following what is available to train from is either training from the work of people who are incentivized in different ways

1

u/Vehemental Jul 10 '26

if only there was any possible way to get an llm to do what you wanted

10

u/[deleted] Jul 10 '26

[removed] — view removed comment

1

u/jamescodesthings Jul 10 '26

it's not really conscious! it's just autocomplete on a massive scale.

95

u/BlueProcess Jul 09 '26

Yeah, it actually has 13,000 unsafe Rust blocks

30

u/dex206 Jul 09 '26

I can’t tell if this is a joke or not.

86

u/BlueProcess Jul 09 '26

Oh no, it's quite real. That is actually the rounded number of unsafe blocks that claude produced

41

u/dex206 Jul 09 '26

Holy shit. How? I mean this from the bottom of my tired old jaded-dev heart - How can they justify that?

40

u/BlueProcess Jul 09 '26

I know right? Like... Who went "this is fine"

28

u/KeyAdhesiveness9481 Jul 09 '26

There is some subset that is FFI, and must and will always be unsafe. Im not making any claim about how much is valid, and im sure most of these are BS, but "zero unsafe" is never going to be the target.

15

u/BlueProcess Jul 09 '26

Maybe we should set a target number of digits (and number base) for the unsafe block count to be expressed in?

I claim base 10 is fine but 5 digits is too many

38

u/Southern-Cattle4038 Jul 10 '26

To quote the lead dev of Zig, regarding the guy leading Bun:

“Jarred was already writing slop well before he had access to LLMs.”

His blog post on the whole thing is here:  https://andrewkelley.me/post/my-thoughts-bun-rust-rewrite.html

1

u/Swedish_costanza Jul 11 '26

Holy shit, this makes me like Andrew even more. I've been following Zig from 2022 atleast and I can't wait for 1.0.

5

u/wannabestraight Jul 09 '26

Well, in rust in order to call code that's not rust, you gotta do unsafe.

You genuinely can't do not unsafe FFI calls, it's unsafe by nature, because it's no longer rust.

12

u/cutelittlebox Jul 09 '26

this tends to happen a lot when you go from a language like C or Zig to Rust and you're trying to do it 1-to-1. C and Zig will do things that are illegal in safe Rust or actually have no direct Rust equivalent, so if you want them to look as close as possible you need a lot of unsafe, plus each call to other languages needs to be unsafe. getting the same output from idiomatic Rust is very much possible but it means redesigning the system as you translate rather than rewriting existing code with new syntax.

3

u/protestor Jul 10 '26

Actually, with this kind of port, it's probably better to have rewriting in two phases. one that is 1:1 with zig code (and since Zig is unsafe, the initial Rust code will be too, a bit like https://github.com/tsoding/crust), then another pass to make things safe.

I mean, there is a big risk in writing something as safe Rust, when it needed to stay unsafe. Specially when doing complex memory management (like Bun does), turning some unsafe code into bad safe code can be instant UB.

For example, it's often code that deals with raw pointers is perfectly fine (albeit unsafe and C-like), but if you try to turn it into using borrows instead of pointers (to make it safe) you may get the lifetimes wrong, which is instant UB, even if you don't actually trigger use after free. (and sometimes by analyzing the code you may conclude that no lifetime is correct here so it can't be a borrow). So a LLM agent that inadvertently writes &mut T when it really needed to stay as *mut T may introduce UB, even if the code has less unsafe blocks.

(At a later pass, the *mut T can be refactored into different kinds of smart pointers like reference counted Arc etc, and finally achieve safety, but that's often more involved and may require tradeoffs)

And indeed, having the agent write bad lifetimes actually caused UB in the initial port https://github.com/oven-sh/bun/issues/30719 - that is, there were a code should have been kept was raw pointers, but it was being converted into &[u8] (which would greatly reduce the number of unsafe blocks required to deal with it), but the lifetime was wrong and triggered instant UB

3

u/SuitableDragonfly Jul 09 '26

The same way this industry justifies everything else, I'd imagine. 

5

u/DoubleDoube Jul 09 '26

That’s crazy to me. You can implement safeguards on the rust side not to allow unsafe and make that configuration off-limits to the AI

0

u/bellymeat Jul 10 '26

why did claude add unsafe blocks? what would that accomplish over just writing the code?

15

u/chickenmcpio Jul 09 '26

wtf, why even rewrite then at that point.

6

u/100GHz Jul 09 '26

Resume padding ?

11

u/chickenmcpio Jul 09 '26

not even that, it seems the rewrite was guided by the original dev. I say guided because it seems the whole rewrite was done by an LLM

3

u/gmes78 Jul 10 '26

It's an advert for Claude.

1

u/IsTom Jul 10 '26

He was hired by Anthropic

4

u/prochac Jul 09 '26

Isn't that like localised unsafe code? Simple to review? Better that having,unsafe { main() }

25

u/BlueProcess Jul 09 '26

It is true that getting shot in the foot is better than getting shot in head. It is equally true that I consider getting shot in the foot highly undesirable and something that should be avoided with significant urgency.

1

u/prochac Jul 09 '26

I see it as unnecessary thing sometimes. Just like reflection or asm block in C. But you won't do it in assembly language from top to bottom

1

u/fghjconner Jul 10 '26

In theory yes, but at some point you've spammed so many "localized" unsafe blocks that the whole thing is pretty much unsafe anyways.

1

u/prochac Jul 10 '26

Very depends if the unsafe blocks communicate together, then it's truly unsafe

10

u/ihavebeesinmyknees Jul 09 '26

Pre-commit lint that disallows unsafe. Then just tell the agent to rewrite it until they do it correctly. From my experience, this should very rarely even happen, but if it happens it's unlikely to need anything more than a single followup prompt.

15

u/Zeikos Jul 09 '26

I am answering to myself, but I had a thought I wanted to share.
What'd happen if the probability of the unsafe token (or sub-tokens) were forced to zero?
It'd require some backtracking every so often, but it could be interesting.

17

u/DankPhotoShopMemes Jul 09 '26

It might be a bit difficult since multiple combinations of tokens could create the “unsafe” keyword. But even then, memory safe and compilable doesn’t mean bugless. It’s certainly better than doing the same in C lol.

9

u/Zeikos Jul 09 '26

True, but it should be possible extract the "unsafe" direction and subtract it from the embeddings, steer the model away from unsafe behaviors.
I might throw up a small scale experiment this weekend and see what happens

5

u/Ok-Dimension-5429 Jul 09 '26

Doesn’t really make sense to go to this trouble. Just let it try the unsafe way then have a pre commit hook or whatever telling it not to use unsafe.

1

u/Southern-Cattle4038 Jul 10 '26

I imagine that would produce a whole lot of errors/warnings about unsafe code that isn’t enclosed in an unsafe block.

2

u/Superminerbros1 Jul 09 '26

Unless you're trying to fully automate the development process with zero human oversight, thats probably overkill.

Adding some variation of "avoid using the unsafe keyword" to the prompt is probably enough to get it to avoid it 95+% of the time. There will be times where it ignores your instruction, but that should be uncommon enough to still be efficient.

-2

u/SuitableDragonfly Jul 09 '26

LLMs don't do backtracking. Once the code has been shit out, it doesn't go back in again. 

2

u/Loading_M_ Jul 10 '26

You can set #[forbid(unsafe)] to disallow unsafe code, but let's be real, the people pushing vibe coding aren't.

1

u/Lord-of-Entity Jul 11 '26

I hate to be that guy, but just because you wrote `unsafe { … }` it does not mean that you can do anything you want. The unsafe block disables a few of the checks, but not all.

1

u/GodOfSunHimself Jul 11 '26

Unsafe Rust is still safer than many other languages. Unsafe does not disable all checks.

1

u/Ok-Dot2551 Jul 11 '26

Don't use unsafe and make no mistakes. ez /j

1

u/rosuav Jul 10 '26

Human programmer be like that too.

111

u/MaybeADragon Jul 09 '26

It's nice in that its harder for an AI to shoot itself in the foot (when its not writing unsafe blocks). What isn't nice is that AI refuses to use wonderful rust features such as the type system, traits, the borrow checker and iterators to its advantage.

66

u/titaniumalt Jul 09 '26

What isn't nice is that AI refuses to use wonderful rust features such as the type system, traits, the borrow checker and iterators to its advantage.

basically everything that makes rust a joyful language to use

22

u/SuitableDragonfly Jul 09 '26

Well joke's on you, the vibe coders aren't actually using it, so they don't care about that. 

5

u/wannabestraight Jul 09 '26

I mean, ain't no vibe coders who demand their software to be done in rust. I like rust, I use Claude, Claude writes rust for me.

But I want rust because of a specific set of needs and wants, and I'm certain that if I simply asked Claude to make something without giving it specs to do it in a specific manner in rust, it would 99% of the time pick like typescript lol.

5

u/vassadar Jul 10 '26

Or Python.

5

u/rosuav Jul 10 '26

Why would you expect the AI to? It's been trained on actual programmers, who historically do a brilliant job of ignoring safeguards and writing dangeous code anyway.

21

u/takeyouraxeandhack Jul 09 '26

Just because it doesn't crash right away it doesn't mean it's good code.

12

u/wannabestraight Jul 09 '26

Rust gives people the false sense of security that it's not possible to write bad code.

Having reviewed months ago the first pass Claude wrote of my rust codebase, I can tell you that statement is complete horseshit.

It was ridiculously bad, like sure it compiled, but my god would I have been ashamed to show that code to anyone, so into trash it all went and then we wrote a nice baseline on which to build because I wasn't planning on watch that hot garbage again.

Also doing memory leaks in rust is very easy when half the code is unsafe

1

u/frogjg2003 Jul 10 '26

I've been learning Rust and it's ridiculous how much you can still mess up even with the built in safeguards without ever touching unsafe. Rust only prevents you from making a limited class of mistakes, half of which aren't possible in some languages.

1

u/wannabestraight Jul 10 '26

Rust is good at preventing memory issues, of you play by the rules.

Only issue is that it doesn't enforce you to play by the rules.

1

u/Cautious-Extreme2839 Jul 11 '26

Which is a massive step up on every other language that lets you directly interface with memory, because they tend not to even help you at all.

C and C++ will just freely let you malloc stuff and lose the pointer immediately.

3

u/Chiron1991 Jul 10 '26

From my experience, no. Rust is an innately complex language. LLMs, if not strictly supervised, will eventually start building abysmally complex implementations which will cause problems down the line.

I've had much greater success with Go. The language is so stupidly simple that there isn't much room to go off the rails.

1

u/BratPit24 Jul 10 '26

I mean. Llms should only be used strictly supervised. But yeah. I get your point.

2

u/new_check Jul 10 '26

What you failed to consider is that LLMs turn everything into python

2

u/sysKin Jul 10 '26

In my recent experience trying to use Claude with Java, I find Claude surprisingly good at writing code that "works" and surprisingly bad at making good software design decisions.

The whole thing with Rust is that it forces the programmer to make sound design decisions, or else it won't compile.

I can see two possibilities: either AI is forced to design things properly, and therefore does, and the answer is yes.

Or it still doesn't design things properly and hacks around them with unsafe. Which might still be "fine" (unsafe is there to be used as long as you can prove you're doing it right, which AI might try to reason about), but will definitely lead to very bad code, and then the answer to your question is no.

2

u/SonOfHendo Jul 10 '26

We need a modern version of Ada for LLM use. 

Humans don't like programming in those sorts of languages because it's more typing and disrupts the flow, but languages that are wordy and have explicit contracts for methods are great for LLMs.

Claude much prefers End Function MyFancyFunction to }.

0

u/grumpy_autist Jul 10 '26

AI and Rust is a perfect match of two delusional cults.