Re:Dr. Software: An unfinished journey starting from dirty c...
by tabtab on Monday June 28, 2021 @04:37PM
(#27667737)
// procedural style
func foo01(a) {
b = x(a);
c = y(b);
r = z(b,c);
return r;
}
// functional style
func foo02(a) {
return z(x(a), y(x(a)));
}
With foo01, one can readily study the value of "b", "c", and "r" in a debugger and/or a Write() statement. With foo02 it's harder to do the equivalent. A good debugger will let you explore the output of a given function call in foo02, but you still have to rework the code to put those into a Write() statement. A direct debugger is sometimes not sufficient, especially in big loops.It's also easier to read the first style. It's more like a bulleted list:
- Step 1
- Step 2
- Step 3
The functional style is often an awkward horizontal string of chained steps. Sure, the formatting can be adjusted, but it takes more effort, training, and/or discipline to format functional code to make it legible to ordinary code maintainers. Procedural just handles riff-raff better; functional requires ideal conditions/staff.PS, do I really deserve a -4 score above?
Re:Dr. Software: An unfinished journey starting from dirty c...
by divs1210 on Wednesday June 30, 2021 @11:29AM
(#27689728)
Both are functional styles.
(defn foo01 [a]
(let [b (x a)
c (y b)
r (z b c)]
r))
and (defn foo02 [a]
(z (x a)
(y (x a))))
are both valid.I prefer the first one where I can see the intermediate steps clearly.
https://docs.cider.mx/cider/debugging/debugger.html