<story><title>Read this post ‘unless’ you’re not a Ruby developer</title><url>https://jesseduffield.com/Unless/</url></story><parent_chain><item><author>JasonFruit</author><text>You&amp;#x27;ve demonstrated that it is trivially replaced by &amp;#x27;if&amp;#x27; and negation. I think that&amp;#x27;s almost the definition of inelegant.</text></item><item><author>nickelcitymario</author><text>I&amp;#x27;d consider myself a writer more than a developer, but I&amp;#x27;ve been working in Rails for over 15 years, and one of my absolute favourite things is &amp;quot;unless&amp;quot;.&lt;p&gt;Why? Because it allows you to express yourself more elegantly.&lt;p&gt;The click-bait title is misleading. It&amp;#x27;s meant to ridicule &amp;quot;unless&amp;quot;, but actually achieves the opposite.&lt;p&gt;If you were to write the title of the post as code, it would be:&lt;p&gt;&lt;pre&gt;&lt;code&gt;  unless !ruby_dev
    read article
  end
&lt;/code&gt;&lt;/pre&gt;
That would be a terrible use of &amp;quot;unless&amp;quot;! That should clearly say &amp;quot;if ruby_dev&amp;quot;, not &amp;quot;unless !ruby_dev&amp;quot;.&lt;p&gt;But what if you wanted to write an article meant for anyone other than ruby developers?&lt;p&gt;Which of the following is better?&lt;p&gt;&lt;pre&gt;&lt;code&gt;  if !ruby_dev
&lt;/code&gt;&lt;/pre&gt;
or&lt;p&gt;&lt;pre&gt;&lt;code&gt;  unless ruby_dev
&lt;/code&gt;&lt;/pre&gt;
Both work, but I consider the second option more elegant. Just as I wouldn&amp;#x27;t verbally say &amp;quot;if you&amp;#x27;re not a ruby developer&amp;quot; rather than &amp;quot;unless you&amp;#x27;re a ruby developer&amp;quot;.&lt;p&gt;Honestly, I don&amp;#x27;t see the issue. It&amp;#x27;s a style matter. Just use it properly. All language can be abused if you try hard enough.</text></item></parent_chain><comment><author>nickelcitymario</author><text>Only if you definition of elegance is &amp;quot;please express yourself in as convoluted a way as possible, so as to minimize the number of words I need to know.&amp;quot;&lt;p&gt;The truth is there is a balance in all languages. Nearly every word was invented to prevent having to say a string of other words to mean the same thing.&lt;p&gt;&amp;quot;Unless&amp;quot; is a single word to mean &amp;quot;If not&amp;quot;. I consider that elegant.&lt;p&gt;However, some languages take this too far, in my opinion. German famously has a word for nearly everything. I&amp;#x27;m not sure that&amp;#x27;s elegant, in that it requires learning a far greater number of words.&lt;p&gt;English has many words that I wouldn&amp;#x27;t consider elegant, simply because they&amp;#x27;re uncommon or convoluted. Never use a 10 dollar word when a 5 cent word will do.&lt;p&gt;So, if, like me and the ruby community, you prefer to optimize for developer happiness, &amp;quot;unless&amp;quot; is an elegant choice.&lt;p&gt;If you prefer to optimize for peak computing performance, if may be more computationally efficient use &amp;quot;if not&amp;quot;.&lt;p&gt;But, _unless_ you&amp;#x27;re saying that you never use the word &amp;quot;unless&amp;quot; in everyday language, I think we can agree it&amp;#x27;s a good word that has good applications. I don&amp;#x27;t see why that wouldn&amp;#x27;t be true in programming.</text></comment>
<story><title>Read this post ‘unless’ you’re not a Ruby developer</title><url>https://jesseduffield.com/Unless/</url></story><parent_chain><item><author>JasonFruit</author><text>You&amp;#x27;ve demonstrated that it is trivially replaced by &amp;#x27;if&amp;#x27; and negation. I think that&amp;#x27;s almost the definition of inelegant.</text></item><item><author>nickelcitymario</author><text>I&amp;#x27;d consider myself a writer more than a developer, but I&amp;#x27;ve been working in Rails for over 15 years, and one of my absolute favourite things is &amp;quot;unless&amp;quot;.&lt;p&gt;Why? Because it allows you to express yourself more elegantly.&lt;p&gt;The click-bait title is misleading. It&amp;#x27;s meant to ridicule &amp;quot;unless&amp;quot;, but actually achieves the opposite.&lt;p&gt;If you were to write the title of the post as code, it would be:&lt;p&gt;&lt;pre&gt;&lt;code&gt;  unless !ruby_dev
    read article
  end
&lt;/code&gt;&lt;/pre&gt;
That would be a terrible use of &amp;quot;unless&amp;quot;! That should clearly say &amp;quot;if ruby_dev&amp;quot;, not &amp;quot;unless !ruby_dev&amp;quot;.&lt;p&gt;But what if you wanted to write an article meant for anyone other than ruby developers?&lt;p&gt;Which of the following is better?&lt;p&gt;&lt;pre&gt;&lt;code&gt;  if !ruby_dev
&lt;/code&gt;&lt;/pre&gt;
or&lt;p&gt;&lt;pre&gt;&lt;code&gt;  unless ruby_dev
&lt;/code&gt;&lt;/pre&gt;
Both work, but I consider the second option more elegant. Just as I wouldn&amp;#x27;t verbally say &amp;quot;if you&amp;#x27;re not a ruby developer&amp;quot; rather than &amp;quot;unless you&amp;#x27;re a ruby developer&amp;quot;.&lt;p&gt;Honestly, I don&amp;#x27;t see the issue. It&amp;#x27;s a style matter. Just use it properly. All language can be abused if you try hard enough.</text></item></parent_chain><comment><author>shakow</author><text>A for can be replaced by a while and a jump, that does not make it more or less elegant.&lt;p&gt;IMHO, something ‶elegant″ in programming is not something that can&amp;#x27;t be built form something else (or we will all end up in writing only CMOVs), but something that conveys the meaning of its author precisely and concisely – which makes it inherently subjective. I&amp;#x27;m in the `unless` team, I can perfectly understand if you are in the `no unless` team, but this argument does not make a lot of sense.</text></comment>