Not sure how I feel about Node.js after this experiment. Trying to wrap my mind around the fact that any function that performs I/O cannot return a value, but must instead take a callback that would operate on that value. Which means that any function that MIGHT one day perform I/O (or call something that does) cannot return a value, but must take a callback instead. In my mind, this makes it unsafe EVER to write a function that merely returns a value, unless what it is doing is pure calculation (in which case you could probably inline it).
This toy script takes a directory as an argument, finds all the files in that directory (without recursing), and prints their contents.
The Python version seems pretty straight-forward to me, easy to read, easy to write.
The Node version was harder to write, but only because of my inexperience I think. However, my first try had a subtle bug that caused it to produce the wrong output (commented).
What kills me is how path.exists()
must take a callback, because it has