Hacker News new | past | comments | ask | show | jobs | submit login
Five Dollar Programming Words (codinghorror.com)
33 points by bdfh42 on March 20, 2009 | hide | past | favorite | 16 comments



Sciolist

One who knows many things superficially; a pretender to science; a smatterer


"A function is "idempotent" if the result of doing it twice (feeding the output of the first call into the second call) is exactly the same as the result of doing it once. (Or, in other words, every output of the function is idempotent under it.)"

Uh?? According to this definition this wouldn't be idempotent:

  (defun add-one (x)
    (+ x 1))

  CL-USER> (values (add-one 5)
           (add-one (add-one 5))
           (= (add-one 5) (add-one (add-one 5))))
  6
  7
  nil
edit: What the... Wikipedia seems to be agreeing with him. It seems I mixed up idempotence and referential transparency, I thought they were equivalent concepts. I'm confused...


The concepts of referential transparency and idempotence are close, but not quite equivalent.

'Idempotence' is the property that you can run something 1 or 100 times, and there is no difference in post-conditions. "x=1" is an idempotent operation. Idempotent operations can have side-effects.

'Referential transparency' means you can replace an expression with the value it returns, and it makes no difference in post-conditions. The expression "x=1", while idempotent, is not referentially transparent; the expression (in most languages) will return a value of 1, but you cannot replace "x=1" with "1" in your code and expect the same post-conditions. Referentially-transparent expressions cannot have side-effects.


His definition of idempotence is correct. As an example, a hash table with idempotent delete would work fine if I did this:

  (setf h (hash-new))
  (hash-insert h 'foo '(1 2 3 4))
  (hash-delete h 'foo)
  ;;; some time later
  (hash-delete h 'foo)
  
A non-idempotent implementation might complain that 'foo doesn't exist in the table.


I think Jeff conveys the wrong sense of idempotence. He has somehow extracted the purely mathematical sense, while the source he quotes goes on to explain the programming angle.


Yeah, I had never heard 'idempotence' used in a mathematical sense before. I just think of that as a function hitting a fixed point.


I think it's much more common to talk about idempotence in programming w.r.t. state and state transitions. With immutable data, this approaches the mathematical definition:

    (= (remove-el set 1) (remove-el (remove-el set 1) 1))
With network protocols, state machines, and mutable data, idempotence helps ensure consistent state without the fixed-point-ness.


A good example of an idempotent function is the absolute value function.

abs(-1) = abs(abs(-1) since both equal 1


I really do like Jeff Atwood, I think for the most part he has been beneficial to the community. But for the love of god, I wish he would stop making half of his post quotes from someone else's post. I don't mind that he gets an idea to write something based off of another person, but he could at least add something substantive to it.


I see him as a sort of Reader's Digest of programming. Not sure if that's good, mind you.


Reader's Digest of programming is the perfect description!


I think his biggest service to the community is taking great ideas from lesser well-known sources and publicizing them. I've found so many classic essays and posts because he wrote about them. He pointed me to where I can dig deeper.

Also his high page rank makes his articles extremely easy to find.


I really do like HN, I think for the most part it has been beneficial to the community. But for the love of god, I wish half of the comments on Coding Horror submissions here would stop being the same old ad hominem attacks on Jeff's writing style. At least the HN community could add something substantive to Jeff's arguments.


ad hominem

Is it? If he had said "this writing style is bad because Jeff uses it", perhaps.


Ah, my bad.


I'd like to add that Jeff didn't always write this way, most his content was his own in the earlier days.

I'm not uber pissed or anything, I understand that he has a new kid and a new business to tend to and therefore his writing time has surely diminished. The word best used to describe my feelings towards his posts as of late is probably "disappointed". I'd rather see fewer, but higher quality posts.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: