News for hackers. Stuff that matters.
Re:Why is F# code so robust and reliable? by chx on Monday September 23, 2024 @11:23PM (#41632858)
Rust doesn't apply. You need a functional language for the kind of robustness we are talking about. Rust got some influences from there but it's not one.
Re:Why is F# code so robust and reliable? by __s on Monday September 23, 2024 @11:51PM (#41632984)
What are "we" talking about?

- Immutability by default. Check

- Discriminated unions with exhaustive check. Check

- No nulls by default. Check

- No exceptions in the business logic. Check

- Strict dependency order. Rust doesn't have this

- Warnings on unused expression results. Check

- Typed primitives. The level of ergonomics this is implemented with in F# I'll say Rust doesn't have this

- Explicit conversions. Check

- Functional approach to concurrency. I think Rust's compile time safety against data races gives this a check. I've used channels for concurrent server processes, it's nice. Check

- Explicit dependency injection. I've never understood what this means

7/10

Re:Why is F# code so robust and reliable? by Jtsummers on Tuesday September 24, 2024 @12:34AM (#41633121)
> - Explicit dependency injection. I've never understood what this means

The article seems to mean what's described in this other article as "dependency parameterization" where the dependency is explicitly passed to the function (and every function it calls that also needs that same dependency). This is as opposed to, in OO languages, setting the dependency (typically) during construction (however the object is constructed). Or it's otherwise set in some larger scope than the functions which make use of it (global, module, object instance, whatever is appropriate to the language and task).

https://fsharpforfunandprofit.com/posts/dependencies/

https://fsharpforfunandprofit.com/posts/dependencies-2/

Re:Why is F# code so robust and reliable? by pjtr on Tuesday September 24, 2024 @02:02AM (#41633501)
Is "let-over-lambda" (variable capture / closure) not possible in F#? Is that not a form of implicit dependency injection?
Re:Why is F# code so robust and reliable? by fire_lake on Tuesday September 24, 2024 @02:33AM (#41633639)
Yes it’s possible.
Re:Why is F# code so robust and reliable? by Zerot on Tuesday September 24, 2024 @03:03AM (#41633834)
Closures are possible, yeah. But F# also has partial application(and currying). So you don't need to use a closure to do this.
Re:Why is F# code so robust and reliable? by Horusiath on Tuesday September 24, 2024 @12:37AM (#41633136)
Most of these points are related to strict type system. If that was the case, then Lisp wouldn't be functional programming language.

IMO the first and foremost principle of Functional Programming languages is that they are optimised around building programs in terms of function composition. And anyone who had to work with borrow checker and closures for 5sec knows, that this is not the case for Rust.

Re:Why is F# code so robust and reliable? by frogulis on Tuesday September 24, 2024 @12:53AM (#41633186)
I think you've taken it backwards. The comment you were replying to is listing features that lead to robustness (many of which appear in strongly-typed functional languages in the ML family), not essential aspects of functional programming languages.
Re:Why is F# code so robust and reliable? by __s on Tuesday September 24, 2024 @01:21AM (#41633306)
Indeed. I was listing the specific items the article (titled 'Why is F# code so robust and reliable? ') lists. Functional programming languages only came up to reject someone suggesting Rust as a language that can be included as robust/reliable in the context of the article's reasons for F# being robust/reliable
Re:Why is F# code so robust and reliable? by kazinator on Tuesday September 24, 2024 @02:04AM (#41633513)
Lisp is a family of languages, most of which are not functional.