Question

I've recently studied the code of FParsec the F# port of Haskell Parsec parser combinators library.

FParsec public API is completely functional, but it relies on support library FParsecCS that relies on mutable data structures and performs explicit memory management using CLR unsafe constructs.

I think that this is done for performance reasons.

My experience with Functional Programming is still limited, so I'm asking to more experienced FP developers, if this could be a good technique to adopt in this scenario.

Was it helpful?

Solution

Generally speaking you should stick with a more functional style. A few exceptions are:

  1. Public Libraries (for performance reasons)
  2. Performance Critical sections of your app
  3. Apis consumed by other languages (functional apis may be more difficult for non-functional languages to consume)

Even for these exceptions, frequently there is a functional means of doing what you're trying to do with a functional style (api definitions excluded), so make sure you explore your functional options before turning to a more imperative or OO style.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top