Blog

Portfolio CV

Functional programming: F# ray tracer

Published:
2008-10-30 23:45:53
Posted from:
Home
Tags:
F#, Functional programming, Ray tracing,

I'm subscribed to a lot of blogs. I don't really read a lot of them, I mostly scroll through them and look for interesting news or subjects. Sometimes I find particularly nice posts, like a couple of weeks ago; Christer Ericsson blogged about functional programming. I've been curious about learning a functional language since then.

I try to do some recreational programming every other weekend when Jennie is working, to develop my skills and to recapture the fun. So when I was in need of a project for last weekend I had two alternatives; to port Moonlight to the iPhone, or; do something with a functional language. The first alternative (that of course was an idea born out of alcohol) seamed a bit to ambitious. So I settled for the second, and decided that "do something" meant "write a ray tracer".

Functional programming is a different beast from "ordinary" (imperative, procedural, object oriented) programming:

I decided to go with F# for my ray tracer, a functional language created by Microsoft and released as a technology preview. It is compiled into a .NET application, which means that you can reference and use all the classes in the .NET Framework. This of course isn't of much use to a ray tracer, the only classes I used were the System.Drawing.Bitmap and System.Drawing.Color classes to save the rendered image as a png.

Results so far: F# ray tracer output

Comments

No comments so far. You leave the first:

Name
Email
Website
Text

© 2008 Markus Johnsson