r/programming • u/k_cieslak • Aug 14 '18
Announcing F# 4.5
https://blogs.msdn.microsoft.com/dotnet/2018/08/14/announcing-f-4-5/15
Aug 14 '18 edited Aug 14 '18
Does F# interactive work with .Net Core now?
6
u/peeeq Aug 15 '18
It's still not implemented. Imho they should stop adding features to visual studio and instead put more effort into basic cross-platform tooling. Currently it still feels like a "Windows first" language which hinders adoption. Most developers I know are on Mac or Linux.
3
u/phillipcarter2 Aug 15 '18
No. There is significant work remaining, including building a palatable means to use a compiler plugin model that would be needed to have sane referencing of assets in a cross-platform way. FSI was also originally built with an assumption of
.dlllayouts on disk, and an older MSBuild binary that is not cross-platform. Much of the foundational work is now done to eliminate those assumptions, but we need to complete the whole thing.There are separate questions about an editor "interaction model" with mixed SDK/non-SDK projects in a solution. This is independent of Visual Studio and would only not be a problem if you used FSI only in the command line, which most people don't do. This is also on the docket.
2
21
u/RobertVandenberg Aug 15 '18
F# is definitely one of languages that deserve more love from people. Great to see this.
19
u/pure_x01 Aug 15 '18
Agree. It has the light-weight feel of python but is statically typed and is more performant. It also has very nice constructs for functional and object oriented programming.
For newbies: https://fsharpforfunandprofit.com/
7
13
u/FluorineWizard Aug 15 '18
Generally speaking, ML derivatives should have seen more development and use if languages were actually judged by their own merits.
26
u/mytempacc3 Aug 14 '18
I've never seen a job offer asking for F#. What kind of projects or industries are using it?
47
Aug 14 '18
I used it once because no one told me what language to use; they just wanted a win forms application. Does that count?
37
3
u/makkynz Aug 15 '18
How happy were they about that?
28
Aug 15 '18
It didn't come up. I was the only person remotely technical involved in the project. They wouldn't have even known what F# or C# were.
20
Aug 15 '18
We moved from C# to F# last year at my company. We're currently at about 8,000 lines of F# code. The benefits of the stricter compiler and the expressiveness of the type system were perfect for the problem we had to solve. Our product is a gateway between APIs, sort of like the controller of a multi-process MVC application.
After almost a year of coding with F#, everyone on my team has come to like it more than C# for a lot of domains. I don't remember where I read it, but somewhere I read that, "F# makes writing hard things easy at the cost of making easy things hard." That's the best, most succinct way to express F# I think. GUI applications are much better suited for C#, while a database controller or a JSON interface might be better for F#.
12
u/csman11 Aug 15 '18
I don't remember where the quote is from either, but it is about FP in general. The basic idea is that pure FP makes it difficult to express the basic side effects that every program has. It's great for expressing solutions to complicated problems, but completely overkill for solutions to the simple problems we have to solve most of the time. It's about finding a balance where you separate the critical code from the side effects and are able to "reason about" the functional code. That balance is different for every system, but most of the time it doesn't mean you need to embrace "monads," "linear types," "effect systems," or any other explicit static and formal way of expressing effects. It's just common sense that "policy" (business logic) should be separated from "mechanism" (effects). We just don't have the time to do it in general.
Most of the difficulties come because code was written under strict deadlines and the author had to ignore best practices. We like to poke fun at things like "enterprise fizz buzz," but the reality is most code is seriously underarchitected. Very few programmers go to an extreme to overcomplicate things in a way that leads to that. Most of the issues come from doing it quick and dirty. Finding the balance between the "right way" and the "expedient way" is the goal. The catch is no one knows how to do it well all the time and we are all learning. That's why there are no silver bullets.
There are other things at play as well of course (decent libraries for the task at hand, knowledge of the domain among people who are working on a project, etc), but most software sucks because it is just a hack job to do the thing the business said it needed done 5 years ago.
5
u/JoelFolksy Aug 15 '18
GUI applications are much better suited for C#
Have you played with Elmish.WPF? It's rapidly becoming my favorite way to do a WPF app. You only create C# projects to hold your .xaml files.
1
Aug 15 '18
I've been looking at Elmish.WPF recently. I kind of like it, but I have doubts: Don't you end up with a flat and enormous list of bindings at the top of your application? How do you structure that?
My use case implies multiple Excel/Access-style data grids at once, but I couldn't figure out how would I two-way bind the model to the cells. Using nested bindings sounds too bloated to me.
As a side note, I also gave a try to Elmish.XamarinForms with the WPF backend. The backend is not ready at all, but I must say writing dynamic views react-style is amazing; I'm eager to use it on mobile now.
2
u/JoelFolksy Aug 16 '18
As far as structuring the bindings, it's just a list, right? So you could create a bunch of sublists in different modules/files, and concatenate them into the final list.
Your data grid use case sounds more sophisticated than any of mine - hard to say if it can be well supported.
1
Aug 16 '18
I hadn't heard of that before, but I will definitely check it out! Based on a quick one-minute scan of the README, it looks pretty awesome. Thanks!
15
u/sicranchez Aug 15 '18
Jet.com uses it. Lot of insurance providers seem to use it for risk modeling. FSharp Foundation testimonials has a few examples of where it is being used.
26
u/colelawr Aug 15 '18
Jet.com, a competitor to Amazon, is using F# for most of their code
15
20
u/dudeNumberFour Aug 15 '18
Nobody. It's an awesome language, there's no reason not to use it. I suppose it's nothing but old anti-MS bias that kept it from going places. .Net analog to scala, very comparable; scala is used a ton, F# almost not at all.
38
Aug 15 '18
It wasn't anti-Microsoft bias, it was more likely Microsoft itself. Up until recently F# was a second class citizen in the Microsoft tool universe. It's getting more love now with .NET core, but notice you don't see even 1 project template for using it to make a UWP application.
I think there are a few bitter dregs amongst the F# faithful that the language gets little/no official attention from its creator.
6
u/pjmlp Aug 15 '18
.NET Native (required for UWP) does not support F# bytecodes and there is no public roadmap of it ever happening.
UWP only supports JavaScript, C#, VB.NET, C++ and Python (on IoT Core).
UWP is not the only case, to this day Forms, WPF and EF designers still don't work with F# code generation, only VB.NET, C# and C++/CLI.
8
5
Aug 15 '18
It wasn't anti-Microsoft bias, it was more likely Microsoft itself. Up until recently F# was a second class citizen in the Microsoft tool universe.
The problem with Microsoft is being a second class citizen in this context can mean Microsoft could as worst scenario scratch F# as deprecated next year.
Sure, it might seem like a small risk... but who is willing to take that risk for a larger project, when there are other options.
10
Aug 15 '18
The problem with Microsoft is being a second class citizen in this context can mean Microsoft could as worst scenario scratch F# as deprecated next year.
Which in Microsoft terms means support will probably continue through 2040. Even if they deprecated it tomorrow, it will still probably outlast most products built with it. VB 6 is still supported in Windows 10 FFS.
-3
u/mytempacc3 Aug 15 '18
B 6 is still supported in Windows 10 FFS.
Makes sense. I love to write my new apps in VB 6 or Rust.
6
u/aaron552 Aug 15 '18
Microsoft could as worst scenario scratch F# as deprecated next year.
The community would likely fork it at that point.
3
Aug 15 '18
To be fair, F# is increasingly community-driven. This worry definitely hindered the adoption of F#, but I don't think of it as a risk anymore.
30
u/zqvt Aug 15 '18
it really is a shame, it's a great language, I wouldn't even compare it to Scala. Scala seems to me very cluttered and I don't like the syntax at all. The sea of underscores instead of providing currying by default for example just looks convoluted to me, pattern matching in F# is simpler, the syntax overall is much cleaner. Also, F#'s type inference is more powerful, the first time I saw type providers on a sql database it looked more like dark magic than programming lol.
1
u/jyper Aug 15 '18
Currying ia hard to read
4
u/TarMil Aug 15 '18
Everything can be done in excess, but used well it can make things very readable on the contrary.
7
u/jyper Aug 15 '18
C# is a better language then java
Also being an ml f# is stranger to java/c# programmers tthen scala
2
u/pjmlp Aug 15 '18
Other than not being supported by UWP, HoloLens, XBox, IoT Core, EF, WPF/Forms designers, .NET Native.
7
7
u/AngularBeginner Aug 15 '18
Lots of financial institutes in London. Also software for some slot machines is written in F#, as you can pretty often represent the entire game logic in the F# type system.
11
u/chucker23n Aug 14 '18
What kind of projects or industries are using it?
I understand it’s big in finance.
5
u/ProfessionalNihilist Aug 15 '18
I've worked with F# professionally and have applied at other places using it (Cambridge UK). I've prototyped something in it at an education company and used it fairly extensively in a company in the commodities trading industry. I know of some companies in other industries using it too.
I've seen jobs for it in London too (usually finance) but I am not doing that commute.
If you are interested in using you should follow https://twitter.com/fsharpjobs
3
u/greenspans Aug 15 '18
Why not use ocaml, haskell, clojure or idris? Because it takes no time to find a team of java or node devs that do things, good enough™, as long as you give them enough structure not to shoot themselves in the foot.
2
5
3
Aug 15 '18
Nice! Been waiting for the match! keyword for ages.
PS Can we get FSI working in dotnet core, now. Pretty please!
8
u/MorrisonLevi Aug 15 '18 edited Aug 15 '18
Due to their open-source history I have avoided Microsoft technology stacks, even on my home computers. However, if there was any single technology that they have that interests me it is F#. It seems like a functional language that tries to be understandable by people who aren't coming from the functional world, and it seems like you might be able to use it for projects that need C# interop, so you have an imperative "escape hatch". How wrong/correct are these statements?
9
Aug 15 '18
The .Net team is demonstrating a lot of interest in supporting the open source community. While that may not last I think it's somewhat safe to rely on so long as MS is getting spanked in the mobile space. Getting their language used across platforms is the only way for them to get back into the game and the OSS community is the only way that's ever going to happen.
0
u/oblio- Aug 15 '18
That’s never going to happen. Despite being considered subpar, MS DOS was never replaced as the text only client PC OS. Despite being considered subpar, Windows was never replaced as the GUI client PC OS. Now that the mobile market has stabilized, Android will never be replaced. The network effects guarantee that.
What Microsoft can do, at least partially, is provide apps for all platforms ($$$) and development tools that link into their backends (more $$$).
The next big step is wearables, but that’s probably a decade away: AR needs to mature, input methods need to be refined, processing power needs to go up while the hardware needs to become smaller and more robust. And even then, the mainframes are still with us, as are PCs. Wearables will just be another gizmo in the toolkit (at least for the first generations).
8
u/matthewblott Aug 15 '18
What was Windows considered subpar in relation to? The reason Windows is dominant on the desktop is because Linux desktop is poor by comparison and the only real alternative is / was OSX which only runs on expensive Macs.
4
u/aboukirev Aug 15 '18
In relation to OS/2. OS/2 was a much better experience to use (but not to install: a huge pack of floppy disks and 3 different UIs during installation process, yuck)
1
13
u/flyingjam Aug 15 '18
That's basically why I use it in many personal projects. It's a full fledged functional ML style language, not the Scala bastardizations, and unlike, say, Haskell or ocaml, gives you all the libraries of the .net ecosystem.
4
2
Aug 15 '18
TIL let fn() = is correct style
6
u/nikofeyn Aug 15 '18
is it? i have seen both
let example() = ...and
let example () = ...i personally find the second more clear in the function definition since you are defining a function that takes () as its parameter and not defining a function with zero arguments.
although when calling, i feel that either either example() or example () is fine, and i have probably used the former more often.
2
u/needadvicebadly Aug 15 '18
same here, but I noticed that Don Syme amd most of the core language people use the
let example() =style. When I was learning I found it confusing becusae initially I thought it was some special syntax for some reason3
u/CSharpFan Aug 15 '18
Odd. Because
()is really unit. I.e. a val that takes unit and does something. It’s not part of the language.1
u/aaron552 Aug 15 '18
If you do
let fn = ..., the F# compiler treatsfnas a "value", not a function. The most obvious example is in recursive functions:let rec fn = let a = Console.ReadLine() if not (a |> String.isNullOrEmpty) then printfn "%s" a fnThis won't compile.
I suspect the preference for not putting a space before the parentheses is to indicate more clearly "this binding is a function".
Leaving out the space may also be a way to distinguish ".NET-safe" (ie. not curried) functions.
1
Aug 15 '18 edited Aug 15 '18
It makes more sense if you also compare the tupled version:
let fn(a, b) =. This makes functions of unit/tuple parameter look the same as methods, for which the style choice is too familiar to change.Edit: forgot about reddit's new fancy editor.
1
u/igouy Aug 15 '18
How do I update .NET Core 2.1 (on Ubuntu) with F# 4.5 ?
(The docs all seem to be about updating Mono).
0
Aug 15 '18
[deleted]
1
u/igouy Aug 15 '18
Thanks !
I just checked Software Updater and it shows
Microsoft .NET Core SDK 2.1.400
31
u/phillipcarter2 Aug 15 '18
Hey folks, author of the post here. Really excited to release this for everyone. Please leave feedback and file issues on GitHub so that we can look at anything that seems funny.
F# would not be the amazing language it is without the wonderful and engaged community it has, so if you’re looking to jump in, there’s no better time than now!