Why do you need the compiler to tell you whether the code is safe?

Why do you need the compiler to tell you whether the code is safe?
Is there an automated alternative to make sure the code is safe for C/C++?

Attached: Rust_programming_language_black_logo.svg.png (800x800, 25.42K)

Other urls found in this thread:

lawfareblog.com/what-ben-franklin-really-said
twitter.com/SFWRedditGifs

"Safe code" doesn't exist. Rust cripples your mind by convincing you it's safe so you never actually learn how to program properly.

Sort of how people who learned shit languages like Java before trying to learn C have their minds crippled into thinking pointers are "hard".

Attached: 1655180255567.jpg (1024x702, 254.78K)

I'm paraphrasing here, but
>Those who sacrifice freedom for safety, deserve neither.

>Retarded C fanboy's mind is to crippled to use assembly

>Why do you need the compiler to tell you whether the code is safe?
Because I am a human, and so are the scores of my coworkers contributing to the same codebase as me. Somewhere, someone is going to screw up. It doesn't matter how many years of experience you have, you're guaranteed to have a day when you're not at your brightest. Maybe you forgot your coffee. Maybe you had a breakup and you're trying to force yourself to not think about it by working, but you're still distracted. Maybe it's not even you, it's the intern, and the guy who was supposed to check his work. It doesn't matter who, but SOMEONE will fuck up.

And the result of that fuckup may vary based on the severity of the bug, and the application it's used in. Maybe you just waste time trying to figure out why the program doesn't pass its tests. Maybe it deletes a client's database and makes your company pay out a million dollar settlement. Maybe it causes an airplane to disregard pilot input and nosedive the plane into the ground, killing 157 people onboard.

Clearly we want to avoid mistakes. Rust causes more mistakes to be caught at compile time, and makes those that can't be checked by the compiler easier for your coworkers to spot.

>Is there an automated alternative to make sure the code is safe for C/C++?
There are some static analysis tools for C and C++, though I can't vouch for their quality.

I didnt say that people ought to cgeck if the code is safe by hand. Hence is there an automated alternative.

I don't think you read my post.

>Rust cripples your mind by convincing you it's safe so you never actually learn how to program properly.
But it's the exact opposite. You need to learn how to program properly in Rust or the borrow checker won't compile your code. It's not anything like Java and C. A Java user going to C will have their program compile fine until it breaks at runtime or leaks memory.

Sure, but if you don't need legacy compatibility, why not just have the safety integrated?
Safety is also not Rust's sole feature. It also has sum types, iterators, etc.

>A Rustlet shills his language
How does it feel knowing you could've learned to pointers in the time you learnt Rust and shill for it?

Attached: 1648550505388.jpg (1080x726, 205.61K)

Rust uses pointers bozo

You know, I do sympathize with Rust. Despite the trannies and literally orwellian language strategy, there are a few good ideas in there. Here's my roadmap for bringing the good parts to normal languages:
>all values must be used
>overloadable functions for duplicating values and deleting values
>functions can 'swallow' their arguments, destroying them in the calling scope
>defer/autofree
For instance, calling free() on a pointer would destroy that value, preventing it from being used again, and by removing drop() from a file handle, you could prevent it from going out of scope without being closed.
To really make things nice, add multiple return values, and make
ret = func(val, &ref)
be the same as
(ret, ref) = func(val, ref)

user, I learned C++ at 16, and I'm 30 now. I know how fucking pointers work. Hell, I've used them in unsafe Rust before.That doesn't mean I'm going to prefer them over safer abstractions when I have the opportunity.

A chef's knife is fully sufficient for cutting open a human body, but if you want to do surgery, you should probably use a scalpel, even if the chef's knife can cut more things.

there are a million problems with rust
why are we still talking about "unsafe"

>I know how fucking pointers work.
I don't think I've seen more than five levels of pointer on a type in production code.

The m1 chip has an unpatchable security exploit because of a memory bug i think.

That's the most misused quote from US history I've ever seen. The actual quote reads:

>Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety.

The quote is attributed to Benjamin Franklin, who was criticizing the Governor of Pennsylvania for refusing to tax the ruling Penn family to pay for defense of the colony. Franklin was protesting their offer of a lump sum in exchange for the legislature to stop taxing them; they were quite literally trying to convince the legislature to purchase temporary safety by giving up their claimed ability to tax and govern freely.

lawfareblog.com/what-ben-franklin-really-said

The safety in Rust is neither temporary nor is it purchased. Also, crashing your program with memory safety bugs isn't an essential liberty. Your users would find it more of a liberty _not_ to have those bugs.

You can say the same about C compared to B. C is literally just B with a very basic type system added because the people using B (who were the same ones who wrote B and C) struggled without one.

>There's a language called B
>That's why it's called C.
Oh neat.

Attached: 1655317311863.jpg (480x318, 35.06K)

C, C++ and Python are better

>Why do you need the compiler to tell you whether the code is safe?
Because I want the computer to warn be of unsafety.
>Is there an automated alternative to make sure the code is safe for C/C++?
There are a bunch of proprietary static analyzers but they are not free for use. I prefer the free one that comes with Rust.