3 ms·
“Every line of code, whether it be PHP or Clojure has roughly the same potential for a bug. But 20 lines of Clojure may sometimes translate into 1000 lines of P
by alexgartrell 17y ago
“Every line of code, whether it be PHP or Clojure has roughly the same potential for a bug. But 20 lines of Clojure may sometimes translate into 1000 lines of PHP.”
Not PHP, but C:
int x = 6;
I'm pretty confident about that one. A lot of those 1k lines of code will be "stating the obvious". I don't think it's fair to imply that the probability of a fault in a line of C code is anywhere near the probability of a fault in a line of Clojure.
I doooo like Clojure though :)
- swombat 17y agoI can point to a Clojure line that has similar characteristics (and I don't even know Clojure): (+ 1 1) Done. Clojure's awesome, right? No errors. That rocks, huh? No. Even that line has the potential for errors: 1. You could have a typo (int z = 6; int x = 7;) 2. You could have misunderstood the requirements (it should actually be float x = 6.5) The only possibility you excluded with this trivially simple line is: 3. An error in how you used your own tools (easier to imagine if the line involved pointers). Part of the difficulty of debugging is, you don't know which lines have errors in them. If you have 1000 lines, you potentially have to review them all to find the bug. If those lines are poorly compartmentalised, so that you can't heuristically find your way to the likely location of the bug, that is doubly the case. Conversely, if you only have 20 lines of code, then you only have 20 lines to read before you've definitely seen the line with the bug (whether you recognise it is another matter, which has more to do with experience, capability, and the clarity of the code). Intention-revealing code does tend to be much, much clearer, though. (although I'll grant you it's possible to obfuscate code with malevolent intent).