←back to thread

Why F#?

(batsov.com)
447 points bozhidar | 1 comments | | HN request time: 0.248s | source
Show context
eknkc ◴[] No.43546122[source]
As far as I can tell F# is one of those things where every single user is extremely happy. This happens rarely and I really am curious about the thing but never had time to get into it. I'm also pretty well versed in the .net ecosystem so it's probably gonna be easy.

Any tips? What kind of workflows might benefit the most if I were to incorporate it (to learn..)?

replies(4): >>43546205 #>>43546241 #>>43546333 #>>43548384 #
pjc50 ◴[] No.43546333[source]
The funny thing is that you can write very similar code in C#, so maybe you don't need to switch which language you're using as a CLR frontend.

    using System.Linq;
    using System;

    var names = new string[] {"Peter", "Julia", "Xi" };
    names.Select(name => $"Hello, {name}").ToList().ForEach(greeting =>   Console.WriteLine($"{greeting}! Enjoy your C#"));
LINQ is such a good library that I miss it in other languages. The Java stream equivalent just doesn't feel as fluent.
replies(8): >>43546511 #>>43547010 #>>43547095 #>>43547391 #>>43548261 #>>43548541 #>>43553969 #>>43554778 #
klysm ◴[] No.43547010[source]
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
replies(3): >>43547086 #>>43549695 #>>43555783 #
DeathArrow ◴[] No.43555783[source]
Yes, ForEach isn't idiomatic but he could use Select instead.
replies(1): >>43571878 #
1. klysm ◴[] No.43571878[source]
Side effects in a Select is not idiomatic either