Thoughts on Perl and Emacs, technology and writing

Learning to program functionally

A major problem I’ve found with learning scheme in isolation is that it is quite easy to pick up the syntax and then start programming in with a heavy C++ accent. Although this demonstrates the flexibility of scheme, it is not what I’m really after. The question is, how to learn to write in a good style. I can think of a number of possibilities:

Keep writing programs in scheme and hope my style will improve

Read books that specifically teach good scheme style

Read real world code written in scheme

I’ve been inspired to work through some of the exercises in HTDP from various posts I’ve read on Lambda the Ultimate. So far, the book advises a similar approach to designing programs as I have seen before: decide on your data structures before writing the code and define the data structures using (define-struct …). I’ve found it a useful exercise to write functions that convert the data structures into lists that could be evaluated to re-create the original data. Here is an example, more or less from chapter 17.

Share this:

Like this:

Related

One Response

I think a good way to improve programming style is to find some good advices, writing them say, on the wall in front of your computer, and looking at them after each prog writing to be sure you follow the rules😉