Ben Allfree :: Painless Programming

Guaranteed results for iPhone, Rails, PHP, .NET, Flash, and more

Functional programming languages

May 20th, 2008 · No Comments

Functional programming languages have a templating feature, called a macro, that allows you to write code that writes code.

Writing code that writes code is an interesting idea, and is one of the cornerstones of Ruby on Rails. Rails promises to write code that works as long as you promise to use database and file naming conventions that it can recognize. In this way, Rails writes a lot of code for you, at run time. Rails is code that writes code.

It is different than code generation. Code generation is done at design time. Dynamic code generation might be a better term. The code is written at run-time, on the fly, by the underlying framework like Rails.

This does lead to some interesting abstractions. You have the ability to reorganize not only the code that is executed, but also to extract common execution patterns into a single process that creates similar execution patterns. Dynamic code generation requires a level of indirect thinking that feels strange at first, then beings to feel more “right” than anything ever before. Your program organization begins to take on the shape of the problem itself rather than just the shape of the problem’s intermediate steps.

It’s a difficult concept to explain effectively without starting with much more of a background than I have given here, but it’s important to be aware that a lot of the productivity and popular research going on today has to do with dynamic code generation and thus functional languages.

At this shop, I use both traditional languages and functional languages. One of the projects I’m involved with right now is to create a new functional language.

Tags: , , ,

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment