Top
Best
New

Posted by bozhidar 4/1/2025

Why F#?(batsov.com)
447 points | 413 commentspage 2
a-french-anon 4/1/2025|
Why would Lispers feel at home with its (whitespace delimited) syntax? Quite the strange claim.

I know this isn't a common rant, but I hate so-called functional language still bowing to the "infix mathematical operator special case" dogma, when those are just binary (variadic in Lisp) functions.

Always found it pretty appealing, otherwise. And no ";;"!

110bpm 4/1/2025||
I put together a quick-start guide to F# Computation Expressions — showing how you can go from C# async/await all the way to Result<> workflows with let!... and!... expressions, and even a custom validation {} CE. [0]

This is a practical side of F# that doesn’t get enough spotlight — but one I’m using daily.

[0]: https://news.ycombinator.com/item?id=42636791

LinearEntropy 4/3/2025|
That was a great read. Thanks for sharing.
protonbob 4/1/2025||
> which is quite odd for what is supposed to be the flagship editor for F#

The flagship editor is Visual Studio, not vs code.

MaxGripe 4/1/2025||
The flagship editor is Rider
bozhidar 4/1/2025||
But it's Windows-only, so it's not an option for me.
GiorgioG 4/1/2025|||
Rider is an option for you. Community edition is free too.
LandR 4/2/2025||
Rider is now entirely free for non commercial use.
protonbob 4/1/2025||||
Who said it was? It is the flagship editor though.
neonsunset 4/2/2025|||
Why not VS Code with Ionide? It’s quite nice.
protonbob 4/2/2025||
I've found that as C# gains much of the features that F# has and will soon gain more (pattern matching, functions as first class data types, great fp libraries, etc) the "moat" that F# has over C# has gotten smaller. I write most of my c# code in a primarily functional style, but I still have the advantage of using the libraries in their own native ways that follow the examples given by microsoft and other vendors.
runevault 4/2/2025||
Watching c# eat f# features as someone who has dabbled in f# lightly for over a decade has been wild. And supposedly DU's are in the works but multiple years out.

Though one thing I doubt c# ever gets that I love when I'm writing f# is pipeline operators. I love the way they read, from object/collection being worked on and then a list of operations being run on it in order from left to right (or you can do right to left if you need to for some particular reason).

gdfsfs8895 4/2/2025||
[dead]
shermantanktop 4/1/2025||
> Trivia: F# is the language that made the pipeline operator (|>) popular.

I’m not a dabbler in exotic languages, so this definition of “popular” was puzzling. I’ve literally never seen that operator before. Maybe I need to get out more.

zdragnar 4/1/2025||
It exists in several similar languages such as elixir, and was even a proposal for ecmascript, but never really got traction.
sundarurfriend 4/1/2025|||
I'm familiar with it via Julia, and I believe recent versions of R also have it.
WorldMaker 4/1/2025|||
It made it to Stage 2, which is some traction: https://github.com/tc39/proposal-pipeline-operator

It has been "stuck" at Stage 2 for a while, though.

shermantanktop 4/1/2025||
Thanks for that link! Now I want pipe operators...
sdsd 4/2/2025||
I've used it in Racket, which is not exactly "popular" but common in universities as a teaching language. I actually built a fairly popular Tor hidden search engine in Racket nearly a decade ago, but I quickly shut it down when I ran some stats on the most common queries.
GiorgioG 4/1/2025||
As a 20+ year C# developer I’ve tried several times to learn/use F#. Despite being interested in FP, my brain is having trouble figuring out how to structure my code in F#. In C# I’d either build a service (or use the mediator pattern) for the domain and a repository for data access. With F# it’s functions all the way down and it feels unnatural (as silly as that may sound).
Akronymus 4/1/2025||
along with what jcmontx said: F# is structured bottom from top. As in you can't reference something that is later defined earlier. I find that naturally leads to getting a decent enough structure "for free" because it forces you to have your basic functionality early on and build on that later.

That also, IMO, makes untangling/splitting up parts of the codebase easier as well.

jcmontx 4/1/2025|||
The secret is currying. Replace your DI for currying and you'll start to see somewhat similar patterns
Smaug123 4/1/2025||
By the way, I consider https://www.bartoszsypytkowski.com/dealing-with-complex-depe... to be the canonically correct way to do DI when you want to inject more than like two dependencies.
DeathArrow 4/2/2025|||
Have you tried using a book or a tutorial to see how things can be done using idiomatic F#?
MrMcCall 4/1/2025||
That makes sense when one is used to the Visual Studio organization of solutions and projects, with some main method somewhere being the entry point, unless it's a WCF service or somesuch that gets run via a service manager.

I only used F# at its command line, fsi.exe, to give me commandline access to .NET for exploration, testing, and munging data. Over time, I built up quite a library of usable functions that I'd have the fsi.exe program pre-load when I kicked it off, leaving me at the prompt with all .NET namespaces and my code ready and accessible.

Once you get access to your database's data, it's easy to write queries against it and then play with the data. I could then port the F# processing bits that worked into my C# projects as necessary, but it was far easier to do it that way than to write the logic deep within complex multi-project solution files, where the various classes are spread throughout the projects' files.

I also just really enjoyed using F#.

hurril 4/1/2025||
F# is a wonderful language, one that I write as my daily for the second time during my carrier. It _baffles_ me how it isn't more popular than it is because it truly is very very good. And I say this as an experienced and avid functional programmer.

We even do the frontend in it using Fable and Elmish, which is to say: we basically write our frontends in Elm, but the platform is .NET.

nickpeterson 4/1/2025||
Because it’s great, and people that think otherwise are dead to me.
MrMcCall 4/1/2025|||
Curried functions combined with that magnificent pipe operator, overlaid on the .NET runtime. Don Syme et al knocked it out of the park.

It's the one programming language that changed how I think about programming.

I'm only talking about the version before type providers. Then it got messy.

Before that, we could (and I did) recompile fsi.exe to do some custom prompt manipulation. It was a slog, but it worked, but then Microsoft faded from my life. Still, that early version (I believe 2.0) F# is just magnificent.

munchler 4/1/2025|||
F# is up to version 9 now, and has only improved over time, IMHO. Type providers are a very small part of the story and can be avoided entirely if you want.
jasonthorsness 4/1/2025|||
I tried F# when it was first released and was not a fan, but it sounds like that impression is a little outdated. C# has come so far in that time it’s almost a new language. I’ll have to take another look.
MrMcCall 4/1/2025||
I don't know what C# has for an interactive prompt nowadays, but F#'s commandline environment, via its fsi.exe, was a revelation back then. It prevented having to have entire solutions to contain test projects to explore different areas of the vast .NET framework, especially when just learning how to use specific methods or objects.
DeathArrow 4/2/2025||
For C# you can use LINQpad, a .NET scratchpad. You can even mix and match F# in it.
speed_spread 4/1/2025||||
Why would type providers be avoided? It seemed to me like a nice metaprogramming feature, akin to what Zig does with comptime types (except runtime?)
Smaug123 4/1/2025|||
Yeah, they're terrifying. It's often not that hard to generate the code (e.g. https://github.com/Smaug123/WoofWare.Myriad/ is where I pump out these things) for a bunch of what you would want to do with a type provider, and that's much less existentially terrifying if it's possible.
Akronymus 4/1/2025||||
Type providers can be extremely brittle IME. Altough, I guess if it is referring to version controlled example data that probably works better than referring to a DB or something like that directly that the dev has to provide.
munchler 4/1/2025||||
Type providers are very powerful but involve running arbitrary external software at compile-time (e.g. a SQL Server or Postgres database). This can be difficult to set up and configure reliably in a multi-person project.
owlstuffing 4/2/2025||
You're not entirely wrong, but when it comes to SQL, the trade-offs are unavoidable. You either embrace a conventional, not-SQL approach with all its limitations, or you treat the database as the single source of truth (SSoT). Both have downsides, but configuring a designated local or shared database for this purpose is no less reliable than conventional approaches.

As for type providers in general, I don't think databases are the best example of their typical use case. Most type providers don’t interact with external systems; they usually parse schemas, configuration files, or other structured data to generate strongly typed representations. The database-backed approach is just one variant, not the norm.

MrMcCall 4/1/2025|||
For me, I already had all the featues I needed.

Plus, I'm not going to be downloading, configuring, or running any separate code at runtime. The project is the project, it's going to process some files, communicate with some services, and communicate with the UI, if any.

If I need to consume a service, it should be defined such that I manifest the interface module (perhaps via WCF) and then connect to it progressively from stub to ever greater functionality in test to final implementation. Trying to write a program to do all that at runtime is not sensible, IMO.

Metaprogramming via reflection, however, was useful for exploring the vast .NET framework, and I used those to great effect, especially in exploring .NET's various UI frameworks (WinForms and Silverlight), but never to create code at runtime via the emit functionality. No, that's my job: to emit code that is tested and works and is comprehensible.

MrMcCall 4/1/2025|||
I don't doubt it, but I don't run Microsoft software any more. I've seen enough embrace, extend, and extinguish in my lifetime to not depend on them for my code's execution environment.

My current work needs nothing the .NET environment provides that I can't use python's standard libraries to get done, or bash and C if I need to.

But I'm lucky to no longer be in a corporate environment, so I don't need to consume commercial services, which was much easier using WCF within .NET. Back in my previous life, constructing n-tiered services on top of SqlServer using WCF was slick, indeed.

To any who are interested in how to construct such n-tiered applications simply but securely and precisely, I highly suggest Juval Lowy's IDesign system. He had three specific videos that I watched three or four times each until I understood his distillation of his vast expertise. Of course, Mr. Lowy is one of the co-designers of WCF, which was an excellent bit of tech.

munchler 4/1/2025||
FWIW, F# is an open source project controlled by the F# Software Foundation, the .NET Foundation, and Microsoft.
MrMcCall 4/1/2025||
> controlled by the F# Software Foundation, the .NET Foundation, and Microsoft.

It is controlled by Microsoft. It's not going on my Linux or BSD boxes.

I know how they work, and I want nothing to do with them.

lunarlull 4/1/2025||
Do you make sure to run a linux kernel with all the MS stuff patched out also?
MrMcCall 4/2/2025||
No, but if it came in the standard install there's nothing I can do about it save spending hours and hours auditing my install. I don't do that kind of thing nowadays.

Separately installed software? Not a bit of it.

akkad33 4/1/2025|||
It has great ideas but because of all these conveniences it is very bad for performance based programming making it slower than C#. I like the ideas in Roc language to make functional programming as fast as imperative by controlling allocations in things like closures
MrMcCall 4/2/2025||
That's interesting. Thanks for the heads-up.
turtlebits 4/1/2025||
It might be great, but IME, MSFT docs and tooling are subpar, and anything dotnet related is/was a disaster.
mesic 4/2/2025||
F# is getting some traction in Norway. I know for a fact that places such as NRK (BBC eqvivalent), Resoptima, Frende Forsikring and my current employer, REN are all using F#.

I just gave a talk about how we use F# at REN: https://vimeo.com/1070647821

aloisdg 4/1/2025|
F# is corporate friendly ML. Love it.
More comments...