Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

Oh yeah,

1. IDE experience is much better.

2. I like the fact that F# emphasizes the functional aspects, it's a bit of a 'tighter' language than Scala (despite the two crucial missing pieces) and so I think people could learn it a bit faster. Scala has things like structural typing, all kinds of optional syntax, multiple inheritance, etc.

3. Lack of flexibility in syntax is a plus imo for F#. Some of Scala's flexibility is nice, but some of it just confuses the newbies (like the various usages of `_`).



sort by: page size:

In what way do you consider F# better than scala? Especially with the recently released, revamped Scala 3?

Disagree as someone who has programmed in both Scala and F#; I found F# pretty much could do the same things just in different ways. In F# I found more ways to squeeze performance than in Scala which by comparison is bloated. For the data applications ive written F# wins usually especially with ad-hoc tactical apps and in my experience was easier to teach than Scala which is not as coherent of a language.

Is there anything about using F# that you would see as a plus over Scala or Haskell?

F# is primarily functional, Scala is much more of a hybrid of both OO and FP; so Scala has things like traits that are actually advanced OOP constructs, while F# tries to push you more in the direction of pure FP.

The tradeoffs are different also. F# focuses a lot on performance in the spirit of Caml, whereas Scala is a bit more free to dive into more powerful features that go against that spirit. This is my grock at least of my conversations with Don and Martin over lunch when Don was doing his sabbatical at EFPL.


F# started out as integrating much better and being very selective of features, whereas Scala has been happy to add all sorts of features, to my understanding. F# has been feature complete for a while, mainly getting quality of life improvements and updating to maintain C# compatibility.

F# is a remarkably less powerful language than scala. Along with the cost of Visual Studio + windows licenses, the Scala/open source ecosystem is just a better choice.

Having used and enjoyed F#, I ended up programming in Scala which is almost the same language, despite the huge superficial differences:

- Indentation delimited blocks vs curlies

- CLR vs JVM

- Whitespace vs Parenthesis for function calls

- Currying by default vs currying optional

Despite all this, when you actually start coding, it's remarkably the same:

- Immutability by default, transformations rather than mutation

- Less classes with embedded implementation logic, more "dumb" records with external functions

- Structural pattern matching

- Tagged unions

- Type inference

- Convenient definition of record/struct-like data types with free copy-constructor

- Operator overloading

- Easy FFI to external libraries in a different paradigm

- Easy "dropping down" to mutable, imperative code (e.g. for performance, or interop)

- Both have lots of syntactic and semantic warts and corner cases, though few enough you can live with them

- Garbage collected, multithreaded, JITed runtime

- Both compile to Javascript

While every single feature looks totally different on the surface, starting with a totally different syntax, the two languages are more the same than different. If you look at the tutorials linked from that page, all of them can be translated almost line-for-line from F# to Scala (and vice versa: take any random Scala tutorial, and you can trivially translate it line-for-line into F#)

Scala brings with it a bigger ecosystem, both in Scala and from the JVM, and better tooling support in general (Both Scala-specific, as well as general JVM tooling which all works with Scala: profilers, debuggers, package managers, ...), and slightly more seamless platform interop (Scala <-> JVM is less jarring than F# <-> C#), which is why I ended up sticking around.


The type inference is much better in F#, the syntax is much terser, discriminated unions are much cleaner than case classes.

Also .NET/Mono benefit from a VM with much better performance characteristics (tail calls, value types).

Scala has its own set of benefits too (incredibly powerful type system, Scalaz, bigger community).

F# is primarily a functional language with some OOP bits tacked on. Scala is the opposite.


> Scala is more OOP, F# is more FP

That depends on your background. As far as FP goes, I wouldn't see myself working in a FP language that doesn't have type-classes or something similar. Clojure has protocols and multimethods, Scala has type-classes based on implicits, while F# doesn't have anything like that.

> F# is looking more "clean" than Scala.

I don't know about that, I got used to Scala code. As far as the languages are concerned, I hate for instance how F# imported some language features from C# that really needed to die a long time ago, like static class members and operator overloading based on said static class members. Scala on the other hand cleaned all that crap. My problem with F# is basically that it has 2 type systems in the same language. Same problem that Ocaml has really, except Ocaml can also do some pretty cool tricks with structural typing for OOP that F# cannot.

But anyway, these issues are actually irrelevant because the choice for developers will end up being the answer to ".NET or the JVM?"


I have a special place in my heart for F#. While I do a lot of Scala these days, professionally and open source, F# was my first introduction to functional programming that eventually got me into Scala.

F# and Scala are extremely similar languages: garbage collected, hybrid OO/FP guest languages hosted on a widely-used runtime. Even though the superficial syntax is very different, and the advanced language features they provide are pretty different, the core experience of modelling your data as "dumb" data structures and transforming collections of data using higher-order functions is almost identical.

Scala ended up winning out for me due to a broader ecosystem (Much more OSS Java than OSS C# out there), better tooling (Visual Studio's F# support was always disappointing...), and easier interop (F# <-> C# feels a lot more clunky than Scala <-> Java). But I can easily imagine an alternate universe where I'm happily writing F# all day, and almost nothing would be different from my current work writing Scala.


I've only used F#; have looked at Scala a bit but haven't used it. I find F# feels fairly natural and pleasant if you know C# and like ML-like languages. I've mostly treated it as a nicer C# rather than a true functional language, though; features like sequence expressions (generate an anonymous IEnumerable with yields without having to declare and define a function etc.) and object expressions (generate an instance of an anonymous class that inherits from some interface) let you write imperative code in a more "value-oriented" fashion and with less ceremony. Algebraic data types and pattern-matching are also nice to have, of course. My impression is that Scala is much more conceptually interesting.

F# can be a nice language even if you don't care for the functional paradigm.

Discriminated Unions and pattern mactching still come in handy, the syntax is still less verbose, there is less biolerplate/ceremony than in C# where everything has to be in a class.

it is easier to pass a function to a function than in C#

inlining functions is easier

the type inference can be useful in various ways.

if/then/else statements being expressions is extremely nice.

I tend to code in a mostly imperative style, even in F#. I understand it better, it usually performs better.


I have been debating whether to learn Scala or F# in my spare time. F# seems to be the more pragmatic choice. Doesn't go the insane way of FP that Scala does with complicated libraries or convoluted inheritance hierarchies. The Scala community seems more divided than the F# one with multiple competing ecosystems/libraries for achieving the same thing. My interest lies in webdev/backend and F# seems to be an obvious choice with asp.net and it's supplanting libraries. Not sure how Scala fares, but i guess it's not the primary use case for it. On the surface I kind of like the syntax of Scala, it's very familiar but I fear that I would get more frustrated the deeper I would dig because eventually you have to integrate other people's code and the way most of it is written looks to be like haskell in disguise. Not really sure about the pros/cons.

If you like that kinda thing you should check out F# as well. The IDE experience/speed is much better for F# IMHO, but I have a lot of respect for the concepts behind both. And of course they ride on completely separate massive ecosystems, so you can't exactly swap them out willy-nilly..

I wish I could figure out why my IDE experience with Scala and IntelliJ(IDEA) was so darn sluggish. Also hoping they jump on the language server protocol bandwagon in the future.


I really wish F# was as approachable as Scala is. Every time I consider it I see no strong selling point. Loosing ReSharper + a steep learning curve make it too much for me.

I would not actually compare them from language point of view but ecosystem point of view - but then again, I like simplistic stuff. Give me algebraic datatypes, pattern matching and type inference and I'm happy.

That said, F# in my opinion benefits hugely from the Visual Studio tooling (if one can use it). The main benefits for me are:

- the integrated F# command line facilitates pretty much similar development as with lisps - one can instantiate a context, and then develop ones program code at the same time as the context is live. With static types. I.e. create a function, interpret in repl, run function, observe the side-effects etc. Once done compile. Then load dll in repl, build new functionality on top of previous module etc etc.

- Visual Studio intellisense debugs my logic as I type it. Having the IDE proofreading my sources as I type it is a huge productivity win. Of course, if the program logic is built around types, that is - but with F# this is the easiest way to write stuff any way.

- This is a fringe issue but one can write Unity scripts in F# :)


One of the reasons I chose F#. Too many choices for a Scala novice. Seems to be a pervasive pattern.

I think Scala was actually a better choice since my company mainly does AI/ML (python) and Scala has some clout in data science. But I’m only migrating the application layer so not a deal breaker.

I was leaning more towards Scala going into the “exploration phase”.

——————————

Side note. Using typescript on front end, f# on back, vscode, and GitHub for repo + CI/CD. Feels nice using a single vendor (Microsoft) for dev, even though each tool is stand-alone.


Mostly because of user experience. F# as .NET language has entire ecosystem of high quality libraries to pick from, good IDE support (not as good as Java/C#, but definitely better than Haskell) and smaller learning curve. It's also way more robust than Rust - meaning that you can make a working project with decent performance much quicker. I say that as both F# and Rust developer. IMO the language that covers similar area and may be more tempting to learn is Scala. But if you already know how to utilize .NET platform, then reusing that knowledge in F# is just easier.

I worked quite a bit with F# and Scala.

I really like F# pipelines and function declaration syntax.

On the other hand I've found Scala's case classes cleaner than F#'s (maybe that's because I am coming from an OOP world).

Additionally F# has a cleaner pattern matching compared to Scala.

Both languages have very good support for actor model concurrency (love akka actors and .net agents)

I think that if F# would have had a rich ecosystem the way Scala has, it could become a real contender.

(my 2 cents on F#)

next

Legal | privacy