I am looking to finish with a bang on my bachelor project and I want to finish it with a functional programming project. We didn't study it in school but we are encouraged to try to learn new things ourselves, and I thought learning a new paradigm not only a new language would be a great exercise for me, and probably something interesting for the teachers to see too.

The problem is I want to start a bit ahead of time on my project to take advantage of the summer holiday and get a better understanding on functional programming, and get familiar with one language.

What would you say would be a good practice project that is a bit challenging, but also lets me learn the language, paradigm etc. And then what would you think would be a good project (a more advanced one) for my bachelor project?

Suggestions for the best language to start with when going into functional programming would be appreciated too.

7 Answers
7

It's generally easier if you go for something relatively mathematical or logical - functional programming languages are generally well suited for applications that represent some form of transformation from a given input to an output.

Some ideas, in rough order of difficulty:

Genetic algorithms - write a program that evolves solutions to a particular task where the solutions are represented in a simple DSL. I've had fun before building little bots that hunt for food in a 2D grid and evolve different kinds of strategies

Parsing combinators - build a parser combinator library that enables you to construct a parser for an arbitrary language using higher order functions.

If you really want a challenge, you can try writing a computer game... be aware that this is a tricky task since games have a huge amount of mutable state which can be tricky to manage in a functional programming style. Expect to learn more than you ever wanted to know about monads etc.....

I'd recommend Clojure as a pragmatic functional language. I've been using it for about 18 months now and I'm extremely happy with the choice. Main reasons are:

It's a Lisp - so because of the "code is data" philosophy it is fantastic for macro-based metaprogramming (programs that write programs, genetic algorithms etc.)

Pragmatic functional programming - Clojure style is very functional (lots of emphasis on higher order functions, lazy sequences etc.) but it isn't totally pure like Haskell. There are lots of nice tools to handle mtable state and side efects

Dynamic - Clojure is a dynamic language by default. I find this a big boost for productivity. However, you can optionally add static type hints later if you want the performance benefits of static typing.

Fully compiled - Clojure code is always complied (even if you do an "eval") so you get pretty decent performance - certainly better than most dynamic languages I've used.

You get access to all the libraries and tools in the JVM ecosystem for free. So unlike academic languages that have very limited libraries available, you can access anything in the Java universe pretty easily

You can try out the basics very easily with:

The 4Clojure online problem set - the early problems serve as a good "learning by doing" introduction to the Clojure language

@mikera: For working with the JVM, have you tried ABCL? I tried it out and made only a small example but I have almost no experience with it. (I also have a Clojure book in my todo list, but this is another story, I am curious if you have any experience working with ABCL and Java).
– GiorgioMay 11 '13 at 23:03

@Giorgio: ABCL seems like it's a decent implementation of Common Lisp on the JVM. OTOH Clojure has the advantages of being designed for the JVM, incorporating a lot more "modern" innovations, and having more community momentum. I think it really comes down to whether you care about maintaining Common Lisp backwards compatibility or not.
– mikeraMay 12 '13 at 1:56

If you want to get fancy, and use a more modern functional language that targets the JVM, take a look at Clojure. There's even an adapted version of SICP specifically for Clojure.

Going over the SICP text, you'll get an idea of why functional programming is so well-suited to certain types of tasks, and the exercises might inspire a full-fledged project. If you choose to go the Clojure route, and want to examine some existing projects, there are some good links here.

If you find finance somewhat interesting doing some quant stuff with functional programming is a good match since it's very algorithmic. I'm talking portfolio theory and things like sharpe and sortino ratios etc. Make an app that analyses a fund's returns and gives different statistics, diagrams etc.

I'd recommend F# only because I think it's an easy functional language to get started in, has good tools and good framework backing it. Other alternatives are lisp and clojure but they're a bit harder to learn.

At high level, it is indeed true that you can do a lot of stuff in a functional manner. People have used functional languages to describe exotic option payoffs, for example. But as you go down to the ground level stuff, like calculating PCA, solving nonlinear equations, etc., the algorithms become increasingly iterative and you're better off coding them in the old-style way.
– quant_devMay 27 '11 at 11:40

1

I wouldn't say that, in my experience quantiative analysis is all about running algorithms over series. I've implemented quant stuff in C# and it was very much aligned with LINQ, at least for the portfolio theory kind of stuff
– HomdeMay 27 '11 at 12:19

What about the implementations of algorithms themselves?
– quant_devMay 27 '11 at 12:29

I see no problem in most instances, do you? Take calculating a sharpe ratio, first you calculate an annualized return from a returns series, then you use that value with a risk free rate and volatility: (annualizedReturn - riskFreeRate) / volatility. Nothing a functional language couldn't handle
– HomdeMay 27 '11 at 12:59

For a head-start, you could try to implement a little blackjack game in F#. This is a homework project assigned during this short video tutorial. Solution is also provided on the net (and in one of the videos).

I was thinking of F# honestly mainly because in Denmark Microsoft everything is popular, but the more I read different opinions, I am doubting this decision. I want a language that will help me learn the paradigm mainly, and after I am sure it's not hard to learn another one if I need or want to.
– MemeMay 27 '11 at 11:47

Strongly depends on where you are and what you do. For us Microsoft programming technologies are useless as they don't support our main platform. But I digress: if you want to use F#, great, but then open a new F# specific question.
– user1249May 28 '11 at 6:32

I don't want to use that. I haven't taken a decision yet. The question about the language to use was a secondary one anyway.
– MemeMay 28 '11 at 8:55

In that case, find a project and then ask for recommendations how to solve it. E.g. Prolog is great for decision tree searching. Haskell is great for pattern matching. Lisp is great for constructing and manipulating Lisp programs at runtime depending on your data.
– user1249May 28 '11 at 9:04

For example, in the Frege programming language project, there is much work to do. For instance, you could care about porting base Haskell libraries. This would make you sort of a Haskell expert while you work on it.