Monday, January 16, 2006

teaching abilities to abstract

Today we agreed that I will tell our students something about functional programming language based on examples in Scheme. In my opinion it is important to teach people concepts like functional programming languages. Nowadays most universities (ours included) tend to teach only main stream languages like Java. People responsible for these decisions often argue that programming languages like Java are the languages that are actually used in industry where functional programming languages like Haskell, ML, or Lisp are used by academics only and are thus not relevant. Although the empiric observation about language usage is mostly true this seems to be a really strange argument.

My first argument is that it is not the primary job of the university to teach a programming language but to teach concepts. And in my opinion it is useful for a computer scientist to learn ability of functional programming abstraction because they learn to look at complex problems from a higher level of abstraction and thus solve problems with higher effectivity. Even in a project that does not make any use of a functional programming language at all you can make use of this ability to abstract to write less braindead code.

My second reason why this is a strange argument is that one reason why functional programming languages are used very seldom might be that almost nobody is capable to really use them --- I mean _use_ them in the sense of "think in them", not just hack some stupid Hello-World-program.

Obviously I will not manage to teach our students to become full-fledged functional programming language hackers within one lecture of 90 minutes but I hope at least some of them will find some interest to look themselves a bit deeper into that topic. I hope that this knowledge will not get lost within the next years because from my experience most people capable of imperative programming often have problems to understand a functional style. On the other hand side people with a deep knowledge in functional programming tend to write cleaner code even when they use imperative languages.

All time when I read Java code like "if (x == 42) return true; else return false;" I feel the immediate need to talk to the author of this code...

1 comment:

sinewalker said...

I agree with your sentiment. I wonder though if the percieved "difficulty" of functional languages could be overcome a different way?

At my university, FLs were taught as part of a final year course, or even post-graduate (along with Logical/Symbolic languages like prolog and J). After three or more years steeped in the procedural style of C/C++ and Pascal, or the OOP languages (we learned C++, as Java hadn't been invented -- I could have a whole 'nother discussion of the follies of that teaching decision!), it became difficult to think in the functional style. In hind-sight, the functional style is a much more natural way to solve problems, but I had to un-learn this procedural thinking that I'd picked up while learning Pascal and C.

I do recall an early foray into LOGO when I was in primary school actually helped me during my honours studies, once I saw that LOGO's "first" and "butfirst" are realy just LISP car/cdr with friendly keywords.

If I'd been tought scheme/ML/LISP, or even Smalltalk/Squeek first instead of as an afterthought, then I think I would have "got it" sooner.

Maybe introductory programming should introduce the functional languages, or concentrate on the lisp-like parts of Java (reflection), and Python more, rather than approaching FLs as a "specialist subject"? It would have major benefits for computer science, I think...