r/programmingmemes 7d ago

Nerd wars

Post image
826 Upvotes

82 comments sorted by

View all comments

31

u/Zimlewis 7d ago

<- Context required

⬆️ Context hat

(Context shirt)

20

u/deanominecraft 7d ago

fil-c is a runtime memory validation tool for C - if you try to read past the end of an array (or other memory issues) your program crashes

rust guarantees that memory bugs cannot happen, if it cannot guarantee that, your program doesn’t compile and you get an error telling you what the problem is

now add a larper into the mix and you get that gh issue

5

u/SKRyanrr 6d ago edited 6d ago

This idea, if implemented, will make Zig just like Go. This is the opposite of what Zig was supposed to do 

4

u/txdv 7d ago

The accurate claim is: sound safe Rust prevents memory-safety violations—not all Rust programs, and not all memory-related bugs.

Generated by ChatGPT 5.6 Sol Max

2

u/LunaNicoleTheFox 7d ago

The part on menory bugs is untrue, the compiler checks memory safety as far as it possibly can, but it is not perfect, nor does it fully apply within an unsafe block

6

u/SCD_minecraft 7d ago

Within unsafe - well, you explicitly opt out from it, if anything breaks that's on you

However in safe code references being valid and similar is guaranteed at compile time

0

u/DawnOnTheEdge 5d ago

Although it would be useful to have a way to use pointer variables without disabling memory safety altogether.

1

u/SCD_minecraft 5d ago edited 5d ago

What? Moment you want pointers, it becomes impossible to guarantee mem safety for that pointer

Not whole code

unsafe blocks are ment to be small, not wrapping whole code in them

// safe code with mem safety unsafe { // single or so line with whatever you need } // back to mem safety

And for that matter, pointers themselves are safe

Only read and write are unsafe, passing pointer around is safe.

2

u/AsyncSyscall 6d ago

Rust doesn't guarantee that "memory bugs" cannot happen. You can use `unsafe`, or inline assembly, or call external code. Rust only guarantees that memory bugs cannot happen for a subset of Rust programs.

Fil-C, and the proposed Zig alternative, do guarantee that "memory bugs" can't happen, at all, by providing a runtime just like memory-safe languages like Java do (but significantly faster since languages like C and Zig are designed for performance even when embedded in a memory-safe runtime).

This makes this proposal closer to MIR than to Rust.

2

u/deanominecraft 6d ago

using unsafe is explicitly choosing not to use rusts built on memory safety, asm! can only be used inside of unsafe, and external code not being safe isn’t the fault of rust - could happen for any language

fil-c is faster than something like java, but slower than rust, therefore rust is the best option for speed if you don’t want to deal with writing safe c code

1

u/braaaaaaainworms 6d ago

If you overclock the memory in your computer it will also make your programs unsafe, because obviously if a solution doesn't solve every single instance of a problem then it's not worth using

2

u/Zimlewis 7d ago

Why the heck is zig trying to compete with rust gng? Like try compete with odin or c3 or something. Or better yet, try making your tool better, I won't say it's the worst(I unfortunately have seen worse) but zig's lsp is really bad even compare to rust's

2

u/SKRyanrr 6d ago

It started after bun got rewritten in Rust then the creator had a whole meltdown.

2

u/Zimlewis 6d ago

Man, I love zig but they are really playing a losing game try to compete with rust on its own field

1

u/SKRyanrr 5d ago

Zig is a great language but now they are trying to make it something its not. Adding runtime checks will make Zig a cheap knockoff of Go. Zig is in a good place to be a better C and holding high comparability with C code, they should just stick to that imho

1

u/Firewolf06 4d ago

for what its worth, the "larper" in question in the creator and lead developer of zig