Functional Programming, Haskell Frustration and Change of Venue

First, I’m long overdue “explaining” functional programming. Then, I’m frustrated w/ Haskell GUI issues. Finally, my non-technical writing is moving to a different blog.

I became interested in functional programming, over a year and a half ago, because of an article in Dr. Dobb’s Journal, and the confluence of other factors.

This is a very readable introduction to functional programming, here is a comparison with imperative programming- specifically with respect to Haskell.

I describe functional programming in terms of these aspects:

  • everything is a function (“variables” don’t exist — symbols don’t change once set; recursive functions are encouraged and preferred)
  • because of the above, side-effects are eliminated — a function only takes input and produces output; it does not change global variables, or alter the state of execution, and, therefore, always produces the same result, whether called first, third or last in program order.  Also, if a function is called ten times, repeatedly, with the same input, the output is always the same.

In imperative programming (and not necessarily, but in what I call “normal” programming) a lot of the work gets done by side-effects.

A typical example might be a hospitalprogram — where setting the patient name would initialize a new admission record, presuming that this is the desired operation.  But there is nothing per se about setting a person’s name that implies a new record should be initialized.  So that operation would be a side-effect of the function “set patient name.”

  • Now, frequently, this is how things happen.  Most “normal” programs operate some sort of finite state machine — that is, the program should do something different, even when the same function is called, at different point in the execution timeline.  But this is precisely what makes debugging so difficult.
  • Also, because of the changes to global variables and state, “parallelizing” code to run in a multi-threaded or multi-processing environment is non-trivial — nay, is next to impossible.
  • And those last two points are part of the primary motivation for the current interest in functional programming: ease of debugging, and simplicity of parallelization for multi-processor and multi-core computers.

    I strongly urge anyone truly interested in functional programming to do more, better research than that, but I hope I spark an interest in some to do that…

    Haskell “libraries”

    The problem I’m having is that too many Haskell libraries seem to be Unix-centric. For instance, here is  a program using FileManip, but that requires the unix lib. from hackage, and you can guess my luck getting that running under Windows.  WxHaskell required wxWidgets, and specifically wxConfig, which didn’t build for Windows (although most of the rest did).  Gtk2Hs worked almost completely, but some Glade files were/are missing; and along the way, I found out that I have two cabal installs, or something screwy with my setup, so I might try something else, we’ll see…

    Blog Separation

    Finally, I’d like to note that my non-technical blogging has moved.  I may move some previous entries there later.  I once ran across a blog, the ideas of which were mixed — some software engineering principles were dead-on, then there were some more crackpot ideas, and I found it a little dis-heartening to try and keep the thoughts separate:

    yes, I agree with these things; no, I don’t agree with those.  I know it’s the same person, but one shouldn’t invalidate the other.

    I don’t think my personal beliefs, here, invalidate, my comp. sci. musings, but it might be a distraction to some.  My personal reflections, whether you agree or not, should not influence your reception of my technical thoughts.  And you shouldn’t have to filter through one to find the other (some people, if you can believe it, don’t care about my technical blogging, but only my “writing”).


    2 Responses to “Functional Programming, Haskell Frustration and Change of Venue”

    1. Ted Tower Says:

      Thanks for the brief intro to functional programming. Although not a software engineer, I do a lot of programming in my job, so the strengths of this are immediately attractive. I’m trying to apply some more discipline to function creation to keep them close to how you describe — it should give the same output every time. In truth, however, I’ll keep with my current languages and glean whatever I can from your investigation, hoping to be able to apply the principles in my own context.

      Thanks again!

    2. Latest on P != NP and Next Haskell Work « More than a Tweet Says:

      […] Latest on P != NP and Next Haskell Work By gparks At the end of this post, I’m going to lay out my plan for further work on Haskell… […]

    Leave a Reply

    Fill in your details below or click an icon to log in: Logo

    You are commenting using your account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s

    %d bloggers like this: