After reading @ray vernagus post about using ArcObjects with F#, I have been wondering ... what types of GIS problems are better handled by Functional Programming, as opposed to more traditional forms of programming?

Perhaps more specifically, when would I be better off using F# as opposed to C# with ArcObjects?

  • Perhaps the paradigm one chooses depends upon what one intends to program for, one of your links contains references to alternate paradigms and a comparison of what they are suited for en.wikipedia.org/wiki/Comparison_of_programming_paradigms
    – user681
    Apr 21, 2012 at 20:14
  • @DanPatterson Thanks for the feedback. What I'd like to see are specific GIS problems where F# is more suitable than C#. If I can see that, then I might be able to justify investing time to learn it. I've got a sneaking suspicion that things like map algebra and network flow solvers are good candidates, but just haven't seen any case studies. Apr 23, 2012 at 22:21
  • 1
    "Map algebra" (from the 1980's) is functional programming.
    – whuber
    May 11, 2013 at 14:56
  • @whuber As I understand functional programming, it allows what we would normally think of as formulae, to be treated as data. Spreadsheets, for example, do this. I don't see a way to assign a function to a raster cell. It seems like this could be used to more rationally create something like a zoning map. Each zoning category could have a different suitability function. With units like property tax revenue. The inputs might include surrounding zoning. Zoning a parcel as residential might not yield as much tax revenue when it's near property zoned industrial. May 13, 2013 at 14:39
  • 1
    I believe you are thinking of something different, more akin to "computing on functions." According to [Wikipedia], functional programming is "a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data." Map algebra, almost all of which consists of pure functions, is a straightforward (but limited) example of this. The alternative of, say, looping over cells in Python is the opposite of functional programming. Strong FP paradigms exist now in R and Mathematica, which provide many GIS-related examples.
    – whuber
    May 13, 2013 at 14:45

3 Answers 3


The single biggest reason why functional programming has come back into vogue lately is concurrency. Being able to do processing in parallel for performance reasons is becoming massively important in computing overall and GIS is no exception. Functional programming has some serious benefits in the context of creating parallel systems because of how much it emphasizes immutability and recursion. Because of these properties most functional languages tend to simply sidestep issues like locking that make parallel programming in imperative languages a massive headache.

That being said, I think the GIS field has a long way to go before you will really be able to take advantage of a lot of what functional programming has to offer. Existing technologies and libraries are simply too fixated on Object Orientation and a generally imperative approach. Sadly, just because you can use ArcObjects from F# doesn't necessarily mean the underlying libraries will actually play nice with a functional style of programming.


Not strictly programming, but ArcToolbox follows a more functional design paradigm.

  • Most tools are designed to accept a set of inputs, run a function, and return the outputs without the influence of external state.
  • Most tools do not edit existing layers, but create new ones (immutability).
  • Many tools are similar in operation to a map function. They operate on sets of objects (feature set) rather than use iteration to process lower level objects (geometry).
  • Basic tools such as union, intersect, and dissolve can solve numerous problems that would be difficult to express in a declarative language such as SQL.

The functional approach of ArcToolbox lets us do spatial analysis without needing to write code. The user can work with a simple set of elements such as layers, and not worry about iteration, maintaining state, or complicated side effects.


I am new to functional programming myself so these are just a few thoughts.

There's an interesting example of a Ray Tracer in F# that illustrates some of the strengths of functional programming, namely higher-order functions, recursion, parallelism, and pattern matching. Extending some of those concepts it would seem that raster math is one key area in GIS that functional programming might be particularly suited for.

enter image description here

edit: Here's another example from the same site: Rule 30 Cellular Automata

Another thought is that you don't have to write your entire program in F#. You can have the main program written in C# and create projects/assemblies in F# that solve specific functional programming problems. I've read you can also use ILMerge to merge C# and F# into one executable/assembly.

Lastly, there are a lot of functional programming things you can do in C# with LINQ, through its use of lambda expressions, higher order functions (Select, Where, etc), sequence pattern matching, etc.

  • Thanks for the link to the ray tracer. Took liberty of adding image to your answer. May 12, 2013 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.