Live data from Hacker News

Why F#?

batsov.com

221–230 of 424 posts

Re: Why F#?

#221
post #91

Earlier quoted context omitted.

I'm not sure I'd call Rust a "niche language" any more (perhaps in ~2018) - it's in common use across many big technology companies.

It is extremely niche outside of this bubble.

According to Stack Overflow developer survey [0] Rust is at 12.5%, roughly a half of C# or Java and a quarter of Python. Also more than twice Ruby. So definitely not niche.

[0] https://survey.stackoverflow.co/2024/technology#most-popular...

Re: Why F#?

#222

F# is beautiful, but I could never crack the nut and get fluent in it. I think the big problem is I only know a little C#, so it is difficult to figure out the object oriented methods that F# depends on. It was the same thing with Clojure and Scala for the JVM. I have zero interest in first learning C# or Java, just to use those platforms.

you are not supposed to do oop in f#

oop is just another tool in your toolbox; if f# provides it and it's the best way to express a given algorithm you should definitely go ahead and use it. oop got a bad name due to people trying to shoehorn it into places it was not the best way to express something, and it seems like you're making the inverse mistake here.

Re: Why F#?

#223

F# is beautiful, but I could never crack the nut and get fluent in it. I think the big problem is I only know a little C#, so it is difficult to figure out the object oriented methods that F# depends on. It was the same thing with Clojure and Scala for the JVM. I have zero interest in first learning C# or Java, just to use those platforms.

you are not supposed to do oop in f#

Why not? It does it very well, better than C# in my opinion. At least that was the case ten years ago when I last used C# and played with F#.

Re: Why F#?

#224
post #90

Earlier quoted context omitted.

This isn’t a great example of what linq is good at. There’s no reason to do ToList there, and the ForEach isn’t particularly idiomatic

> There’s no reason to do ToList there In this case, I would move it to the very end if we are concerned about the underlying data shifting when the collection is actually enumerated. Forgetting to materialize LINQ results can cause a lot of trouble, oftentimes in ways that happily evade detection while a debugger is attached.

> if we are concerned about the underlying data shifting when the collection is actually enumerated

I’m not sure what you mean by this. You can fulfill the IEnumerable contract without allowing multiple enumerations, but that doesn’t really have to do with the data shifting around. Doing ToList can be an expensive and unnecessary allocation

Re: Why F#?

#225

Earlier quoted context omitted.

This is a really minor point, but "strongly typed" and "statically typed" are not interchangeable terms. In the context of your comments here, you are exclusively interested in the static nature of the type system, rather than anything about the "strength" of it (which is something totally different and inconsistently defined).

You are absolutely right. Thanks for pointing it out.

Sure thing. Cheers!

Re: Why F#?

#226
post #160

Earlier quoted context omitted.

These days there's Gleam[0], as a strongly typed alternative for the BEAM virtual machine. Of all the languages I haven't used yet, it seems to hit the safe + minimalistic + productive sweet spot the best. (Yes the C-inspired syntax is slightly off-putting, but syntax is the least important aspect of a language.) [0]: https://gleam.run/

Gleam, much like any language which primarily targets BEAM, is slower by an order of magnitude or two when compared to F#.

The appeal is the runtime model. I can’t readily verify if BEAM languages are meaningfully slower or really slower at all but let’s take the premise for the sake of argument.

Even if is slower, the runtime model is incredibly resilient and it’s cheap to scale up and down, easy to hot update, and generally does asynchronous work extremely well across a lot of different processes.

F# has really good async ergonomics but it doesn’t have the same task/processing flexibility and Websockets are kind of a pain compared to elixir or even erlang

Re: Why F#?

#227
post #91

Earlier quoted context omitted.

I'm not sure I'd call Rust a "niche language" any more (perhaps in ~2018) - it's in common use across many big technology companies.

It is extremely niche outside of this bubble.

MS is starting to use Rust pretty extensively internally. That's a lot of developers outside the "bubble."

Re: Why F#?

#228
post #43

Earlier quoted context omitted.

You can write a vast majority of your C# codebase in a functional style if you prefer to. All the good stuff has been pirated from F# land by now: First-class functions, pattern matching, expression-bodied members, async functional composition, records, immutable collections, optional types, etc.

I don't know if there's a name for it but essentially F# is where the language designers can push the boundaries and try extremely new things that 99% of users will not want or need, but eventually some of them are such good ideas that they feed back into C#. Maybe that's just research, and I'm glad that Microsoft hasn't killed F# (I do work there, but I don't write F# at work.)

> F# is where the language designers can push the boundaries

It really isn't, not anymore. F# now evolves conservatively, just trying to remove warts and keep up with C# interop.

And even then some C# features were considered too complex/powerful to implement (e.g. variance, scoped refs) or implemented in weaker, incompatible ways when C#'s design is considered messy (e.g. F#'s non-nullable constraints disallow value-types, which breaks for some generic methods written in C#, sadly even part of the System libs).

Re: Why F#?

#229

Earlier quoted context omitted.

`await` can only be used in an `async` function. How is that so different from `let!` only being available in a computation expression?

because an async function doesn't require you to change syntaxes to get them to work

It's actually sort of the other way round. C# has hardcoded syntax for async/await. F#'s syntax for async/await is a fully-general user-accessible mechanism.

Re: Why F#?

#230

>whitespace is significant, like in Python hard pass

This isn't such a big issue in my experience. Auto-formatting helps a lot, the code needs to be just syntactically correct.

The default F# autoformatter is bundled/supported by VS Code, VS and Rider [0].

[0]: https://fsprojects.github.io/fantomas/docs/end-users/StyleGu...

Post reply on HN