News for hackers. Stuff that matters.
Re:The Problem with F# Evangelism by phillipcarter on Wednesday August 16, 2017 @11:26AM (#15028211)
I actually work on F# at Microsoft. I've had success and some failures when it comes to evangelizing F# through Microsoft (but mostly success if my measures are accurate). I strongly believe that it can be boiled down to one major thing:

Programmers learn how to program with C-style languages. C, C++, Java, C#, JavaScript, Python (sorta) . . . they're all in the same family. People, especially while learning, associate programming with specific constructs and idioms of C-style languages. It's incredibly difficult to break that barrier.

I think that functional programming is on the rise, and that more and more developers are starting to realize that the types of bugs that hold them back can be reduced by using a more powerful language. But it's got a very long way to go, because there is a lot of unlearning to do. The article alludes to this a bit. For example, immutability is one of the key concepts in nearly every FP language. Functional programmers take it for granted, but it's transformational and completely changes the way you have to solve a problem. This hump is often too big for many people to get over, at least in their first trial with a functional programming language. It's hard to solve a task you know how to solve when you now need to re-think your approach because the language doesn't let you change x in-place.

Additionally, I believe that many programmers aren't necessarily aware of all of the problems they're having. The next time you hear someone say, "and make sure to check for null here", watch them to see if they're seeing that as a general problem hurting their ability to get bits out the door or not. In my experience, it's not usually viewed that way. Yes, null is a necessary evil in many environments, but it's one that can be tamed, and different languages have already figured out how to do that. But unless it's seen as a problem by people at large, they won't see that as a carrot when you wave things like Optional types in front of them.

Overall, I'm still excited. Jet.com is a billion-dollar company that built their stuff with F#. There are similar stories of companies successful with F# (and other functional programming languages), and it feels as though this is happening more often. And as the mainstream (read: C-style languages) adopt more functional programming techniques, I think this will only get better. I think that people will see the value, then see a language which does it better, and give it a try.

Re:The Problem with F# Evangelism by runT1ME on Wednesday August 16, 2017 @02:17PM (#15029809)
My previous job was working for a .NET shop that powered tons of automotive search engines etc. across the web. We moved to more and more functional concepts using C# as the team learned about them and had a lot of success with them. At a certain point, we explored using F#, but the lack of type classes & HKTs meant we kept having to repeat ourselves.

We ended up choosing Scala for some new projects despite having an inferior IDE experience and being unable to use some of our other libraries. I don't think I can emphasize how much not having type classes and HKTs hurts productivity once you buy into the fully functional mindset. We were extremely productive in Scala because the language was a bit more powerful.

I would love to use F# again, but not until the language adds those features.

Re:The Problem with F# Evangelism by corn_dog on Wednesday August 16, 2017 @04:11PM (#15030891)
Is there anything about using F# that you would see as a plus over Scala or Haskell?
Re:The Problem with F# Evangelism by runT1ME on Friday August 18, 2017 @08:37PM (#15050845)
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 `_`).

Re:The Problem with F# Evangelism by GiorgioG on Wednesday August 16, 2017 @12:21PM (#15028734)
I'll get excited when the Visual Studio team actually holds up a release because something is horribly broken in its F# support. So basically...never.
Re:The Problem with F# Evangelism by toyotaboy on Thursday August 17, 2017 @05:43AM (#15035152)
Just use VS Code + Ionide. That's where the action is for at least for F# + .NET Core
Re:The Problem with F# Evangelism by TensorMetric on Thursday August 17, 2017 @09:36AM (#15036614)
It's misleading to pretend that it's a substitute for full Visual Studio.
Re:The Problem with F# Evangelism by flavio81 on Wednesday August 16, 2017 @12:19PM (#15028712)
> People, especially while learning, associate programming with specific constructs and idioms of C-style languages. It's incredibly difficult to break that barrier.

I'd say this is the main problem with the programming community at large, in 2017.

Re:The Problem with F# Evangelism by arwhatever on Wednesday August 16, 2017 @04:11PM (#15030900)
I feel like someone invented a toaster oven that doesn't catch fire, but everyone wants to stick with the model that does catch fire all the time.
Re:The Problem with F# Evangelism by pjmlp on Thursday August 17, 2017 @02:28AM (#15034233)
Because when you manage to actually make a meal on both of them, the ones from the latter taste better.
Re:The Problem with F# Evangelism by srean on Wednesday August 16, 2017 @12:07PM (#15028611)
At what point does big company politics become a drag rather than a lift ? F# is not Microsoft's important story in a way that Java was for Sun.

In such situations, I wonder if something that came into being organically and in the open (and helped on by a sugar daddy) has better chances/purchase.

Re:The Problem with F# Evangelism by pjmlp on Wednesday August 16, 2017 @12:13PM (#15028656)
Replacing the contents of my previous post regarding VS 15.3 support of F#.

"For long time .NET developers, a common question is "when will Visual Studio support F# .NET Core projects". We’re working hard to get this functionality ready, but unfortunately, we’re not quite happy enough with the quality in the 15.3 update to announce that it’s fully supported. While Visual Studio 2017 version 15.3 is able to open the new F# .NET Core projects, build, and debug them, IntelliSense does not yet work correctly"

From

https://blogs.msdn.microsoft.com/dotnet/2017/08/14/f-and-net...

Re:The Problem with F# Evangelism by phillipcarter on Wednesday August 16, 2017 @12:17PM (#15028689)
I'm sorry, but what you're saying is factually incorrect. Can you please update your comment so as not to spread misinformation?
Re:The Problem with F# Evangelism by pjmlp on Wednesday August 16, 2017 @12:25PM (#15028773)
Updated with the blog quote.
Re:The Problem with F# Evangelism by phillipcarter on Wednesday August 16, 2017 @12:47PM (#15028981)
This is for the .NET Core tooling support part of F#, and as we've stated in the blog post, we prioritized the quality of cross-platform usage here. You're free to disagree with this prioritization, but please don't craft a narrative about the relationship between F# and Microsoft that can mislead people as you did before.
Re:The Problem with F# Evangelism by pjmlp on Wednesday August 16, 2017 @12:54PM (#15029038)
If the issues faced by your team were related to C# I assume management would have taken other path.

And this is the reason why none of our customers wants to even discuss integrating F# into C# projects.

Re:The Problem with F# Evangelism by phillipcarter on Wednesday August 16, 2017 @01:03PM (#15029124)
Perhaps it's worth taking a different viewpoint. With VS 2017, no single release updates every part of the product to the latest things. For example, UWP does not support .NET Standard 2.0 yet. That did not put the VS 2017 15.3 release on hold. Similarly, although F# fully supports .NET Core and .NET Standard 2.0 with this release, the tooling quality wasn't high enough for us to declare the associated tooling support in VS as fully supported. That also did not put the VS 2017 15.3 release on hold. This because we're already three updates into Visual Studio, and it's only been 6 months since its release. Visual Studio updates faster and teams can release things easier and more rapidly without needing to wait for everything else. This is a really good thing.
Re:The Problem with F# Evangelism by pjmlp on Wednesday August 16, 2017 @03:43PM (#15030575)
Point taken, but apparently Microsoft employees keep forgeting F# is part of .NET, or isn't EditorConfig at all relevant for F#?

https://docs.microsoft.com/en-us/visualstudio/ide/editorconf...

Re:The Problem with F# Evangelism by twodave on Wednesday August 16, 2017 @02:56PM (#15030121)
This, and also VS2017 did in fact ship C# without some things (for instance, full support for value tuples).
Re:The Problem with F# Evangelism by TensorMetric on Thursday August 17, 2017 @10:44AM (#15037199)
This is minor compared to all the major things VS isn't shipping for many years in a row now.
Re:The Problem with F# Evangelism by rottyguy on Wednesday August 16, 2017 @11:29AM (#15028259)
"...realize that the types of bugs that hold them back can be reduced by using a more powerful language."

I hear this a lot with FP but would love to see some real world examples of this if anyone has any links.

Re:The Problem with F# Evangelism by dep_b on Wednesday August 16, 2017 @11:51AM (#15028457)
I can't give you any examples in F# from the top of my head, haven't touched it for a few months but I did ship software with it. I can give an example in Swift:

C#:

    ResultObject MyFunction(SomeObject some, AnotherObject another)
You have no idea if every value you pass in is required, or if you would always get a ResultObject or also need to expect null. Could possibly throw an Exception as well.

Swift:

    func myFunction(some: SomeObject, another: AnotherObject?) throws -> ResultObject
Forces you to give SomeObject, but you can pass nil to AnotherObject if you would like to, and the code inside this function will be forced to deal with it. Also it will always return ResultObject unless it throws an Error.

You will have no surprises using Swift while C# forces you to guess unless you know the inside of the function. F# works the same as Swift in that regard. You need to be explicit about nullability and mutability, and if it is nullable you are forced to deal with it it before you use it. Immutable and non-nullable is just easier to use.

The leap between C# and F# is much bigger because C# is really good and F# is a real functional language where Objective-C was older and Swift is less functional. Same goes for Java vs. Kotlin. Android Java is terrible compared to C# while Kotlin is much more similar in syntax.

Re:The Problem with F# Evangelism by phillipcarter on Wednesday August 16, 2017 @11:40AM (#15028355)
It's often very difficult to come up with one, because there isn't really a silver bullet here.

The draw to F# for me, when I was learning it, was I needed to build a DSL in a large system I was working on (side note: there must be a law somewhere stating that any large system will have a DSL in it somewhere). I didn't know about libraries like FParsec or anything (or a C# equivalent), so I just googled "how to write a DSL C#" and ended up somewhere showing F# code. I was curious.

A week later, I wrote the whole thing in F#, with tests, and all requirements were fulfilled. Upon re-writing in C# (because reasons...), I had to re-think the problem. I used F# types and pattern matching everywhere, and Active Patterns to make stuff really concise and readable. A lot of the branching logic in my C# rewrite didn't really exist in F# because of this, and it was really hard for me to track down how everything worked in C#. I'm still convinced that someone unfamiliar with F# could understand the F# version better than the C# version because of how much less code and branching logic was involved.

For a more professional case study, Microsoft Security Risk Detection is a fuzz testing service written in F#: https://blogs.msdn.microsoft.com/dotnet/2016/12/13/project-s...

We blogged about their experience, and they do have practical examples there.

Re:The Problem with F# Evangelism by yawaramin on Tuesday August 22, 2017 @08:30PM (#15077526)
Units of measure. So in C# you can do something like this (using floats for convenience):

    class Power {
      public static HoursUsed(
        float totalBillDlrs, float deviceWattage, float rateDlrsPerkWh) {
        return 1000.0 * totalBillDlrs / (deviceWattage * rateDlrsPerkWh);
      }
    }
Then call it like this:

    var totalBillDlrs = 10.95;
    var deviceWattage = 100.0;
    var rateDlrsPerkWh = 0.15;

    Power.HoursUsed(deviceWattage, totalBillDlrs, rateDlrsPerkWh);
But, oops! that was actually supposed to be:

    Power.HoursUsed(totalBillDlrs, deviceWattage, rateDlrsPerkWh);
In F# you can use units of measure to prevent this kind of thing at compile time:

    [<Measure>] type dollar
    [<Measure>] type watt
    [<Measure>] type kilowatt
    [<Measure>] type hour

    module Power =
      let hoursUsed
        (totalBill : float<dollar>)
        (deviceWattage : float<watt>)
        (rate : float<dollar/(kilowatt hour)>) : float<hour> =
        1000.0<watt/kilowatt> * totalBill / (deviceWattage * rate)

    let totalBill = 10.95<dollar>
    let deviceWattage = 100.0<watt>
    let rate = 0.15<dollar/(kilowatt hour)>

    // Compile error
    Power.hoursUsed deviceWattage totalBill rate
And, yes, in C# you can use things like named parameters to reduce the chances of something like this, but you can't eliminate it at compile time, which is what F# does.
Re:The Problem with F# Evangelism by tome on Wednesday August 16, 2017 @12:05PM (#15028602)
How many times have you had the runtime exception

    AttributeError: 'NoneType' object has no attribute 'foo'
(or its equivalent in your favourite language)?
Re:The Problem with F# Evangelism by earthtolazlo on Wednesday August 16, 2017 @02:05PM (#15029681)
That's something addressed by static typing though. I'm pretty sure any dynamic language has that issue, functional or not.
Re:The Problem with F# Evangelism by tome on Wednesday August 16, 2017 @07:17PM (#15032173)
It's fair to say that the boundaries of "functional programming" are pretty amorphous and I certainly didn't mean untyped functional programming. In any case, if you want to prevent null/None errors in a way that gives the programmer his/her own access to create similar new abstractions then you need

* sum types

* parametric polymorphism

* pattern matching

at which point you may as well also add

* first class functions

and then if you don't describe your language as "typed functional" then how do you describe it?

Re:The Problem with F# Evangelism by brianberns on Wednesday August 16, 2017 @12:00PM (#15028533)
Is your programming language unreasonable? or, why predictability is important

http://fsharpforfunandprofit.com/posts/is-your-language-unre...

Re:The Problem with F# Evangelism by nickpeterson on Wednesday August 16, 2017 @04:59PM (#15031333)
Speaking of Jet.com and their billion, here is their GitHub page, https://github.com/jet

:(

Re:The Problem with F# Evangelism by toyotaboy on Thursday August 17, 2017 @05:44AM (#15035159)