Writing all the code to achieve the desired goal yourself in the imperative approach and using, for example, the pre-made sum and groupingBy functions in the declarative approach is not a fair comparison. You should either implement those functions in the declarative example or import some magically previously defined function sum() in the imperative approach, which would make it a one liner.
If you had a magically previously defined function "sum" how would justify it not being called declarative?
Declarative literally means "in the fashion of declaring." Here that would mean declaring functions. In software it has come to mean "programming without explicit control flow." The second you add the "sum" function call you hide the control flow making it declarative.
Any way, what reasonable language doesn't have magically previously defined "sum" library functions? I mean, its like the simplest thing you could have in a library.
25
u/yoomiii Aug 05 '19
Writing all the code to achieve the desired goal yourself in the imperative approach and using, for example, the pre-made
sumandgroupingByfunctions in the declarative approach is not a fair comparison. You should either implement those functions in the declarative example or import some magically previously defined function sum() in the imperative approach, which would make it a one liner.