TFP & FuncJS

[ Tags | ]

Today is day 3 (of 3) of Trends in Functional Programming, an annual international symposium on functional programming, with specific academic focuses on, as far as I can tell,

  • high level mathematical proofs using functional languages, mainly ACL2
  • hardware level correctness proofs, also mainly ACL2
  • cool applications of FP, mainly Haskell, the current "cool" functional language and
  • FP evangelism and education (in other domains, not to the participants, often discussing Programming I classes).

This year it happened to be in Oklahoma, hosted by OU, so OU CS students got in for free. Most of what's being discussed goes over my head, but I'm fairly familiar with FP in general and really like it. Seeing these talks and having just finished the CS Capstone at OU (which uses ACL2 exclusively) has inspired me to finally follow up on a personal project I've been wanting to invest some time in, which is writing a purely functional library that facilitates simple functional programming in Javascript.

Javascript already has several functional type features: first order functions, a decent anonymous function notation, closures, etc. Still, it has a ways to go, and some frustrating deficiencies (no (fully supported) const declarer, no nice if/else return syntax -- have to use ternary operator, etc). Still, it's coming along pretty nicely. Here's my merge sort implementation:

Read more )

I've uploaded a first cut of the library to Google Code. It's nowhere near completion yet, in my opinion, but I wanted to get it under source control now so I can have more flexibility to play around with it. (The code above, of course, depends on the library.)

I'm pretty pleased with it so far. I ran the above merge sort on a pre-generated list of 10,000 random floats, and it completed in 33ms of CPU time (according to Chrome's profiler), as compared with an imperative implementation that I wrote (that uses an array, of course) which took 12ms. Not too bad, I think.

More to come :-)

790 views and 0 responses