1. Mar 20th, 2009

    Just find me the lock I need to crack

    Cliff Click Jr on hardware transactional memory:

    Really what the customers want to know is: “which locks do I need to ‘crack’ to get performance?”. Once they have that answer they are ready and willing to write fine-grained locking code. And nearly always the fine-grained locking is a very simple step up in complexity over what they had before. It’s not the case that they need to write some uber-hard-to-maintain code to get performance. Instead it’s the case that they have no clue which locks need to be “cracked” to get a speedup, and once that’s pointed out the fixes are generally straightforward.

    Interesting thing about functional programming, actors monads is that they all come from the same place, promising to unlock large scale concurrency riches, in return for a little bit of devotion on our daily programming rituals.

    I recently switched from Prototype.js to jQuery. One thing I appreciate about Prototype.js is that extent it goes to make functional programming easy with JavaScript.

    jQuery doesn’t do functional programming. What most jQuery functions do is return the same object, while modifying it. It’s one big chain of side effects:

    $('p').text('Hai').addClass('welcome').show();

    It’s precisely this chaining style that makes jQuery so appealing to developers. It makes them happy, productive, creative. Out of that come a lot of plugins, sample code, and interesting UI techniques. A few that I wanted to use, which became the “killer app” that caused me to switch.

    Functional programming may be the ultimate answer, but method chaining is the productivity lock people wanted to crack.

    1. Mar 20th, 2009

      Dr Nic

      It is interesting that it all the programming models we learn at university, I don’t recollect ever once someone saying “X model is best because it makes programming a whole lot easier in situations A,B,C” Who would have thought method chaining was so powerful and fun to use that you just had to have it for DOM manipulation?

    2. Mar 21st, 2009

      Damien Katz

      Functional programming doesn’t make programming easier, it makes *reliable* programming easier.

      In the example you gave, if one of the steps causes an error, you’ll wind up in a half-modified state. Maybe it’s not a big deal, or maybe it locks up the UI. It’s hard to tell.

      With functional programming, the state change doesn’t take effect until the new state is completely ready. If there is an error, the UI still has it’s previous state.

    3. Mar 21st, 2009

      kball

      The interesting thing to me is that while jQuery does not do functional programming, what makes it so effective are actually its use of concepts from functional programming. The jQuery object is a list, and basically all of the methods are maps, filters (special case reductions), and things built on top of those two core concepts.

      The biggest difference to me is what Damien said, that in functional programming the state change doesn’t take effect until the new state is completely ready. Modifying jQuery to do this would essentially just mean lazily evaluating the transformations and applying them all at once at the end of the chain of methods.

      And it would be nice if jQuery did have a general case reduction as well as the special case of filters, but I’m not sure if thats valuable for DOM manipulation, which seems to be the primary target they are after.

    Your comment, here ⇓