Live data from Hacker News

Prusti: Static Analyzer for Rust

github.com

81–90 of 93 posts

Re: Prusti: Static Analyzer for Rust

#81
post #75

Earlier quoted context omitted.

Can't wait for dependently typed type systems

I've written code with dependently typed languages. It's very powerful, but it really is time-consuming. That won't be appropriate for all developments/developers.

Do you recommend any of the dependently typed languages more over others?

Re: Prusti: Static Analyzer for Rust

#82

That looks incredibly useful. Proving the absence of panics and overflows is already great, and with the annotations you can guarantee properties you'd normally write property tests for, like in this example from the docs: impl List { #[ensures(self.len() == old(self.len()) + 1)] pub fn push(&mut self, elem: i32) { // TODO } }

Can't wait for dependently typed type systems

No need to wait, you can pick Idris today, but it won't be a productive experience versus mainstream development tooling.

Re: Prusti: Static Analyzer for Rust

#83
post #72
post #63

Earlier quoted context omitted.

Nitpick, unsafe doesn't turn off the borrow checker. It just allows you to dereference raw pointers which are the things you must be careful about by reasoning about the actual safety yourself as a programmer. Everything else that uses safe pointers (references and mutable references) remain safe.

But how passing around a (constant) raw pointer is not sidestepping borrow checker? Since the pointer (AFAICT) does need to be borrowed, because it's manifestly immutable, it could be passed into several functions that alter the pointed-at memory in arbitrary order.

Yeah it is sidestepping as you say! The distinction is that if you don't sidestep by dereferencing raw pointers, the borrow check still works. Observe that you can cast as raw pointers in safe rust. What unsafe {} changes is that you can dereference them. The borrow checker still works for regularly borrowed values (&var and &mut var etc). This is probably obvious for Rust users, but I find some people take the "turn the borrow checker off" literally by assuming they won't get lifetime errors if the put an unsafe { } around their code.

Re: Prusti: Static Analyzer for Rust

#84
post #64

Earlier quoted context omitted.

Thanks for your interesting work! I wanted to ask, how are FFI boundaries handled? Are they ignored or is it an error to call FFI functions?

Currently they are not handled. But (you guessed it) we also have a project working on this: attaching trusted specifications to external methods. In the long term we might investigate a full integration with external verifiers, e.g. to check that the specifications declared on external methods in Rust is justified by their actual implementation, say in C. This is tricky because the specification language/level of ab…

Sounds really exciting! Mir interpreter has the same limitation. Have you examined incorporating mir in your analysis?

Re: Prusti: Static Analyzer for Rust

#85

Looks like I need to fix my binary search code!

[off-topic] While you're at it, how about integrating D with cargo? D could:

- act as a C/C++ compiler for legacy code,

- shine where Rust is weakest: strings-first apps and apps that benefit from classes,

- get us to a world where the best C++ is a frozen C++

Too tall an order?

Re: Prusti: Static Analyzer for Rust

#86

Looks like I need to fix my binary search code!

[off-topic] While you're at it, how about integrating D with cargo? D could: - act as a C/C++ compiler for legacy code, - shine where Rust is weakest: strings-first apps and apps that benefit from classes, - get us to a world where the best C++ is a frozen C++ Too tall an order?

I'm not really qualified to judge what is the right feature set for a build system like dub or cargo.

Re: Prusti: Static Analyzer for Rust

#87

Looks like I need to fix my binary search code!

[off-topic] While you're at it, how about integrating D with cargo? D could: - act as a C/C++ compiler for legacy code, - shine where Rust is weakest: strings-first apps and apps that benefit from classes, - get us to a world where the best C++ is a frozen C++ Too tall an order?

Sadly, D has its own set of problems and design flaws. It's better than C++ in many ways, but still far from Rust in terms of solid foundation in computer science and language design. Frankly, I see no point in integrating it with Rust.

And what do you mean by Rust being weakest in these categories anyway, and why do you think it is? What are "string-first apps"? And how is not adopting inheritance-based OOP a weakness? I think, many experienced programmers, especially those familiar with ML family of languages and otherwise well-versed in different paradigms, will argue that this particular flavour of OOP is more harmful than helpful.

Re: Prusti: Static Analyzer for Rust

#88

Why would you need a static analyzer for a language that promotes itself as safe out of the box.

This is a fair question really. Calling it a static analyser is misleading and seems to be editorialised. It's not like static analysers in C++. It's actually a formal verification tool. They call it a "static verifier" not a "static analyser". Most static analysis tools seek to find potential problems in your code - generally common mistakes - but they aren't proving anything usually. They have false positives and n…

- I am pretty sure that static verifiers are a subclass of static analysers.

- Prusti does not require you to write any "properties". I just ran it on a piece of code, which has no annotations for Prusti, and it still found a potential integer overflow. Maybe it has some internal annotations for std, but none for my code.

Re: Prusti: Static Analyzer for Rust

#89
post #87

Earlier quoted context omitted.

[off-topic] While you're at it, how about integrating D with cargo? D could: - act as a C/C++ compiler for legacy code, - shine where Rust is weakest: strings-first apps and apps that benefit from classes, - get us to a world where the best C++ is a frozen C++ Too tall an order?

Sadly, D has its own set of problems and design flaws. It's better than C++ in many ways, but still far from Rust in terms of solid foundation in computer science and language design. Frankly, I see no point in integrating it with Rust. And what do you mean by Rust being weakest in these categories anyway, and why do you think it is? What are "string-first apps"? And how is not adopting inheritance-based OOP a weakne…

I admit I do not come from an academic computer science background. What I do bring to programming language design, however, is decades of experience in programming, compilers, and being on the front lines doing tech support on them.

In other words, the human factors facet of language design. D does very well as a friendly language from a human factors perspective.

A simple example of this is `+` is commonly used to mean both addition and concatenation, leading to confusion with awkward resolutions. D uses `+` for addition, and `~` for concatenation. It's been working great.

We also regularly correct errors in the design of D.

Re: Prusti: Static Analyzer for Rust

#90
post #81
post #75

Earlier quoted context omitted.

I've written code with dependently typed languages. It's very powerful, but it really is time-consuming. That won't be appropriate for all developments/developers.

Do you recommend any of the dependently typed languages more over others?

My experience is stale by now. I'd really like to try recent versions of Idris, though.
Post reply on HN