Re:Please do not attempt to simplify this code
by bitexploder on Friday December 28, 2018 @03:29AM
(#18775529)
I don’t think this changes the inherent complexity of the code right? The basic logic of what is being done is still the same. De-indenting code but still having the same complexity, some of which is now abstracted by the language is still complexity. Maybe it somewhat helps the humans reading the code? But don’t you still have to reason about the basic state changes of the system the same way?
[ Parent
| on HN ]
Re:Please do not attempt to simplify this code
by dnautics on Friday December 28, 2018 @04:05AM
(#18775682)
the code itself has the same complexity, but you are pushing the workload to the compiler, not to the human. Given the two options I typically prefer the compiler.
Re:Please do not attempt to simplify this code
by AstralStorm on Friday December 28, 2018 @04:30AM
(#18775777)
Compilers and libraries are written by humans and are probably the most fallible things ever, optimization wise. I'm not talking 1% here. I'd love to see an opposing compiler with an automated proof that it does what it claims.
Well, unless your computer can read and parse high order proofs over code. Not even Haskell can do that. (It can barely parse F types much less optimize them.) The closest I have come to that feature is Isabelle's simplify and even that is limited.
GCC and Clang can do basic bounds proofs at best and otherwise are tough buggy heuristic beasts. Just look at the trackers.
GHC has a slightly easier job but it's paid for in programming complexity. There are hoops in type system you have to jump to get performant code... and even then the code generated its at best meh quality. There is always some joker telling that it could be compiled for SIMD or multithreaded but that never materialized in usable form.
Re:Please do not attempt to simplify this code
by Touche on Friday December 28, 2018 @07:45AM
(#18776429)
Compilers can only tell if programs are internally consistent, they can't help ensure that they are correct. Compilers don't know about inputs. Compilers don't know if the branch you wrote goes in the correct direction for a given input.
Re:Please do not attempt to simplify this code
by mywittyname on Friday December 28, 2018 @11:45AM
(#18777806)
Well, the compiler can optimize away any superfluous branches which exist entirely to act as hints for the programmer.