11
Jan

How Lisp changed my style

   Posted by: Swizec   in Inspiration

IBM 402 Accounting Machine plug-board wiring. ...
Image via Wikipedia

This is the first post in the series of How <x> changed my style where I shall talk about tools and events that had a significant impact on my style of doing things. If you happen to like this idea, I would be very happy if you could help it spread like wildfire, because it’s a form of pay-it-forward where we say Thanks for cool stuff.

Some months ago, fuck has it been two? three? four?,  I attended a series of lectures on Lisp and functional programming and some other useful thingies by Simon Belak. At first it all felt like just another useful tool under my belt. Cool, Lisp, yeah, so what do I do with this? Meh, it’s cool, knowing this can’t do any more harm than a parenthesis thrown at a boomerangual trajectory smashing the windscreen of our hapless programmer.

However it did do damage, dear god it did so much damage! It fucked with my mind man, it fucked with everything. Nothing has been the same since!

No not really, but lately I have started noticing some pretty remarkable changes in the way I write code and more importantly, the way I think about code. Suddenly everything is a function is a function is a function! It’s quite remarkable really, sure I’ll often still code the very obvious object as an object, but I’m no longer forcing object oriented programming where it doesn’t belong.

And then there are even more radical examples of my brain changing, for the better I believe. Let’s take a simple comparison of writing a function that calculates the average of a list of numbers. In the old days I’d write it like so:

avg = 0
for key in self.tags:
	avg += self.tags[key]
avg /= len(self.tags)

These days, and it was fucking surprising when I noticed myself doing this, the same function gets written with a much bigger lisp:

avg = reduce(lambda a,b: a+b, tags.itervalues())/len(tags)

I really couldn’t go so far as to say whether this change in style and thinking is good or bad, but it certainly is interesting to just sit back and watch yourself from a distance as you morph and change before your very eyes.

So what’s changed your style lately?

Reblog this post [with Zemanta]
Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • StumbleUpon
  • TwitThis
  • DZone

Tags: , , , , ,

If you liked this post you should follow me on Twitter,
or see the music I like on last.fm,
or perhaps leave a comment, I like comments,
or go do your job because I know you're slacking,
or go write a blog of your own,
or tweet about something interesting,
or go out and have some fresh air,
or find a girlfriend,
or a boyfriend,
or a manbearpig,
or for fuck's sake stop reading this already,
no?
This entry was posted on Monday, January 11th, 2010 at 09:23 and is filed under Inspiration. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

5 comments so far

 1 

I wouldn’t say a specific language influenced me personally, but rather specific language features and concepts; being language-agnostic has its merits, and for me, lambda expressions and first-class objects were the defining moment.

January 11th, 2010 at 09:37
 2 

Well I’ve always been language-agnostic to an extent, but this is the first time in my life I’m becoming paradigm-agnostic as well and it’s a big big difference.

January 11th, 2010 at 14:03
 3 

too bad python (from your examples) is one of the poorest dynamic languages these days where you can experiment with your new learned FP-ness.

January 12th, 2010 at 10:48
sb
 4 

import operator

reduce(operator.add, tags.itervalues())/len(tags)

I prefer to omit lambda where possible (especially in Python where naming that construct lambda is cruel joke).

January 15th, 2010 at 16:54
Simon
 5 

The only language that needs to force me into any kind of perversions is asm :) But few months ago i discovered groovy (obviously, because I am a java fan :) ) and it totally rocked my boat. Now I’m looking at scala. It comes as no surprise, taht scala can be at times even faster than java.

January 25th, 2010 at 16:49

Leave a reply

Name (*)
Mail (will not be published) (*)
URI
Comment