by hamstercat · 9y ago · 0 comments
This. x1000. I've found that a lot of disagreement about ways to implement a feature can be solved by keeping this in mind.
I dunno, the usual reactions I get are more in line with the comments on this Stack Overflow post: http://stackoverflow.com/questions/43377533/should-python-er...
For whatever reason, making the case that code that actually performs some useful computation should be closer to the exception rather than the rule tends to result in people completely losing their shit.
In general readability of code has more to do with something like this:
valid_filename = filename.ends_with? ".txt"
return File.open(filename) if valid_filename
Versus something like this: return File.open(fn) if fn.ends_with? ".txt"
The former uses a longer variable that clearly shows what it is and reduces the mental overhead of having to figure out why we're returning (because the file is valid, we're finished with this function as intended).Not this. x1.
Now if this were true, you would read these programs as you would literature. But you don't. Instead, you only use these programs as you would a tool and then complain when they don't do what you want them to do fast enough or reliably enough.
In literature, you have expectations but not certainty about the ending. Only with a bad tool do you expect anything but certainty about the ending. Indeed the hallmark of a good program is that you don't have to read it to know how it ends.
Another anti-parallel is that literature (literate programming) admires originality whereas good engineering admires plagiarism.
His purpose is altogether simpler. From his paper, the literate programmer focuses on "exposition". He or she "chooses the names of variables carefully and explains what each means", and "strives for a program that is comprehensible... using a mixture of formal and informal methods that reinforce each other."
Literate programming is not there to entertain you. It's there to be understood. Beware the programmer who disdains comprehension of their programs.
Programs must be written for people to read, and only incidentally for machines to execute.
Literate programming is not there to entertain you. It's there to be understood. Beware the programmer who disdains comprehension of their programs.
Programs are pieces of engineering. As such they are meant to be used. Beware the programmer who admires their programming too much. If they have elegantly solved a problem that will come out in their solution's use and not in its literate form.
1) which, since I was doing the code reviews, I wasn't allowed to write any production code, because who would review my code? :(
This means we need to read code, even our own code, to understand what it's doing. Code that is harder for us to read is harder to work on.
you seem to be making ancillary points while being deliberately obtuse about the central one.
Programs are meant to be used and only incidentally for people to read. Some programs, we'll call them closed source, can't even be read, not even by Richard Stallman.
BTW, SICP was a required text in 61A when I took it. Required but then like many bibles, never assigned and never read. A few years later, I tried to but couldn't and so I sold my copy on Amazon. Got $25 for it.
And regardless of the intention, code are read many, many more times than it is written, especially when you work in a company with multiple teams and that is spread out on multiple sites. And in my experience, badly written code causes bugs because the original intention is not clear.