eg: code like this in ruby can explain itself very well!
display_error if not valid_input
Now I do understand that comments cannot be replaced entirely and sometimes it is necessary to add notes to understand the code thus I prefer using comments sparingly and avoid long headers on top of each file. Those headers with author name, dates and other information is unnecessary if right tools are used to maintain your project.
display_error unless valid_input
right? display_error if invalid_inputIt's a big world out here, there's room for Spock and for Kirk.
OTOH, you made a much more interesting statement than simply saying you didn't like "unless," you took things into a discussion about programming languages resembling vs. not resembling English.
Ruby has a bunch of lispy things that have nothing to do with English, but it also has a bunch of Perl-inspired things that have a lot to do with expressing logical ideas in English-y "prose."
If you can reconcile those two things, then yeah, you'll like all of Ruby. If not, you'll probably find a subset that pleases you. So sure, I can see that you might like the Ruby you use.
My point was that I think an explicit not is clearer than unless in cases sufficiently complex as to require stopping to think about it. If you're trying to keep track of multiple negations, then having one be in a different form than all the rest does not help. (And meanwhile, there is nothing wrong with a habit of always using if).
In total, yes, but that does not mean that there are no things that work in English that also happen to work in code.
Furthermore, it is difficult to generalize about this: some programming languages are entirely unlike English and work very well, others attempt to be like English and are terrible, while others attempt to be like English in some ways and work.
And further to that, some parts of some programs attempt to be like English and work well, while other parts of programs work well when nothing like English.
Now while I understand bang, andand, and oror, they are a terrible legacy of our C++ days. Bang is especially unforgiveable. If we must have a prefix operator, what is wrong with ~, the actual standard symbol for negation?
;-)
p.s. This thread may seem to be a digression, but it seems quite pertinent to an article that talks about writing code for readability.
Hunh, that hadn't occurred to me! That's a really interesting conjecture, touching on design trade-offs in neat ways. Thanks!
Also I think in general hackers should learn to read code. To reverse engineer. To understand what is going on without comments. Then when you do have some comments, it's a bonus (Or just even more confusing and contradictory).
There are differing degrees to which this is true. Different languages had different design motivations. Smalltalk was specifically designed to be readable by humans. By grade school aged humans, actually! In the Smalltalk community, most regard comments as a "Code Smell."
This is true because code is designed partly for computers while comments can be written entirely for humans.
This is important because comments only have to be written once and maintained occasionally while code without comments has to be reinterpreted every time it is read.