Stream
https://nodejs.dev/learn/nodejs-streams (opens in a new tab)
General
An abstract phrase for something with a source and destination.
Sequence of elements made available over time. https://en.wikipedia.org/wiki/Stream_(computing) (opens in a new tab)
E.g. read/write files, network communication, or any kind of end to end information exchange.
NodeJS
https://nodejs.dev/learn/nodejs-streams (opens in a new tab)
Why??
- Memory efficiency: load data piece by piece instead of all at once into memory
- Time efficiency: load and process data in the meantime
Java
Others
- Stream provides more declarative or expressiveness
- Stream has close affinity to functions
- Stream encourages immutability etc