The earliest code that I wrote that could be considered "functional" was written in perl, and glued together all the billing and provisioning services at a now-dead ISP and phone company that I helped build in the mid-90s. At the time though, map was just a loop to me that could also be used to return a new hash or array. I still didn't get functional programming.



Later on I wrote a javascript compiler in javascript that compiled javascript to javascript. I wanted a way to run long-running computations in the browser and work around the "this page is taking too long" notifications you get when you run big javascript loops in such a page. Transforming the javascript into continuation passing style and using tricks to manually trampoline it to work around the lack of tail-call optimization in javascript introduced me to a few more functional programming concepts, mostly out of the scheme world, and to Appel's Modern Compiler Implementation in ML. I still didn't get functional programming. e.g. My version of CPS used all sorts of evil tricks to try to reduce the number of stack frames it used for the imperative language I was compiling, and I was still generally okay with that.



Meanwhile, Google released the Google Web Toolkit and, despite its flaws, the basic idea was better than what I'd built. I was compiling an untyped language to an untyped language. They could get IDE support. I sold off my project to a company that was building javascript debuggers and looked around for something else to do.



At the time, there was work on a new Javascript standard being done. And Dave Herman was trying to add a ton of features to the language. Some of those features were inspired by functional languages. Algebraic data types, lambdas, etc. He was building a reference implementation in Standard ML, and this seemed like a big push with Mozilla behind it, so this was a very serious thing by serious people.



So I decided to transfer all my javascript expertise to try to write a new javascript engine that could run server side -- node.js didn't yet exist. The new javascript had (optional) types, so that would fix some of my infrastructure and tooling problems. But it also had a lot of fancy type system features. The only real language I could think of that felt like it had the mixture of mixin traits and other classes that they were bandying about at the time was... perl.The working implementation of perl 6 at the time was called pugs and was written in this other programming language Haskell. So I decided to write my new compiler in Haskell, whatever that was, and whenever I didn't know how to implement something I'd just copy whatever pugs was doing, and I'd learn a new language in the process. It is all just syntax right?



The proposed javascript standard in question was scrapped because Microsoft said no and Brendan Eich and company folded. Ecmascript "Harmony" was an attempt to pick up the pieces and make minor incremental progress instead.



Fourteen years later I'm still learning that new language.



I'll get around to that javascript compiler some day.