Anil Philip wrote:Isn't that (and streams in general) just a new-fangled way to write a program horizontally, sideways... instead of vertically in the old-fashioned way?
No. Declarative programming has benefits that go beyond "preference of coding style".
I'm not saying it is better than imperative programming in every case, and I'm also not saying that there aren't cases where imperative programming is better.
I was simply giving an example of one of many ways you can fill an array with three copies of a
string.
I am sure I can write it with fewer steps and less IQ, the old-fashioned way - vertically down.
Great. Do it the way you want.
The only remark I have is that declarative programming doesn't necessarily take "more IQ". It's just a different perspective. If you can't appreciate it, you're probably just not accustomed to it.
Oh, maybe a second remark. You might be surprised to learn that not only is declarative programming not "new-fangled", imperative programming isn't the "old-fashioned way" either. But it may appear that way if one mostly uses languages like C and
Java.