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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="mguimas" data-post="31" data-topic="57577">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mguimas/48/11229_2.png" class="avatar"> mguimas:</div>
<blockquote>
<p>Obviously, if your test coverage is not wide enough, then you probably are not testing a part of the code where a type mismatch is hidden … and this is where a static type system will help you avoid these hidden type mismatches. But if someone is not covering well the code with tests, then probably they don’t care for that code’s quality too, so you get as much as you put in.</p>
</blockquote>
</aside>
<p>You are not wrong but strong static typing will force the programmers to think about these. Which is often a good thing.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="298449" 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/types-n-testing/57577/32">Post #31</a>
	                </div>
	            </div>
              <div id="likers-container-298449" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="298449"
                     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 #31"></div>
  </section>
</div>
    <div class="postbit" id="298626" data-post-id="298626">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>My view is that testing and strong typing both help with lowering the cost of change, but they do so in different ways, and are therefore not a substitute of each other.</p>
<p>Strong typing pins down the basic interface of each callable function, defining what is expected as input and output. If a change breaks such expectation, the type system tells us. Additionally, when used properly, types also provide documentation, specifying explicitly what a function takes as input and what it returns as output.</p>
<p>Good tests pin down invariant properties of the system behavior, so that if a change breaks such invariants, the test tells us. Ideally, a test would assert an invariant property without restricting the specific implementation, so that one could change the implementation and still pass the tests, if the invariant is respected.</p>
<p>Here’s a toy example to illustrate what I mean. Suppose I want to implement a sort of key-value store, with two functions: <code>set(key, value)</code> that sets a key to a value, and <code>get(key)</code>, that gets the value associated to a certain key, if any.</p>
<p>The type system can specify what keys and values are supposed to be, and even what happens if I try to <code>get</code> a key that is not associated to any value.</p>
<p>On the other hand, types won’t help in ensuring that if I set a certain key <code>K</code> to a certain value <code>V</code>, and then get the key <code>K</code>, I get exactly the value <code>V</code> and not another one of the same type. For that, we need a test like “set <code>K</code> to <code>V</code>. Then get <code>K</code>, and assert that the result is <code>V</code>”.</p>
<p>Such test asserts an invariant that the system should respect, without specifying what the implementation should be. Under the hood the system could be implemented as a hash map, as a database call, etc. without failing the test. This is easier said than done in more realistic cases, but that’s the aspiration.</p>
<p>Sometimes, a bug is discovered, and a test can be added to ensure that a similar bug cannot be re-introduced with future changes. That’s protecting against regressions, and again, ideally it would pin down some invariant that should hold for some corner case, rather than a specific implementation.</p>
<p>I don’t think that tests (or types) help much with ensuring correctness. What really matters for me is to lower the cost of change, and both tests and a good type system help, in complementary ways.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="298626" 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/types-n-testing/57577/33">Post #32</a>
	                </div>
	            </div>
              <div id="likers-container-298626" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="298626"
                     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 #32"></div>
  </section>
</div>
    <div class="postbit" id="298642" data-post-id="298642">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="adw632" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  adw632
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="lucaong" data-post="33" data-topic="57577">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lucaong/48/21794_2.png" class="avatar"> lucaong:</div>
<blockquote>
<p>Strong typing pins down the basic interface of each callable function, defining what is expected as input and output. If a change breaks such expectation, the type system tells us</p>
</blockquote>
</aside>
<p>If we think a bit deeper, where do the constraints and expectations come from?</p>
<p>Our Elixir programs do not really care what the <em>types</em> are, they only care that there is a matching function for the combination of argument <strong>values</strong> provided, and that function return <strong>values</strong> match expectations. Anything else is by definition invalid as without any static types it will generate a runtime exception and crash (as the Erlang gods intended).</p>
<p>I want to point out that our functional code goes beyond static type semantics to <em>value</em> semantics. So we <em>can</em> do better than static types.</p>
<p>If a future “type” system can infer “bottom up” the value constraints from the leaves of the call graph and propogate them up the call graph, then that is all that is needed to identify the possible call paths that permit unconstrained values to flow into those functions where the value constraints are violated.</p>
<p>I prefer to think of this kind of system as a <em>value constraints</em> system and therfore superior to a static type system that needs the developer to constantly remind the compiler “top down” that this thing is a string, this a string, it really is a string over and over and over…</p>
<p>The only thing that matters is that at some point in the code the <em>only</em> available matching function(s) require a string <em>then right there</em>, the value constraint exists  AND NOWHERE ELSE.</p>
<p>What we really want are the <em>value</em> constraints to automatically propagate up/out all of the code paths that can arrive at that function so that we can catch conflicts  so that <em>we</em> can decide if there is merit in specifically dealing with it earlier in the call graph.  Since we have <strong>safe</strong> let it crash semantics we can code the happy path, avoid polluting our code with types and sad path defensive coding paradigms of other languages and runtimes that do not have the automatic let it crash and cleanup luxury we have in BEAM languages.</p>
<p>In Elixir we do not have to be exhaustive in handling every possibility in our code as that is quite literally exhausting and proven to not be as reliable as BEAM languages and systems. Static types and defensive programming/exhaustiveness are in my view in conflict with coding the happy path and “let it crash”, the more productive path forward is in my view value constraint propagation to aid the developer to identify potential problems they may need to handle.</p>
<p>Value constraints can be more than a simple string type, it may be a constraint that the string be no longer than 12 characters and start with a capital letter. These value constraints can again be propogated up/out all code paths with no need for fixing type annotations throughout the code.</p>
<p>Imagine typing a function call in your favourite IDE and it pops up the value constraints on each function argument without you having to maintain types on everything, all derived through elixir pattern matching which collectively express the value constraints that exist in our programs.</p>
<p>Perhaps some business rules change and the code needs to alter the constraint, I don’t need to tell the compiler all through the code, I only need to implement the constraint at the function definition where the actual constraint is <em>necessary</em>. There is no need to be reminding the compiler on every possible call path, creating a refactoring mess, and we get value constraint expressiveness that goes far beyond the static type checking in most languages.</p>
<p>What I have described above is my <em>hope</em> for an enhanced value checking system in the BEAM (i.e. beneath Elixir) so that it helps the compiler to generate optimal code as well as help the developer identify potential constraint violations in the boundary layers of our programs or libraries.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="298642" 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/types-n-testing/57577/34">Post #33</a>
	                </div>
	            </div>
              <div id="likers-container-298642" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="298642"
                     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 #33"></div>
  </section>
</div>
    <div class="postbit" id="298646" data-post-id="298646">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="adw632" data-post="34" data-topic="57577">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/9d8465/48.png" class="avatar"> adw632:</div>
<blockquote>
<p>I prefer to think of this kind of system as a <em>value constraints</em> system and therfore superior to a static type system that needs the developer to constantly remind the compiler “top down” that this thing is a string, this a string, it really is a string over and over and over…</p>
</blockquote>
</aside>
<p>Neither of both is “superior” to the other, they should and they <em>do</em> complement each other (example: in Rust you have a statically strongly typed struct that you can deconstruct via pattern-matching, and you have 80% of the tools that Elixir has to do so. Same in OCaml).</p>
<p>This way of discourse – pitting stuff against each other – is unproductive. Or your claims about what is “proven” and you should really know better than to not post links showing the alleged “proof”.</p>
<p>The value semantics that Erlang / Elixir have are extremely valuable and nobody in this community is saying that they are not. Some of us however, me included, claim that adding <em>optional</em> strong static typing will make them <em>even more efficient</em>. Nothing else is being claimed. All of us here love the “let it crash” thing. Stuff yells at us in our APM system, we then proceed to add one more defensive clause in the code, problem solved, and we have the best of both worlds.</p>
<p>Elixir’s amazing mix of dynamic typing plus pattern-matching / deconstruction allows you to only <em>opt-in</em> for more static checking when you choose to do so (via guards) and that’s an enormous productivity booster and I understand why people fond of Elixir don’t want a static typing system. Well good news, nobody is currently rewriting the BEAM to be statically strongly typed under your feet! <img src="https://forum.elixirforum.com/images/emoji/apple/smiley.png?v=15" title=":smiley:" class="emoji" alt=":smiley:" loading="lazy" width="20" height="20"> Rejoice!</p>
<p>IMO general discussions on the topic are fairly unproductive and tend to devolve into semi-religious wars. It’s always discouraging to see somebody coming in and expressing a strong opinion. Historically, all of these abstractions have their place.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="298646" 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/types-n-testing/57577/35">Post #34</a>
	                </div>
	            </div>
              <div id="likers-container-298646" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="298646"
                     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 #34"></div>
  </section>
</div>
    <div class="postbit" id="298647" data-post-id="298647">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>If you mean to say that pattern matching is more expressive than a static type system, by all means I agree. But that does not invalidates the benefits of static typing. Of course, like everything, there are also costs: writing and maintaining static types takes effort. Therefore, whether static typing helps or hinders ultimately depends on the specific type system, project, team skills, etc.</p>
<p>I do think that, while a good type system has clear virtues, the benefits are often exaggerated. Definitely, however powerful, a type system does not replace a good test suite. And definitely there is expressiveness in a programming language way beyond static types.</p>
<p>I should also have added, the type system tells us about broken expectations <em>at compile time</em>. Then, how important it is to discover issues at compile time versus runtime depends heavily on the specific project. On a web applications with a good test suite, where “runtime” often means “when running tests”, monitoring errors is easy, and fixing the occasional bug is just a deployment away, it might not matter too much. On an embedded project, where a runtime issue happens on a user device, possibly hidden from the developer, and fixing a bug involves getting all devices to upgrade, the difference between compile time and runtime can be huge.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="298647" 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/types-n-testing/57577/36">Post #35</a>
	                </div>
	            </div>
              <div id="likers-container-298647" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="298647"
                     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 #35"></div>
  </section>
</div>
    <div class="postbit" id="298707" data-post-id="298707">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="adw632" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  adw632
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="dimitarvp" data-post="35" data-topic="57577">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/48/38664_2.png" class="avatar"> dimitarvp:</div>
<blockquote>
<p>Neither of both is “superior” to the other, they should and they <em>do</em> complement each other (example: in Rust you have a statically strongly typed struct that you can deconstruct via pattern-matching, and you have 80% of the tools that Elixir has to do so. Same in OCaml)</p>
</blockquote>
</aside>
<p>I have to respectfully disagree but I think we are both wanting similar outcomes from <em>compile</em> time checking and in fact at the developers fingertips when entering code in their IDE.</p>
<p>My view is that anything that requires developer overhead whilst detecting <em>fewer</em> problems is <em>objectively</em> inferior.</p>
<p>If you can obtain both the the strong type <em>and</em> value constraint  because the compiler is able to propagate those constraints, you don’t have to keep telling it all the time because you already did within the code where the  constraint was <em>neccesary</em>. There is no need to repeat a poor approximation of the value constraint all over the code base.  The compiler is able to provide constraint violation warnings with more more detail than a type.</p>
<p>Inferred value constraints are <strong>stronger</strong> than static type constraints and don’t require developer effort to obtain the benefit. They reflect the <em>true</em> constraints in our code, not <strong>approximations</strong> to them, and therefore we are able to detect both type and value errors at <em>compile</em> time.</p>
<aside class="quote no-group" data-username="lucaong" data-post="36" data-topic="57577">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lucaong/48/21794_2.png" class="avatar"> lucaong:</div>
<blockquote>
<p>I should also have added, the type system tells us about broken expectations <em>at compile time</em>. Then, how important it is to discover issues at compile time versus runtime depends heavily on the specific project</p>
</blockquote>
</aside>
<p>Agree.  However any argument or desire you have in favour of manual <em>approximate</em> static typing is eclipsed by automatic <strong>stronger</strong> value constraint checking at compile time.</p>
<p>If you can prove your code obeys all the value constraints because the compiler checks it, you can eliminate a whole range of tests and focus on the stuff that matters.</p>
<p>In fact you would have to <strong>disable</strong> constraint checking on tests to be able to call functions with bad values in order to test the runtime handling of boundary conditions. Imagine having to turn off static type checking in your other languages just to be able to compile tests and that will give you some idea of the relative strength that value constraint checking provides over static types.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="298707" 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/types-n-testing/57577/37">Post #36</a>
	                </div>
	            </div>
              <div id="likers-container-298707" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="298707"
                     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 #36"></div>
  </section>
</div>
    <div class="postbit" id="298715" data-post-id="298715">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="adw632" data-post="37" data-topic="57577">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/9d8465/48.png" class="avatar"> adw632:</div>
<blockquote>
<p>My view is that anything that requires developer overhead whilst detecting <em>fewer</em> problems is <em>objectively</em> inferior.</p>
</blockquote>
</aside>
<p>Your insistence on framing this as a duel between both things is very puzzling. I’ll ask you again: why not both?</p>
<p>Example:</p>
<p>Dynamic typing + pattern matching gives f.ex. 50% value.<br>
Static typing bolted on top gives f.ex. another 20% value.</p>
<p>The 70% sum is still bigger than 50%.</p>
<p>You will have to explain why do you keep framing this as an either-or. I don’t see the need for that.</p>
<aside class="quote no-group" data-username="adw632" data-post="37" data-topic="57577">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/9d8465/48.png" class="avatar"> adw632:</div>
<blockquote>
<p>There is no need to repeat a poor approximation of the value constraint all over the code base.</p>
</blockquote>
</aside>
<p>I don’t get you. How is static typing “repeating a poor approximation of the value constraint all over the code base”, exactly? Can you give examples?</p>
<aside class="quote no-group" data-username="adw632" data-post="37" data-topic="57577">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/9d8465/48.png" class="avatar"> adw632:</div>
<blockquote>
<p>Inferred value constraints are <strong>stronger</strong> than static type constraints and don’t require developer effort to obtain the benefit. They reflect the <em>true</em> constraints in our code, not <strong>approximations</strong> to them, and therefore we are able to detect both type and value errors at <em>compile</em> time.</p>
</blockquote>
</aside>
<p>Are you describing something that exists today in Elixir’s ecosystem? If so, can you provide a link to it?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="298715" 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/types-n-testing/57577/38">Post #37</a>
	                </div>
	            </div>
              <div id="likers-container-298715" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="298715"
                     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 #37"></div>
  </section>
</div>
    <div class="postbit" id="298723" data-post-id="298723">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="adw632" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  adw632
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="dimitarvp" data-post="35" data-topic="57577">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/48/38664_2.png" class="avatar"> dimitarvp:</div>
<blockquote>
<p>Or your claims about what is “proven” and you should really know better than to not post links showing the alleged “proof”.</p>
</blockquote>
</aside>
<p>Everything we do is towards the goal of <strong>correct</strong> and <strong>available</strong> systems. Static types (which may be useful in some language paradigms), are <em>incidental</em> to the stated goal, as all software has defects, and a robust strategy for dealing with and cleaning up from faults which may caused by software errors/bugs, or other operational conditions including node failures, <strong>trumps</strong> static typing.</p>
<p>I will turn this around, and ask you to name a language and runtime that has proven to provide concurrency, fault isolation, fault tolerance and live code evolution exceeding that of BEAM languages.</p>
<p>History has proven that BEAM languages do provide the <strong>essential</strong> foundations for the most <strong>dependable</strong> systems all without requiring  <strong>static</strong> types or requiring type annotations.</p>
<p>I also think the discussion is missing the nuance between <strong>strong typing</strong> vs <strong>static typing</strong>. You don’t need <em>static</em> typing to get <em>strong</em> typing and nor does <em>static</em> typing result in maintainable strongly typed code bases.</p>
<p>If we can accept that <strong>strong typing</strong> is the goal and static typing is just one (non optimal) approach to it, then I think we can agree that we all share a common goal, <strong>we want strongly typed code bases</strong> and as many errors detected at compile time as is practical such that it provides a net increase to productivity.</p>
<p>It just happens that I want the strongly typed system to detect value errors also <em>and I don’t want to pay for any of it</em> by reminding the compiler of the expectations. I want don’t repeat yourself - DRY.</p>
<p>An example of what I am referring to with <strong>strong</strong> typing and type inferencing on the BEAM is the <strong>Gleam</strong> language. It accomplishes what static typing does <strong>without</strong> requiring any type annotations, in fact type annotations / are optional and <strong>do not</strong> impact the compiler type checking, the compiler will however check that the <em>annotation documentation</em> is consistent with the inferred type constraint. There is nothing wrong with using annotations for documentation if you really want the maintenance burden, the key point is the annotations have <strong>zero impact</strong> on the strong type safety which is 100% inferred with zero developer overhead to get it.</p>
<p>Gleam is the style of <em>strong typing</em> I want for Elixir but actually taking it to the level of <em>value constraints</em> and preferably built into the BEAM VM so it can benefit all BEAM languages.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="298723" 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/types-n-testing/57577/39">Post #38</a>
	                </div>
	            </div>
              <div id="likers-container-298723" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="298723"
                     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 #38"></div>
  </section>
</div>
    <div class="postbit" id="298724" data-post-id="298724">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="adw632" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  adw632
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="dimitarvp" data-post="38" data-topic="57577">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/48/38664_2.png" class="avatar"> dimitarvp:</div>
<blockquote>
<p>I don’t get you. How is static typing “repeating a poor approximation of the value constraint all over the code base”, exactly? Can you give examples?</p>
</blockquote>
</aside>
<p>Think of the way we can match on binaries and then think of those value level constraints being propagated up as inferred types without having to type any annotations anywhere.</p>
<p>Now if I have a set of values that are passed into some chain of functions that do allow reaching a non-matching clause then I want to know what function call chains in my code allow that and either accept it (let it crash) or take action to test or sanitize it so that only values meeting the constraints can flow down that code path.</p>
<p>This is the <em>ideal</em> and any way we can get closer to it will enable use to detect more defects at compile time and ideally as we are coding without any <em>need</em> to decorate our code with annotations (the IDE presents the type and. value constraints to us, and for automated documentation generation the type and value constraints can be similarly produced.)</p>
<aside class="quote no-group" data-username="dimitarvp" data-post="38" data-topic="57577">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/48/38664_2.png" class="avatar"> dimitarvp:</div>
<blockquote>
<p>Are you describing something that exists today in Elixir’s ecosystem? If so, can you provide a link to it?</p>
</blockquote>
</aside>
<p>Gleam comes very close to the idea, it is strongly typed without being <em>statically</em> typed, but it stops at types and doesn’t go as far as value constraints.</p>
<p>Still I would welcome Gleam style strong typing in Elixir even without value constraints checking if we didn’t lose compatibility (e.g. Gleam requires homogeneous lists).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="298724" 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/types-n-testing/57577/40">Post #39</a>
	                </div>
	            </div>
              <div id="likers-container-298724" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="298724"
                     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 #39"></div>
  </section>
</div>
    <div class="postbit" id="298739" data-post-id="298739">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="adw632" data-post="40" data-topic="57577">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/9d8465/48.png" class="avatar"> adw632:</div>
<blockquote>
<p>Gleam comes very close to the idea, it is strongly typed without being <em>statically</em> typed</p>
</blockquote>
</aside>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://gleam.run/frequently-asked-questions/#how-does-gleam-compare-to-elixir">
  <header class="source">
      <img src="https://gleam.run/images/lucy/lucy.svg" class="site-icon" alt="" width="690" height="660">

      <a href="https://gleam.run/frequently-asked-questions/#how-does-gleam-compare-to-elixir" target="_blank" rel="noopener nofollow ugc">gleam.run</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/361;"><img src="https://gleam.run/images/preview/faq.png" class="thumbnail" alt="" width="690" height="361"></div>

<h3><a href="https://gleam.run/frequently-asked-questions/#how-does-gleam-compare-to-elixir" target="_blank" rel="noopener nofollow ugc">Frequently asked questions | Gleam programming language</a></h3>

  <p>What? Why? Where? When? How? Everything you wanted to know about Gleam.</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<p>Gleam is statically typed.</p>
<p>It’s hard for me to extract an actual argument from your comments because they seem to be strongly held opinions and are at places non-factual.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="298739" 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/types-n-testing/57577/41">Post #40</a>
	                </div>
	            </div>
              <div id="likers-container-298739" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="298739"
                     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 #40"></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/57577/load_more?page=5">Load more posts (26 remaining)</a>
</div></template></turbo-stream>