Live data from Hacker News

Why you should learn F#

dusted.codes

51–60 of 179 posts

Re: Why you should learn F#

#51
post #45

"No matter if you are already a functional developer from a different community (Haskell, Clojure, Scala, etc.) or you are a complete newbie to functional programming (like I was 3 years ago) I think F# can equally impress you" -> "For this task and for the rest of this blog post I'll be comparing F# with C# in order to show some of the benefits." F# is neat, and I see why it's useful if you have a big .NET program a…

F# features that are unique or not present in all other functional langs:

* multi-threading (vs Ocaml) * type providers (perhaps totally unique) * units of measure * active patterns * computation expressions

Re: Why you should learn F#

#52
post #13

I've been diving into f# in 2018. I came from c# world, and it really made me a better developer. Really recommend the language. Think it has a great balance between functional programming and OO if it is really needed. I really do think it's easier to write better .net programs with f# then c#. Think this article point out some great stuff. That said, it's quite hard to actually get to use it in production at the pl…

"That said, it's quite hard to actually get to use it in production at the places I've worked. My college's are scared of it (that is pretty reasonable, considering c# is a good stable language and my team is confident that what we develop will make the customers happy)." That's my problem too. I would like to give F# a go but at work it seems close to impossible to implement. Most people don't see the need and if th…

Why not start introducing F# via unit tests?

Re: Why you should learn F#

#53
post #33

The only thing I don't like is the DI story presented here and many other F# guides. Having gone down that rabbit hole and using F# in production for 5 years now, I have gone back to classes and interfaces in almost all cases. Functions as DI mechanism suffers from a few things. First, it's hard to search for implementations. They could be defined anywhere. With interfaces, the implementations are a hot key away. Sec…

Can the F# compiler not convert a lambda to a single-function interface instance? Honest question. I'm mostly a Java guy, and I know that is how Java works under the hood because the JVM does not have the concept of delegates. But it seems like a fairly simple and safe transformation, even when your underlying target does have delegates.

Re: Why you should learn F#

#54
Honest question: As someone who does web development and is looking to learn a new programming language in 2018, would you recommend F# over Elixir (and why)?

Re: Why you should learn F#

#55
While I really like the concept of functional programming and F# is definitely on my list of practical useful languages to learn, this article is clearly written by someone who doesn't know C# very well.

Take the "To hell with interfaces" example.

  public interface ISortAlgorithm
  {
    List Sort(List values);
  }

  public class QuickSort : ISortAlgorithm
  {
    public List Sort(List values)
    {
        // Do QuickSort
        return values;
    }
  }

  public class MergeSort : ISortAlgorithm
  {
    public List Sort(List values)
    {
        // Do MergeSort
        return values;
    }
  }

  public void DoSomething(ISortAlgorithm sortAlgorithm, 
  List values)
  {
    var sorted = sortAlgorithm.Sort(values);
  }

  public void Main()
  {
    var values = new List { 9, 1, 5, 7 };
    DoSomething(new QuickSort(), values);
  }
No, no, no, no, nope.

  public static class MergeSort
  {
    public static List Sort(List values)
    {
        // Do MergeSort
        return values;
    }
  }

  public void DoSomething(Func, List> 
  sortAlgorithm, List values)
  {
    var sorted = sortAlgorithm(values);
  }

  public void Main()
  {
    var values = new List { 9, 1, 5, 7 };
    DoSomething(QuickSort.Sort, values);
  }
No interface necessary.

Or immutability:

  "public struct Customer
  {
    public string Name { get; }
    public string Address { get; }

    public Customer(string name, string address)
    {
        Name = name;
        Address = address;
    }
  }
So far so good, but unless someone knows C# very well one could have easily gotten this wrong."

Really?? This is beginner stuff.

I 100% agree that null sucks, functions should not need to be in classes and immutability is great, but this kind of strawman doesn't help his point.

Re: Why you should learn F#

#56
post #55

While I really like the concept of functional programming and F# is definitely on my list of practical useful languages to learn, this article is clearly written by someone who doesn't know C# very well. Take the "To hell with interfaces" example. public interface ISortAlgorithm { List Sort(List values); } public class QuickSort : ISortAlgorithm { public List Sort(List values) { // Do QuickSort return values; } } pub…

I agree, it feels like the author is going out of their way to write really really verbose C#

Re: Why you should learn F#

#57
post #54

Honest question: As someone who does web development and is looking to learn a new programming language in 2018, would you recommend F# over Elixir (and why)?

This has been previously mentioned but F# gets all of the goodies that come with being a .NET language. Elixir comes from Ruby land and thus has a framework called Phoenix(?) which also has its fans.

The big difference is that F# is a statically typed functional language, while Elixir is a dynamically typed functional language. Comparison of static vs dynamic types -> https://hackernoon.com/statically-typed-vs-dynamically-typed...

I personally opted for F# because of the domain modelling tools and the offloading of various caveats and edge cases onto the compiler's stack rather than the meatspace stack, but Elixir has many fans for a good reason no doubt, but I'll defer to someone with more experience working with it to weigh in.

Re: Why you should learn F#

#58
I don't touch anything that runs on CLR or a JVM: waiting for the world to compile is unacceptable. For functional programming, I'll just continue learning ANSI common Lisp which compiles straight to machine code, thank you very much.

Re: Why you should learn F#

#59
post #22

A gripe about F# on MacOs - how to install it, count the ways - 6. https://fsharp.org/use/mac/ Don't I need Mono, wait, shouldn't I be using .NET? Oh I will probably install it one way, only to discover I should have installed it another. I find the .NET and Mono differences confusing. So this is a barrier to entry to consider. That said, this free book is kind of nice introduction: https://www.oreilly.com/programmin…

brew install fsharp or similar worked fine for me.

Did you get fsi with that? That was the one thing that made me eventually install Mono.

Re: Why you should learn F#

#60

F# is 3 big things to me: Safer threading with immutability Safer programming with null-safety Safer logic with precise domain modeling The precise domain modeling is the real paradigm shift. The whole point of static typing is to inform the compiler about your intent so that it can provide guarantees about correctness. F# makes it easy to define lots of small types that precisely model state so that you can give mor…

>I have personally struggled with domain complexity in C# that i was able to model precisely in F# and have it work perfectly on the first try. If you're willing to provide a (simplified) example I would be very interested.

There are some nice examples here: https://fsharpforfunandprofit.com/series/why-use-fsharp.html

I like this one: https://fsharpforfunandprofit.com/posts/designing-for-correc...

Post reply on HN