Hacker News new | ask | show | jobs
by peterth3 1680 days ago
So, you’re claiming that pure FP languages need less dependencies than FP-adjacent languages like rust?

This is really interesting. Do you have a source to cite proving this claim?

3 comments

No. What I'm saying is that many of the dependencies in any language don't need to perform side effects, they only do pure calculations. For example a JSON parser takes a JSON string and returns some data structures. It's a pure function. However, in a language like Rust you can easily hide malicious code that has access to network inside such a function. In a pure functional language you can tell from the signature of a function you're calling that it is indeed a pure function and is guaranteed to not perform any side effects. So it is safe to call any function from a third-party dependency that doesn't do side effects (which you can immediately see from the type signature) without even inspecting the code.
Parent only claimed that most Haskell packages are pure and thus cannot execute impure side-effects. They didn't say anything about the overall number of dependencies.
> FP-adjacent languages like rust

What does that even mean? Rust is very far from having anything to do with FP. FP implies immutability and heavily shared structures. Rust hates shared structures with a passion, it requires ownership. You have to jump through some massive hoops to get the same benefits of shared data structures in Rust.

Just seeing this…

> FP implies immutability and heavily shared structures

FP does imply immutability, but not sure what you mean by “heavily shared structures.”

If you’re referring to a type system like Haskell’s then that’s what I meant by “FP-adjacent.”

> Rust is very far from having anything to do with FP

This thread has a pretty deep rust vs haskell discussion: https://www.reddit.com/r/rust/comments/4jh8hv/question_about... Clearly, there are some similarities.

> You have to jump through some massive hoops to get the same benefits of shared data structures in Rust.

Again, not sure what you mean by “shared data structures.” Functional styles work well in rust. You could use only immutable variables with clone/copy sprinkled throughout and the borrow checker won’t complain.