<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="34991" data-post-id="34991">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Qqwy" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Qqwy/120/1349_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Qqwy
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>TypeCheck Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="Crowdhailer" data-post="14" data-topic="5622" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/crowdhailer/48/2438_2.png" class="avatar"> Crowdhailer:</div>
<blockquote>
<p>yes A data type for rational numbers. It would be best if in code divisions got put straight to this type. I believe clojure does this</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">3
# %Rational{numerator: 3, divisor:1}

2/3
# %Rational{numerator: 3, divisor:1}
</code></pre>
<p>Then a number protocol to get decimal values</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">Number.to_string(1 + 3/2, decimal_places: 2)
# 2.50
Number.to_string(1 + 2/3, decimal_places: 2)
# 1.67
</code></pre>
<p>As a protocol it would be extensible to other structs</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">Number.to_string(%SquareRoot{value: 2}, decimal_places: 2)
# 1.41
Number.to_string(%Pi{}, decimal_places: 2)
# 3.14
</code></pre>
</blockquote>
</aside>
<p>I think you will like <a href="https://github.com/qqwy/elixir-rational" rel="noopener nofollow ugc">Ratio</a>, because it does much of this.</p>
<p>As for using symbolic math: The reason it is not used frequently in practice is that it is multiple orders of magnitude slower than using floating-point operations (which modern CPUs are very much optimized for), and for most computational problems, working with (matrices of) floats is ‘good enough <img src="https://forum.elixirforum.com/images/emoji/apple/tm.png?v=15" title=":tm:" class="emoji" alt=":tm:" loading="lazy" width="20" height="20">’.</p>
<p>Still, symbolic(/arbitrary precision) math certainly has its use cases. I did start writing <a href="https://github.com/Qqwy/symmath" rel="noopener nofollow ugc">something akin to a symbolic math engine</a> in Elixir a while back (abusing the power of macros to read Elixir’s AST as symbolic formulas). But my mathematical skills are not something to write home about <img src="https://forum.elixirforum.com/images/emoji/apple/sweat_smile.png?v=15" title=":sweat_smile:" class="emoji" alt=":sweat_smile:" loading="lazy" width="20" height="20">, so it is very much incomplete and probably bug-ridden.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="34991" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/what-would-you-remove-from-elixir/5622/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-34991" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="34991"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #21"></div>
  </section>
</div>
    <div class="postbit" id="35002" data-post-id="35002">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="OvermindDL1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/OvermindDL1/120/2677_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  OvermindDL1
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="thousandsofthem" data-post="2" data-topic="5622" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/thousandsofthem/48/1030_2.png" class="avatar"> thousandsofthem:</div>
<blockquote>
<p>Tuple keyword pairs, e.g [foo: 1] and replace them with real maps. Not gonna happen though</p>
</blockquote>
</aside>
<p>I like tuple keyword pairs, I do however <em>hate</em> the <code>[foo: 1]</code> syntax, I prefer <code>[{foo, 1}]</code>, not only because that is the erlang way, but because propertylists are more powerful than elixir kwlists.  For example in erlang-style property-lists both of these are the same thing (using elixir syntax of course) <code>[{:blah, true}, :blah]</code> which means that you can have very succinct option lists for arguments, but in elixir you have to do <code>[{:blah, true}]</code> (or the traditionally elixir syntax, which saves you 3 chars <code>[blah: true]</code>) instead of just being able to do <code>[:blah]</code>.  Consequently I use the erlang’s property list functions in Elixir a lot more than I use Elixir’s Keyword module just because the Keyword module is a sub-set of the property list module as an Elixir keyword list is a property list, but a property list is not necessarily a keyword list, property lists are more succinct and more powerful.  In addition the ‘key’ of a property list can be anything, not just atoms.</p>
<aside class="quote no-group" data-username="Crowdhailer" data-post="3" data-topic="5622">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/crowdhailer/48/2438_2.png" class="avatar"> Crowdhailer:</div>
<blockquote>
<p>:atoms because</p>
</blockquote>
</aside>
<p>I’m still iffy on the colon-atom syntax in Elixir, but I think I’m warming up to it.  And atoms are interned strings, they are not strings, just like you cannot compare a flyweight string in C++ to a normal string, same thing here.  Think of Atoms as a globally named enumeration (because that really is what they are), do not think of them as strings.  I absolutely would *NOT*EVER* want atoms removed, enumerations are <em>valuable</em>.</p>
<aside class="quote no-group" data-username="Crowdhailer" data-post="3" data-topic="5622">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/crowdhailer/48/2438_2.png" class="avatar"> Crowdhailer:</div>
<blockquote>
<p>floating point numbers, because</p>
</blockquote>
</aside>
<p>That is in any language though (that does not do magical and bug-hiding auto-casting), the bit representation of 1.0 and 1 are different (well, it might for 1.0 and 1 depending).  Absolutely would not want this removed either.  Emulating floating point with integer math is <em>sloooooooow</em>.</p>
<p>I mostly prefer fixed-point though, but floating point is sometimes necessary.</p>
<aside class="quote no-group" data-username="Qqwy" data-post="4" data-topic="5622">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/qqwy/48/1349_2.png" class="avatar"> Qqwy:</div>
<blockquote>
<p>I would remove the restriction that keyword lists can only contain atoms as keys <img src="https://forum.elixirforum.com/images/emoji/apple/laughing.png?v=15" title=":laughing:" class="emoji" alt=":laughing:" loading="lazy" width="20" height="20">.</p>
</blockquote>
</aside>
<p>Hehe, what I said above, you want property lists too.  <img src="https://forum.elixirforum.com/images/emoji/apple/wink.png?v=15" title=":wink:" class="emoji" alt=":wink:" loading="lazy" width="20" height="20"></p>
<aside class="quote no-group" data-username="DianaOlympos" data-post="5" data-topic="5622" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dianaolympos/48/4353_2.png" class="avatar"> DianaOlympos:</div>
<blockquote>
<p>if, cond and unless. Yes they may have use case, but they are also in general a bit too much abused.</p>
</blockquote>
</aside>
<p><code>if</code> is a nice wrapper around <code>cond</code> (wish it were a literal wrapper around <code>cond</code>), but it and <code>unless</code> are nice macro’s, they should just not be part of the language proper, but should be macro’s inside Kernel is all, if so then all good.</p>
<aside class="quote no-group" data-username="aseigo" data-post="6" data-topic="5622">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/aseigo/48/10674_2.png" class="avatar"> aseigo:</div>
<blockquote>
<p>Keyword lists and “tagged tuples” are an inheritance from Erlang where they are idiomatic and widely used, and I agree they are not as useful in Elixir on its own but .. yeah.. legacy is as legacy does, they aren’t going anywhere.</p>
</blockquote>
</aside>
<p>Keyword lists are not inheritence from Erlang, they are entirely an Elixir construct, just a reduced property list (which ‘is’ from Erlang).  I’d prefer property lists over keyword lists any day.</p>
<p>Tagged tuples are indeed not only idiomatic but *very*fast*, they are awesome in general.</p>
<aside class="quote no-group" data-username="aseigo" data-post="7" data-topic="5622">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/aseigo/48/10674_2.png" class="avatar"> aseigo:</div>
<blockquote>
<p>Do you prefer function head pattern matching, or other control flow strategies, or?</p>
</blockquote>
</aside>
<p>Function head matching just compiles into a case statement in a single function in CoreErlang anyway, so they are just a <code>case</code>.</p>
<p><code>case</code> is a core branching conditional, it should be front-and-foremost.<br>
<code>cond</code> is a core sequential conditional, it should be front-and-foremost.</p>
<p><code>case</code> and <code>cond</code> cannot do what the other does as efficiently as the other does it.</p>
<p>Everything else after that is sugar.</p>
<aside class="quote no-group" data-username="Crowdhailer" data-post="8" data-topic="5622">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/crowdhailer/48/2438_2.png" class="avatar"> Crowdhailer:</div>
<blockquote>
<p>A smart enough compiler should be able to turned user declared strings into atoms at the places it matters.</p>
</blockquote>
</aside>
<p>There are libraries for that.  The compiler <strong>absolutely</strong> should <strong>not</strong> do that, absolutely!  They have two very different use-cases and they are <strong>not</strong> equivalent.</p>
<aside class="quote no-group" data-username="NobbZ" data-post="9" data-topic="5622">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nobbz/48/27235_2.png" class="avatar"> NobbZ:</div>
<blockquote>
<p>But! I’d be very happy if we could remove the implicit else: nil and either replace it with raising something or making it mandatory as in Haskell.</p>
</blockquote>
</aside>
<p>So you want it how it is in Erlang then.  <img src="https://forum.elixirforum.com/images/emoji/apple/wink.png?v=15" title=":wink:" class="emoji" alt=":wink:" loading="lazy" width="20" height="20"><br>
In Erlang you have no <code>if</code>, just <code>cond</code>, and if you have no ‘else’ condition (via <code>true -&gt;</code>) then you get a match error.  I prefer that.</p>
<aside class="quote no-group" data-username="NobbZ" data-post="9" data-topic="5622">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nobbz/48/27235_2.png" class="avatar"> NobbZ:</div>
<blockquote>
<p>If this had been from the beginning, we hadn’t had any problems with what is called an “imperative assignment” nowadays.</p>
</blockquote>
</aside>
<p>Elixir has one very very <em>very</em> what I consider monumentally stupid decision that is hitting me to this day (in mostly macro work), but I’ll get to that at the bottom…</p>
<aside class="quote no-group" data-username="aseigo" data-post="11" data-topic="5622">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/aseigo/48/10674_2.png" class="avatar"> aseigo:</div>
<blockquote>
<p>What I do notice is that these conditionals get used a lot in some Elixir code when there are other more .. idiomatic? .. ways of doing it. Some code looks very much like it’s -port-to-Elixir. I know here at work developers new to Elixir avoid things like function-head pattern matching in favor of the seemingly-familiar  if even if that more familiar conditional form ends up being less clear to read.</p>
</blockquote>
</aside>
<p>Very <em>very</em> much.  For every one time I use <code>if</code>/<code>cond</code> I use <code>case</code> at least a dozen times.  <code>if</code>/<code>cond</code> is not a common construct on the BEAM for well written code.</p>
<aside class="quote no-group" data-username="aseigo" data-post="11" data-topic="5622">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/aseigo/48/10674_2.png" class="avatar"> aseigo:</div>
<blockquote>
<p>I do find that with the embarrassing riches in conditional constructs that are available, it can be difficult at times to decide which to use when. I wonder if over time there will be a stronger tendency towards a given set of idioms in Elixir, or if over time it will evolve into a more Perlesque acceptance of the multitude of equal paths.</p>
</blockquote>
</aside>
<p>Honestly I’d think elixir should toss out <code>if</code>/<code>unless</code>, if someone wants those let them use <code>and</code>/<code>or</code>/<code>||</code>/<code>&amp;&amp;</code> as those are <em>obviously</em> expressions and have defined results.  Try to push people to <code>case</code>/<code>cond</code> instead.</p>
<aside class="quote no-group" data-username="tyro" data-post="12" data-topic="5622">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/t/858c86/48.png" class="avatar"> tyro:</div>
<blockquote>
<p>I would also remove the restriction that string keys must precede atom keys in map literals. i.e.</p>
</blockquote>
</aside>
<p>I’d honestly prefer if the <code>a: 42</code> syntax was removed entirely to be honest, it is inconsistent, it should just be <code>:a =&gt; 42</code> as it would be a lot less confusing to newbies.  This is not a big thing to me though, but I do like unified constructs, and having two ways to do the same expression for something so simple does bug me.</p>
<aside class="quote no-group" data-username="Crowdhailer" data-post="14" data-topic="5622">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/crowdhailer/48/2438_2.png" class="avatar"> Crowdhailer:</div>
<blockquote>
<p>yes A data type for rational numbers. It would be best if in code divisions got put straight to this type. I believe clojure does this</p>
</blockquote>
</aside>
<p>We already have the Decimal and Ratio libraries for that.  <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<aside class="quote no-group" data-username="cdegroot" data-post="15" data-topic="5622">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/cdegroot/48/4644_2.png" class="avatar"> cdegroot:</div>
<blockquote>
<p>IMO floating point is the most overrated and unnecessary datatype in our industry. Unless you work in science, or maybe engineering? But that seems to me a vanishing minority, let them include specific libraries.</p>
</blockquote>
</aside>
<p>Except those cannot be emulated efficiently by a library, floating point has to be a fairly native language construct unless you can write assembly in the language (which we obviously cannot).</p>
<p>And it has great uses by far!  Just a lot of people try to do stupid things like represent money as floating points.  <img src="https://forum.elixirforum.com/images/emoji/apple/wink.png?v=15" title=":wink:" class="emoji" alt=":wink:" loading="lazy" width="20" height="20"></p>
<p>If you can come up with an efficient representation of floating point that is at least as fast as floating point (since its purpose is for efficiency, not accuracy) then I’d say sure, but if you came up with such a style you would also likely become a millionaire near overnight.</p>
<aside class="quote no-group quote-modified" data-username="bbense" data-post="18" data-topic="5622" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/bbense/48/1074_2.png" class="avatar"> bbense:</div>
<blockquote>
<p>No floating point , no AI “Pile of Linear Algebra” Hmm, no way to include a image?</p>
</blockquote>
</aside>
<p>Standard markdown syntax:<br>
![Image title, can be blank](<a href="https://url/to/image.png" rel="noopener nofollow ugc">https://url/to/image.png</a>)<br>
Like a link, just with ! at the start.  <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<aside class="quote no-group" data-username="Crowdhailer" data-post="19" data-topic="5622">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/crowdhailer/48/2438_2.png" class="avatar"> Crowdhailer:</div>
<blockquote>
<p>I would think for science you would be most keen to avoid floats. scientific results would definitely want to be more specific about their errors.</p>
</blockquote>
</aside>
<p>Not necessarily.  If you only need, oh, 4 decimal places of accuracy and your work will not cause the error value to exceed that then floating point can let you get it done in, oh, 10 seconds, where fixed-point might take 2 hours.  SSE is a heck-of-a-drug.  ^.^</p>
<aside class="quote no-group" data-username="Crowdhailer" data-post="19" data-topic="5622">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/crowdhailer/48/2438_2.png" class="avatar"> Crowdhailer:</div>
<blockquote>
<p>I completely forgot but I would also remove with after my macro experiments with alternatives</p>
</blockquote>
</aside>
<p>Ditto, there is *no*reason*whatsoever* to have <code>with</code> be a special language construct.  It can easily be done as a macro instead, and can indeed be done ‘better’ as a macro.  Elixir has a few ‘special constructs’ that just break the syntax rules or are just wtf’s, and <code>with</code> is one.</p>
<p>I think something like <code>with</code>-as-a-macro should be included in Kernel, but it should absolutely <em>not</em> be a special construct.</p>
<h3><a name="p-35002-what-should-be-removed-1" class="anchor" href="#p-35002-what-should-be-removed-1" aria-label="Heading link" rel="nofollow"></a>What should be removed</h3>
<p>And for my vote of what should be removed:</p>
<p>BLOODY-FREAKING-VARS-LEAKING-OUT-OF-SCOPE!</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex&gt; case :blah do
...&gt;   :blah -&gt;
...&gt;     a = 42 # From function or so
...&gt;     a * 2
...&gt;   _ -&gt; :bloop
...&gt; end
84
iex&gt; a
42
iex&gt; # WTF?!?!?
nil
</code></pre>
<p>Grrrr, and sometimes this is really <em>REALLY</em> freaking hard to fix in macro’s without resorting to holding some state in ETS tables or the procdict or so, grrrrrrrr…</p>
<p>WHY was this <strong>EVER</strong> a thing?!?  This is the <em>one</em> thing that bugs me most of all and just makes the language <em>feel</em> like it is bug-ridden-waiting-to-explode kind of thing (even though I know better)…</p>
<h4><a name="p-35002-bonus-second-thing-2" class="anchor" href="#p-35002-bonus-second-thing-2" aria-label="Heading link" rel="nofollow"></a>Bonus second thing</h4>
<p>Why the frick is the <em>atom</em> <code>nil</code> used as the nil value when <code>[]</code> is better for it in every way.  It is ‘slightly’ faster for comparisons, it is also <code>falsey</code> to the BEAM, it is even <em>called</em> the nil type in the Erlang documentation, and there are a half-dozen other reasons it should have been used.</p>
<p>Also <code>nil</code> is used <em>way</em> too much!  The <code>undefined</code> atom is often better in most places it is used as it is a great indicator of this is an ignorable return, or the <code>ok</code> atom is often better in most places it is used as it is a better indicator of success-but-no-useful-return, or the <code>error</code> atom is often better in most places it is used as it is a better indicator of uhhh-wtf, or any other number of things.  I cannot thing of a single place anywhere in any function in any place that I would prefer <code>nil</code> over one of <code>[]</code>/<code>undefined</code>/<code>ok</code>/<code>error</code> or something else more specifically descriptive.  I have no clue where this <code>nil</code> wart even came from, probably some ruby-horror…</p>
<h4><a name="p-35002-bonus-bonus-what-i-want-added-3" class="anchor" href="#p-35002-bonus-bonus-what-i-want-added-3" aria-label="Heading link" rel="nofollow"></a>Bonus-bonus what I want added</h4>
<p>An <code>option</code> and <code>result</code> types, though they would really be <code>{:ok, value}</code>/<code>:error</code> and <code>{:ok, value}</code>/<code>{:error, reason}</code> but with helpers in a module.  This could easily be a library sure, but this should be baked into the language stdlib/kernel or so thus the usage is ubiquitous and unified.  I’d love to do something like this (assume each returns an option/result tuple):</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">import OptionResult, only: [|&gt;: 2, ~&gt;: 2] # I'd prefer these in kernel though...
do_something(blah)
|&gt; operate_on_value(bleep)
~&gt; operate_on_error_to_return_new_result(bloop)
|&gt; more_stuff()
|&gt; yet_more_stuff()
</code></pre>
<p>And at the end you have an ok or error tuple that is the result of the pipeline, success values are passed in at |&gt; and skipped on error, and error values are passed in on ~&gt; and skipped on successes.  You could even have a final call of something like <code>~&gt; throw</code> if you want to throw on error so you only have a success too.</p>
<p>Yes I know there are libraries for these, <code>exceptional</code> is the library I use for this (although it does ‘more’), but it really should be part of the base standard library so its use is ubiquitous.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="35002" data-batch-url="/posts/batch_likers">
                        6
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/what-would-you-remove-from-elixir/5622/23">Post #22</a>
	                </div>
	            </div>
              <div id="likers-container-35002" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="35002"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #22"></div>
  </section>
</div>
    <div class="postbit" id="35005" data-post-id="35005">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Crowdhailer" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Crowdhailer/120/2438_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Crowdhailer
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Raxx</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="OvermindDL1" data-post="23" data-topic="5622">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/overminddl1/48/2677_2.png" class="avatar"> OvermindDL1:</div>
<blockquote>
<p>An option and result types, though they would really be {:ok, value}/:errorand{:ok, value}/{:error, reason} but with helpers in a module</p>
</blockquote>
</aside>
<p>I assume you know but if not check out <a href="https://hexdocs.pm/ok/readme.html" rel="noopener nofollow ugc">OK</a>. It is very similar to exceptional; However I am trying to keep it really small so it could act as a blueprint to what would support for result tuples could be added to the language. As a bonus it has a with macro.[quote=“Qqwy, post:22, topic:5622”]<br>
I think you will like Ratio, because it does much of this.<br>
[/quote]</p>
<p>That also looks good. I have just played around and 30mins allowed me to do the following.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">use Num.Rational

a = 1/2
b = 3/4
assert "2/3" == "#{a / b}"
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="35005" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/what-would-you-remove-from-elixir/5622/24">Post #23</a>
	                </div>
	            </div>
              <div id="likers-container-35005" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="35005"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #23"></div>
  </section>
</div>
    <div class="postbit" id="35010" data-post-id="35010">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Qqwy" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Qqwy/120/1349_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Qqwy
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>TypeCheck Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group quote-modified" data-username="OvermindDL1" data-post="23" data-topic="5622">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/overminddl1/48/2677_2.png" class="avatar"> OvermindDL1:</div>
<blockquote>
<p>Why the frick is the atom nil used as the nil value when <span class="chcklst-box fa fa-square-o"></span> is better for it in every way.  It is ‘slightly’ faster for comparisons, it is also falsey to the BEAM, it is even called the nil type in the Erlang documentation, and there are a half-dozen other reasons it should have been used.</p>
</blockquote>
</aside>
<p>I just <em>have</em> to repeat what José said in IRC yesterday:</p>
<blockquote>
<p>José Valim: honestly, i only added nil because i heard it was the one billion dollar mistake<br>
but i was thinking that the person made one billion dollar with the mistake<br>
so i was waiting for my one billion dollar but alas <img src="https://forum.elixirforum.com/images/emoji/apple/cry.png?v=15" title=":cry:" class="emoji" alt=":cry:" loading="lazy" width="20" height="20"></p>
</blockquote>
<p>:'D</p>
<p>As to why use <code>nil</code> over <code>[]</code>, I think the reason is to show intent more clearly, as <code>[]</code> might mean ‘no results’ rather than ‘nothing’. <code>nil</code> is more search-able than <code>[]</code>, just like <code>Enum.map</code> is more searchable than <a href="http://hackage.haskell.org/package/base-4.9.1.0/docs/Data-Functor.html#v:-60--36--62-" rel="noopener nofollow ugc"><code>&lt;$&gt;</code></a>.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="35010" data-batch-url="/posts/batch_likers">
                        5
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/what-would-you-remove-from-elixir/5622/25">Post #24</a>
	                </div>
	            </div>
              <div id="likers-container-35010" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="35010"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #24"></div>
  </section>
</div>
    <div class="postbit" id="35036" data-post-id="35036">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="OvermindDL1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/OvermindDL1/120/2677_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  OvermindDL1
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="Qqwy" data-post="25" data-topic="5622">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/qqwy/48/1349_2.png" class="avatar"> Qqwy:</div>
<blockquote>
<p>:'D</p>
</blockquote>
</aside>
<p>Lol, that is awesome!  ^.^</p>
<aside class="quote no-group quote-modified" data-username="Qqwy" data-post="25" data-topic="5622">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/qqwy/48/1349_2.png" class="avatar"> Qqwy:</div>
<blockquote>
<p>As to why use nil over <span class="chcklst-box fa fa-square-o"></span>, I think the reason is to show intent more clearly, as <span class="chcklst-box fa fa-square-o"></span> might mean ‘no results’ rather than ‘nothing’. nil is more search-able than <span class="chcklst-box fa fa-square-o"></span>, just like Enum.map is more searchable than &lt;$&gt;.</p>
</blockquote>
</aside>
<p>I still hold that <code>nil</code> and <code>[]</code> both are not appropriate in most places they are used, properly named returns are always better.  <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="35036" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/what-would-you-remove-from-elixir/5622/26">Post #25</a>
	                </div>
	            </div>
              <div id="likers-container-35036" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="35036"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #25"></div>
  </section>
</div>
    <div class="postbit" id="35041" data-post-id="35041">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jeramyRR" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jeramyRR/120/722_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jeramyRR
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I would remove nil.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="35041" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/what-would-you-remove-from-elixir/5622/27">Post #26</a>
	                </div>
	            </div>
              <div id="likers-container-35041" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="35041"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #26"></div>
  </section>
</div>
    <div class="postbit" id="35042" data-post-id="35042">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="OvermindDL1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/OvermindDL1/120/2677_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  OvermindDL1
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’m reminded of old days in Erlang (decade+ ago) where there was discussion about some of the API’s (especially ETS) about some things taking or returning magic values (things like <code>:"$ENDOFTABLE$"</code> or something like that) to indicate empty and so forth, it is unlikely to be a valid value, but it ‘could’ be a valid value, and that they should have returned tagged-tuples instead, it was a wart on the system.</p>
<p>Right now Elixir is doing the same, it is returning the value <code>nil</code>, which actually <em>is</em> a valid value in many cases right now (due to how ubiquitous Elixir uses <code>nil</code> all over the place) so sometimes you cannot tell what is valid and what is not, there have been multiple conversations on the Issue Tracker and here and other places talking about those API’s and how to figure out if the <code>nil</code> is the non-value <code>nil</code> or if it a valid return from what they were trying to get.  It is interesting how things are repeating in the Elixir world without learning from the old Erlang days.  ^.^</p>
<p>Tagged tuples really should be far far more ubiquitous in Elixir, it could have made a better syntax for those perhaps, or just use them as-is is perfectly fine.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="35042" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/what-would-you-remove-from-elixir/5622/28">Post #27</a>
	                </div>
	            </div>
              <div id="likers-container-35042" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="35042"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #27"></div>
  </section>
</div>
    <div class="postbit" id="35043" data-post-id="35043">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="michalmuskala" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/michalmuskala/120/20288_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  michalmuskala
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Turning to tuples everywhere, unfortunately, isn’t a viable solution. Just couple days ago, there was <a href="https://github.com/elixir-lang/elixir/issues/6164" rel="noopener nofollow ugc">an issue</a> about replacing the “awfully nil-ridden” <code>Enum.find_value</code> (and friends). This would mean, however, in many places replacing code that is very readable and simple with something very complex.</p>
<p>Let’s look at some examples I posted in the issue:</p>
<blockquote>
<p>In Phoenix <a href="https://github.com/phoenixframework/phoenix/blob/c3351478748779fe0b777a4f41e7ace7ae5e2452/lib/mix/phoenix.ex#L15-L17" rel="noopener nofollow ugc">here</a> we would change from:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">content =
  Enum.find_value(sources, fn source -&gt;
    File.exists?(source) &amp;&amp; File.read!(source)
  end) || raise "could not find #{source_file_path} in any of the sources"
</code></pre>
<p>to</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">res = 
  Enum.seach(sources, fn source -&gt;
    if File.exists?(source) do
      {:ok, File.read!(source)}
    else
      :error
    end
  end) 
content =
  case res do
    :error -&gt; raise "could not find #{source_file_path} in any of the sources"
    {:ok, content} -&gt; content
  end
</code></pre>
</blockquote>
<blockquote>
<p>Another similar use case is present just couple lines lower in the same file. I also found a couple more uses with an <code>||</code> after <code>find_value/2</code> in Phoenix, but those could be arguably replaced by passing the default value to <code>find_value/3</code>. It’s not possible in case we wanted to raise, though.</p>
</blockquote>
<blockquote>
<p>Another <a href="https://github.com/mschae/cors_plug/blob/e64918d28ca0abae65d75d33edb6966ba9970f90/lib/cors_plug.ex#L100" rel="noopener nofollow ugc">use that would require more convolution</a> would require changing from:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">Enum.find_value(headers, fn({k, v}) -&gt; k =~ ~r/^origin$/i &amp;&amp; v end)
</code></pre>
<p>to</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">Enum.search(headers, fn({k, v}) -&gt; if k =~ ~r/^origin$/i, do: {:ok, v}, else: :error end end)
</code></pre>
<p>with additional modification of the consumer, from a simple <code>if</code> to a <code>case</code> match on the ok tuple.</p>
</blockquote>
<blockquote>
<p>Last <a href="https://github.com/elixir-ecto/ecto/blob/master/lib/ecto/multi.ex#L399-L406" rel="noopener nofollow ugc">use I found</a> after a brief grep of deps of my app is in ecto (and that one I wrote myself). It would require changing:</p>
</blockquote>
<blockquote>
<pre data-code-wrap="elixir"><code class="lang-elixir">defp check_operations_valid(operations) do
  Enum.find_value(operations, &amp;invalid_operation/1) || {:ok, operations}
end
</code></pre>
</blockquote>
<blockquote>
<p>defp invalid_operation({name, {:changeset, %{valid?: false} = changeset, _}}),<br>
do: {:error, {name, changeset, %{}}}<br>
defp invalid_operation(_operation),<br>
do: nil</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">to
```elixir
defp check_operations_valid(operations) do
  case Enum.search(operations, &amp;invalid_operation/1) do
    :error -&gt; {:ok, operations}
    {:ok, invalid} -&gt; {:error, invalid}
  end
end
</code></pre>
</blockquote>
<blockquote>
<p>defp invalid_operation({name, {:changeset, %{valid?: false} = changeset, _}}),<br>
do: {:ok, {name, changeset, %{}}}<br>
defp invalid_operation(_operation),<br>
do: :error</p>
<pre data-code-wrap="elixir"><code class="lang-elixir"></code></pre>
</blockquote>
<blockquote>
<p>While it does not introduce more code, it’s much harder to understand, since we’re looking for an error, but have to return it tagged in an <code>ok</code> tuple, just to switch tags at the end.</p>
</blockquote>
<p>The situation is far more nuanced than “nil is bad”. I urge some of you that propose removing it, to try to remove it from your code and get back to us with results.</p>
<p>Also, switching from atom <code>nil</code> to <code>[]</code> would make the issue far, far worse. An empty list is so much more ubiquitous than atom <code>nil</code>, it would require that much more attention when used. It would also lead to conflating two notions - empty collections and “no value”.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="35043" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/what-would-you-remove-from-elixir/5622/29">Post #28</a>
	                </div>
	            </div>
              <div id="likers-container-35043" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="35043"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #28"></div>
  </section>
</div>
    <div class="postbit" id="35047" data-post-id="35047">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="DianaOlympos" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/DianaOlympos/120/4353_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  DianaOlympos
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>About <code>if</code> you can use <code>with</code> for the same effect <img src="https://forum.elixirforum.com/images/emoji/apple/stuck_out_tongue.png?v=15" title=":stuck_out_tongue:" class="emoji" alt=":stuck_out_tongue:" loading="lazy" width="20" height="20"></p>
<p>But in general, i highly prefer function pattern matching because</p>
<ol>
<li>it makes the scoping evident</li>
<li>it gives the test a <em>name</em> which explains really well what you are doing</li>
<li>it is extendable</li>
<li>it is really not a way of thinking about your flow that i want to offer to people.</li>
</ol> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="35047" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/what-would-you-remove-from-elixir/5622/30">Post #29</a>
	                </div>
	            </div>
              <div id="likers-container-35047" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="35047"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #29"></div>
  </section>
</div>
    <div class="postbit" id="35048" data-post-id="35048">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="net" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/net/120/429_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  net
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Why use boolean operators in the befores but not the afters? Seems unfair.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">content =
  case Enum.search(sources, &amp;(File.exists?(&amp;1) &amp;&amp; {:ok, File.read!(&amp;1)} || :error)) do
    {:ok, content} -&gt; content
    :error -&gt; raise "could not find #{source_file_path} in any of the sources"
  end
</code></pre>
<pre><code>Enum.search(headers, fn({k, v}) -&gt; k =~ ~r/^origin$/i &amp;&amp; {:ok, v} || :error end)
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="35048" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/what-would-you-remove-from-elixir/5622/31">Post #30</a>
	                </div>
	            </div>
              <div id="likers-container-35048" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="35048"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #30"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/5622/load_more?page=4">Load more posts (53 remaining)</a>
</div></template></turbo-stream>