Skip to content
HomeVideosBooks
AllTopicsTrends
BlogsPodcasts
HistoryListsWatch laterLiked videosFollowing

The videos, books, blogs and podcasts Hacker News keeps recommending, all in one place.

VideosBooksBlogsPodcastsAboutPrivacySettings

Data from Hacker News, HackerTube, HackerBooks, HackerBlogs and Open Library. Credits · Not affiliated with Y Combinator.

HomeVideosBooksBlogsPodcasts
Ctrl K
    Functional Programming Using F#Michael R. Hansen

    Functional Programming Using F#

    Michael R. Hansen, Hans Rischel · 2013

    Lisp & FunctionalProgrammingComputer Science
    Open LibraryAmazon
    Stats for nerds
    2recommend
    2mentions
    2people
    2019–2022years
    100% recommend

    Mentions per year

    2019202020212022

    What Hacker News says

    1. bmitcAug 2022
      Yes, please do! Warning: F# will ruin other languages for you. I find it rather painful to work in basically anything else after using F#, with gradients of pain for different languages. Haha.

      And that's a good question. I have basically every book written on F#, but I can't say I have ever used them for anything more than reference.

      The official docs/guide/reference are actually really good, and I refer to them a lot when using some feature I'm not familiar with: https://docs.microsoft.com/en-us/dotnet/fsharp/what-is-fshar...

      F# For Fun and Profit is well-known, but I can't say I use it a lot: https://fsharpforfunandprofit.com/

      The same author's (Scott Wlaschin) book is very good: https://pragprog.com/titles/swdddf/domain-modeling-made-func...

      As for books, I have always liked:

      * Functional Programming Using F# by Hansen and Rischel (might be too simple if you are already comfortable with functional programming and is out of date every now and then with changes to F# that's happened)

      * Expert F# 4.0 by Don Syme and others (contains a lot of nice things by the designer of F#

      One of the latest books is Stylish F# 6: Crafting Elegant Functional Code for .NET 6 by Kit Eason. I have the first edition but haven't read it.

      My personal recommendation is to take the approach of type/domain driven design. That is, I start off every F# module the same:

      1. Define my types with discriminated unions, records, type aliases (such as for tuples) or single case discriminated unions. Use classes when necessary but try to prefer the more functional types.

      2. Start writing functions against these.

      And that's basically it. One thing to recognize with F# is that it mixes OOP rather nicely. Even discriminated unions and records, which are immutable, can have members defined on them, including operator overloading (something F# is pretty good about). They can even implement interfaces and be defined with generic types, which is also nice and powerful.

      I have some projects that might of interest, since they're simple enough and illustrate the above process.

      https://github.com/bmitc/the-ray-tracer-challenge-fsharp

      https://github.com/bmitc/nand2tetris

      Lastly, I'd suggest just starting up some projects. You could also take the Programming Languages course on Coursera by Dan Grossman. Part A uses SML, and you could port the examples and homework solutions to F# (I did so when I took the course). I also take books written for other languages and port the code to F#, usually taking a more idiomatic functional style. .NET Interactive notebooks (https://github.com/dotnet/interactive) are a great way to get started. You just need to install the .NET 6 SDK (which gets you F#) and then install the .NET Interactive Notebook extension in VS Code. That's it. There is also the book The Little MLer which gets people comfortable with discriminated unions (sum types), and I used the book and ported the examples to F#. I need to go back and finish that annotation project (https://github.com/bmitc/the-little-fsharper). I'll probably convert the script files to .NET Interactive notebooks if I do.

      thread
    2. nikofeynMar 2019
      the oft recommended f# for fun and profit is good as a reference, but i personally haven't found it good as a tutorial. the explanations are often not expedient and show (too) many ways of doing things to get to the point. i go there when i have something very specific in mind. i often find the official microsoft f# documentation to be quite good and my go to reference.

      as for books, there are a lot. none of them really fully resonate with me, although they are usually pretty good, but the book functional programming using f# by hansen and rischel is fairly nice. it is more academic in tone, although it was written a while ago against an older version of f#, so there may be some slightly out of date or style code. the book expert f# is by the language designer, and it shows some nice advanced stuff in a clear way.

      i also recommend going through the little mler by translating the sml code in the book to f#. it will get you used to using types and pattern matching the way they are done in ml dialects. you will be able to do everything up until they cover the module system.

      i have some very simple code here: https://github.com/nikofeyn/ray-tracing-with-fsharp/tree/mas...

      it isn't documented or to my usual style, as it is an incomplete project. i was going through the book ray tracing in one weekend by peter shirley and didn't finish. and this code was actually "ported" from racket code that i had originally started the book with. so it went from c++ -> racket -> f#. however, it shows some representative f# syntax for some numerical stuff. i have some more f# projects that show more type-based programming and pattern matching styles, but they are in private repositories.

      i personally just do not like python. it feels very sloppily designed to me, and i prefer scheme-based languages like racket and ml-based languages like f#. i have only worked in python when work has compelled me to, and i hated every instance of it. a large majority of it is that python is just difficult to reason about and is sloppy. that and the ecosystem, while vast, is very sloppy. i have encountered countless dependency issues and version headaches with python. it just isn't fun. all the work to get something working in python is just not worth it and unless you are reliant on some particular library, i personally don't see a reason to use it.

      meanwhile, racket and f# remain as easy to develop code as python, except that the code developed works and works well. they are just extremely nice languages to use. they are the only languages i have used where it doesn't seem they are fighting me.

      if you use python's async code, check out f#'s async expressions. they are extremely easy to use.

      i highly recommend dan grossman's programming languages course on coursera. the first module uses sml (you can basically directly port all the code and your own code to f# for fun and very easily). the second module uses racket. and the third module uses ruby. i recommend it for any programmer and especially for some not used to the functional style.

      thread

    Related

    Cover of Expert F# 3.0
    2013–2022

    Expert F# 3.0

    Don Syme
    6 recommend · 8
    Cover of Functional Web Development with Elixir, OTP, and Phoenix
    2017–2025

    Functional Web Development with Elixir, OTP, and Phoenix

    Lance Halvorsen
    4 recommend · 8
    Cover of Structure and Interpretation of Computer Programs
    2007–2026

    Structure and Interpretation of Computer Programs

    Harold Abelson
    347 recommend · 761
    Cover of How to Design Programs
    2007–2026

    How to Design Programs

    Matthias Felleisen
    277 recommend · 776
    Cover of Programming Erlang
    2007–2026

    Programming Erlang

    Joe Armstrong
    69 recommend · 105
    Cover of The Little Schemer
    2007–2026

    The Little Schemer

    Daniel P. Friedman
    288 recommend · 652
    Cover of Practical Common Lisp
    2007–2026

    Practical Common Lisp

    Peter Seibel
    218 recommend · 400
    Cover of The Implementation of Functional Programming Languages
    2008–2026

    The Implementation of Functional Programming Languages

    Simon L. Peyton Jones
    22 recommend · 44