I used to be a big Haskell programmer. While I still love the language, I've really come around to the idea that strictly evaluated functional languages like F# or OCaml are the best for programming in. You get the nice functional features but don't have the straightjacket of laziness forcing you into certain design decisions. It's really nice sometimes to be able to mix in impure, side effectful code without having…
I use F# daily, and to get around this limitation I use hacky custom code generation an F# script (fsx) to generated specific types. Additionally, on cases where you’re not specifying the data of the type itself, you can use static type constraints on members. This doesn’t give you a default implementation like Haskell but you can always provide one as a function. Btw the monadic threading is still very useful, espec…
A whirlwind tour of object-oriented code in F# (2012)
71–80 of 130 posts
Re: A whirlwind tour of object-oriented code in F# (2012)
#72I'm not saying it's as good as writing F#, or that C# shouldn't include these features of course.
Re: A whirlwind tour of object-oriented code in F# (2012)
#73While there's nothing you can do in C# that cannot be done in F#, the reverse is not true. The biggest thing that comes to mind is to influence the direction of the other language (C#). I've heard it said many times that if you want to see what features will be in C# in the future, look at F#. Too many features to cite (though Linq is the biggest that comes to mind) were in production use in F# long before they arriv…
Really? When did F# start supporting pointers?
> to influence the direction of the other language (C#)
Lately, it seems it's the other way around: C# is introducing features like Span or default interface members and F# is (quickly) catching up.
Re: A whirlwind tour of object-oriented code in F# (2012)
#74Earlier quoted context omitted.
C# has most of the same pattern matching functionality at this point
There's no compiler warning for incomplete matches, and without discriminated unions it's pretty verbose to write pattern-match friendly types C# has support for most F# features, they're just often awkward to use
Discriminated unions: https://github.com/mcintyre321/OneOf and One line value objects: https://github.com/mcintyre321/ValueOf
Re: A whirlwind tour of object-oriented code in F# (2012)
#75Years ago I was working a miserable job writing boilerplate template code where I had to sub in variables based on certain conditions, it was using a very bland language to look up data from our database and format the output. I wasn't allowed to download any software onto my work computer despite having a technical background. So what I did instead to make my life easier was write F# to create a kind of DSL and crea…
What do you do where you are using Racket most of the time?
Re: A whirlwind tour of object-oriented code in F# (2012)
#76Earlier quoted context omitted.
That sounds exactly the same as F# (except there might be more jobs in scala). F# is on .NET CLR and you can use all the .NET libraries, and it lets you fall back to an imperative style if you need to!
> you can use all the .NET libraries did you try it? Hint: there is a lot of things required before F# could use latest WinUI or WPF
Re: A whirlwind tour of object-oriented code in F# (2012)
#77Earlier quoted context omitted.
There's no compiler warning for incomplete matches, and without discriminated unions it's pretty verbose to write pattern-match friendly types C# has support for most F# features, they're just often awkward to use
You can get a pretty reasonable facsimile using some libraries I made: Discriminated unions: https://github.com/mcintyre321/OneOf and One line value objects: https://github.com/mcintyre321/ValueOf
Re: A whirlwind tour of object-oriented code in F# (2012)
#78Earlier quoted context omitted.
C# was usable in VS Code even 3 years ago
How is it these days? Is it “usable” or actually something you want to and enjoy using? Will I be left wanting Visual Studio? I mean I really enjoy IntelliJ, it makes programming Java like slicing butter. But I do want to try F#, people talk so highly of it.
In that case, I think you want an actual IDE and VS Code is not that. The options you have for .Net are Visual Studio and Rider (which is from the same company as IntelliJ and shares a lot of code with it).
Re: A whirlwind tour of object-oriented code in F# (2012)
#79Earlier quoted context omitted.
C# for the most part does a decent job with Functional Programming, but it still leans very heavily towards statements instead of expressions. Even the newly introduced pattern patching (a common FP idiom) ended being a switch statement - perplexing decision because expressions are so central to good FP code. And if you were in imperative land, you didn't really need pattern matching so much in the first place; most…
C# 8.0 will have a switch expression: https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csh... .
Re: A whirlwind tour of object-oriented code in F# (2012)
#80F# is a joy to use. After a certain time, many C# developers find themselves writing in a functional style. F# makes this the default, but lets you continue using all of your existing code. Better yet, Linux and macOS support via .Net Core is excellent. F# on .Net Core is now a powerful alternative to Node.js.
> After a certain time, many C# developers find themselves writing in a functional style If you can't move to F# or find its tooling abysmal and slow then I have a library [1] that makes the inertia flow positively in the functional direction in C# https://github.com/louthy/language-ext/
My current strategy is to hook my colleges in with languag ext until they move to f# themselves.