Hacker News new | past | comments | ask | show | jobs | submit login

By having the code in a differently ordered way, one can look at the compiled version to see how it flows; we get two views of the code instead of just one.

For example, we could use literate program flow to sketch the flow:

    if ( i<0 ) {
      "strip sign and reciprocate"
    }  else {
      "shift to make room for negatives"
    } 
With function ordering, it would look similar but with dealWithNegative() kind of stuff and some sort of return value/scoping issue to think about. And that is all one gets.

But with literate program, you can actually look at the compiled code and get a different view; very helpful with scoping issues.

    if ( i<0 ) {
      i = 1/math.abs(i);
    }  else {
      i = i+1
    } 
Admittedly, the compiled view should not be needed too often, but it is useful on occasion.

One also has the ability to quickly strip out long sections into their own snippets without having to worry about scope/closures/pass-in/return values/where to put the function.




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

Search: