Why haven't you taken the F# pill yet, anon?
https://jkone27-3876.medium.com/f-is-the-net-rust-62f71f8dae41
let maximumHappinessSum values k =
values
|> Seq.sortDescending
|> Seq.take k
|> Seq.zip (seq{0 .. k - 1})
|> Seq.map (fun (i, v) -> max (v - i) 0)
|> Seq.sum
>F# is a functional-first programming language that is known for its expressive type system and seamless integration with the .NET ecosystem, so it is a GC (garbage collected) language with regards to memory management.
do you have any idea what you're talking about? the first thing about rust is that it is not GC'd
Rust doesn't focus on manual memory management, and it achieves it through RAII and single ownership move model.
Yeah, and RAII isn't a GC buddy.
Yeah but it also automates memory management, just like GC.
>raii automates memory management
first time i've heard of this and i deal with this shit all day
When Rust is compared to GC'd languages, and its lack of a GC is used as a selling point, the presence or non-presence of automation in memory management is not the point of contention. RAII is not manual memory management, although it is often built upon a system which allows for manual memory management (FWIW, you *can* actually do manual memory management in Rust -- it does have raw pointers just like C, and can call into any foreign function using C's ABI). What RAII and manual memory management offer over most GC implementations is determinism.
It can be very difficult to predict spikes in program latency caused by a GC having to potentially stop the world just to clean up memory. With either RAII or manually freeing memory, this is almost always done as soon as the memory is no longer in use. While this can technically be wasteful -- freeing memory is slow, and over the long run will cause a program's execution to be longer for the same number of operations -- it does mean that every individual operation has an upper bound on how long it will take to execute. This is very fricking necessary for real time applications. It's also very nice in programs that need to deal with human interaction, because you're not going to deal with random lag spikes.
It's as automatic as C++. Objects go out of scope, their destructor is called. This doesn't guarantee a lack of memory leaks, since cyclical references can guarantee any reference counted smart pointer will never drop its reference count to zero.
>it's as automatic as c++
i only deal with this in c++ daily, and c++ is not automatic at all
>lack of memory leaks
that's just the start of it
>i only deal with this in c++ daily, and c++ is not automatic at all
Anon, I've been programming C++ since I was 16, and I'm 32 now. I think when the compiler is inserting function calls for you without you needing to write those function calls yourself, that fits most people's definitions of "automatic". You may need to write the function definition, which is why it's not a fricking GC... but you don't need to tell the compiler to invoke it. Everything with a destructor has that destructor invoked whenever it goes out of scope. This is done "automatically" by the compiler.
go ask any c++ programmer if they think raii is automatic memory management
prepare for your snort of derision
It's a matter of perspective, isn't it? On the one hand, any time you use anything more than the default data structures, you are writing destructors by hand, and thus doing manual memory management. On the other hand, every time you initialize an instance of that object, the compiler is still injecting calls to the destructor wherever that object leaves scope. And linguistically speaking, that process by the compiler *is* automatic.
>It's as automatic as C++. Objects go out of scope, their destructor is called. This doesn't guarantee a lack of memory leaks, since cyclical references can guarantee any reference counted smart pointer will never drop its reference count to zero.
This happens with garbage collection as well.
It's slow.
>Rust doesn't focus on manual memory management, and it achieves it through RAII
So does C++.
>and single ownership move model
Not related to memory management.
>Not related to memory management.
single ownership, default move and RAII are all parts of Rusts memory management.
Single ownership and default move have nothing to do with the allocation and deallocation of memory, which is what we are referring to by memory management in this context, Anon.,
>single ownership
That's just static analysis/borrow checker. It doesn't manage any memory as it evaluates during compilation and just throws errors or not.
>default move
That's just a syntax/semantics.
>RAII are all parts of Rusts memory management.
RAII is memory management. And it exist in nearly all popular languages. It is not a GC though.
>the first thing about rust is that it is not GC'd
That's why one of the most downloaded crates is a garbage collector.
https://crates.io/crates/crossbeam-epoch
That sounds reasonable, if it was a GC'd language people would have less of a need to make GC libraries for it. There's several popular GC libraries for C as well.
>White space significance
Trash
umm actually F# is the .net ML
So trannies like it?
yes, that's exactly it
>96% male and mainstream language
Go keeps winning
>troony this
>troony that
Trannies also breathe air. Time for you to an hero, troony obsessed homosexual.
>Trannies also breathe air.
Unlike Microsoft products, air doesn't come with troony propaganda built into it.
>microsoft botnet but with no jobs
how about no
>Muh jobs muh jobs muh jobs
man shut up and go use JavaScript
Seems like a neat language, but I already know Clojure and don't see a reason to learn another FP lang
I like FP but I'm not voluntarily using a MS product thanks
Almost all f# features exist in c#, but with c# you have way better ide and tooling support. For real, f# is just syntax skin for .net, c# (especially modern with records, patternmatching, source generators, etc) can do anything f# can do
C# doesn't have DU and C# pattern matching is a joke. Just like majority of kitchen sink ""features"" C# provides ie shitty ""collection"" syntax
> C# doesn't have DU
abstract record MyDuType;
record A(...) : MyDuType;
record B(...) : MyDuType;
Sure, it's not 1to1 the same, but who cares?
> C# pattern matching is a joke
What exactly? It gives you ability to pattern match on these DUs and that's enough for 99% cases. Ok, it can't do "x:xs" pattern, but where this shit is needed except leetcode algorhtims?
F# has nothing cool from fp except sum types and ocaml syntax. It doesn't have type classes or higher order kinds, it's only instrument for polymorphism is same shitty interfaces like c# has, it doesn't even have functors like ocaml does. And for any real development, you'd need to use c# libraries and interfaces, so you'd write same code as in c# but with weirder syntax and shittier ide support.
>abstract record MyDuType;
>record A(...) : MyDuType;
> record B(...) : MyDuType;
This doesn't have totality like a real DU.
>it can't do "x:xs" pattern, but where this shit is needed except leetcode algorhtims?
The frick are you on about? It is very important. Name one language with pattern matching that doesn't have it? Plus C# is Leetcode compatible, not F#.
And also I can put pattern matching anwwhere in F#/Scala/Rust and even Java but in C# you cannot use it inside a function. It's fricking garbage.
> This doesn't have totality like a real DU.
Why would you need it for anything except dependent types? Are you proving theorem or writing a software?
> Name one language with pattern matching that doesn't have it?
C#, rust
> And also I can put pattern matching anwwhere in F#/Scala/Rust and even Java but in C# you cannot use it inside a function.
?????? What r u talking about
>Why would you need it
Because DU is meant to have totality, it's called DU for a reason. Even Java understands that.
>Rust
Wrong. Rust has slice patterns. C# is a joke.
>What are you talking about
let rec f n =
let p = someFunc(n)
let q = p + match n with
| 1 -> 0
| _ -> f (n - 1)
p + q
> Even Java understands that.
Its that language where every method has to have "throws Exception1, Exception2, ..."? Dumb and autistic as frick
> Wrong. Rust has slice patterns.
Ok, you are right, I agree that c# devs are moronic for not having such basic case for pattern matching, especially after update of adding list matching to the language.
But again, writing few more lines of code in such rare scenario is not that critical
> let rec f n =
> let p = someFunc(n)
> let q = p + match n with
> | 1 -> 0
> | _ -> f (n - 1)
> p + q
Uuuh what?
int f(int n) {
var p = someFunc(n)
var q = p + (n switch {
1 => 0,
_ => f(n-1)
};
return p + q;
}
>int f(int n) {
>var p = someFunc(n)
>var q = p + (n switch {
>1 => 0,
>_ => f(n-1)
>};
>return p + q;
>}
Ok, looks like new C# can handle pattern matching inside function body. Still doesn't excuse the lack of DU.
Problem with C# is that it will throw in new "features" half-hazardly. For example their new collection syntax is moronic.
For example in pic related This should print 21. Btw, it won't simply work if you don't collect [..a, ..b[..]] in a variable like c. It's weird pitfalls like this why I don't like C# that much.
If you mean to imply that it's an objectively worse alternative to the mainstream option and people using it are self-congratulating snobs who haven't accomplished anything in their lives you'd be right.
how easy/hard is it to make android apps with F#?
https://github.com/SAFE-Stack/SAFE-Nightwatch