Here’s my take on it (and one definition for “least surprise”)… i want
to be able to say exactly what i mean when programming, to be unambiguous.
This means to not only be objectively unambiguous, but subjectively
unambiguous. In terms of Ruby (or Perl) syntax, “unless” means the same
thing as “if not”. It is objectively unambiguous (and probably produces
identical code from the compiler). But in a subjective sense, “unless”
is clearer than “if not” in many situations. It implies that i expect
something to be false, rather than i expect it to be true.
All higher level programming languages are syntactic sugar. They exist
for the convenient understanding of human beings, not of computers. The
reducto ad absurdum position for language minimalists is to simply use
NAND for everything - after all, we can express all computer operations
with combinations of NAND gates. This is not to say that we should try to
solve every problem by adding new keywords, either (it’s been tried, and
called C++). To paraphrase an artist, expression is complete not when
there is nothing to add, but when there is nothing to be taken away. Is
Ruby more expressive because of “unless”, or less expressive? As long as
the meaning is both objectively and subjectively unambiguous, i’d say it’s
more expressive.
On a vaguely related note, i was working on a language for a while with a
friend of mine. My favorite contribution to the language was a keyword i
haven’t seen elsewhere… “forever”, to imply an infinite loop. So to
create an infinite loop, you would write
forever { … }
rather than
while(true) { … }
I have always found while(true) to be maddeningly indirect and
computer-geeky… surprising, in a bad way. The forever keyword makes
infinite loops explicit.
Needless to say, i approve of Ruby’s syntax.
William Djaja Tjokroaminata billtj@z.glue.umd.edu
09/10/02 09:54 AM
Please respond to ruby-talk
···
To: ruby-talk@ruby-lang.org (ruby-talk ML)
cc:
Subject: Re: Ruby aesthetics
Hi Dave,
Again, French and English have been very well established. I am not
proposing removing “unless” from Ruby, or using the “unless macro” in
C. But suppose we are designing a new language; we as intelligent human
beings, I think, should be able to answer the basic question, is it an
advantage or a drawback to have more varieties (like in Ruby) or bare
minimum (like in Python) in a programming language (which is by nature
different from a natural language)? I think this is significant, because,
in my opinion, Python gets its attractiveness from its minimalist
principle (“there is only one way to do it”), and also in my opinion,
there is no doubt that new programming language designers will emerge, and
they need to learn a lesson from history, just like Ruby learns a lot from
Perl, Smalltalk, Eiffel, etc. (I am not convinced, because of the Python
philosophy and experience, that the answer to this is simply “it does not
matter”.)
Regards,
Bill
Dave Thomas Dave@pragmaticprogrammer.com wrote:
There are phrases in French that are very useful, and yet which have
no direct English counterpart. Should we:
- Translate them word for word, and insert them in to English?
- Stop the French using them?
- Celebrate the fact that different languages are different and get
on with the important business, which is using each effectively?
If you don’t like ‘unless’, then by all means don’t use it. If others
do, then I see no need to stop them.
Cheers
Dave