Tuesday, February 15, 2011

first experiences with F#

I've looked at F# before and i liked the idea, but recently i started to actually write in it, and here's my experience with F# so far:

Debugging is quite different. While in C# / C++ i would put a breakpoint in the faulty code, here in F# i typically use the F# interactive window to call one function at a time. This is convenient because you can build up your program from the bottom up, one subroutine at a time.

Indentation is used for scope. While it helps make code a bit shorter, i have found this to be a total pain in the ass. The indentation-sensitive parser reports all sorts of undescriptive error messages. One space in, and you're doing a nested declaration, one space back and you're declaring a member outside class scope. This has so far caused me major grief. I hope i can get used to this eventually. Perhaps there is a tool out there which helps clarify which scope F# THINKS your function is in.

Programs are shorter because of:

  • Frequent use of inline functions and nice syntax sugar for closures.
  • Indentation instead of braces for scope
  • Operations on lists and tuples are built in parts of the language, ensuring very compact code when dealing with lists. Iteration, accumulation, and selection are very natural in F#.

Published with Blogger-droid v1.6.6

No comments:

Post a Comment