<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="368202" data-post-id="368202">
  <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">
								<p>Well that’s the problem, they don’t work with the Elixir AST; they work with TreeSitter tree structures. Any DSLs – not only in Elixir and not only Ash – trip those tools up.</p>
<p>This is definitely not a criticism on Ash. I am explaining limitations in tooling that I found.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="368202" 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/changes-to-the-struct-update-syntax/71232/59">Post #58</a>
	                </div>
	            </div>
              <div id="likers-container-368202" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="368202"
                     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 #58"></div>
  </section>
</div>
    <div class="postbit" id="368203" data-post-id="368203">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I don’t understand how a DSL that is valid elixir syntax could have the property you are describing. The tree sitter grammar covers Elixir syntax. If it didn’t work, syntax highlight DSLs would also break (which it doesn’t). Only exception is sigils (which Ash doesn’t use).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="368203" 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/changes-to-the-struct-update-syntax/71232/60">Post #59</a>
	                </div>
	            </div>
              <div id="likers-container-368203" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="368203"
                     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 #59"></div>
  </section>
</div>
    <div class="postbit" id="368205" data-post-id="368205">
  <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">
								<p>I meant it in the sense that those tools don’t find certain results in the code in response to queries (that’s what they do, they allow you to search in code without regexes and thus be more “aware”; and that’s where TreeSitter comes in). I’ve isolated those failures to DSLs but it did happen with a few other idioms as well. I’ve not kept examples so can’t provide them. Sorry.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="368205" 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/changes-to-the-struct-update-syntax/71232/61">Post #60</a>
	                </div>
	            </div>
              <div id="likers-container-368205" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="368205"
                     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 #60"></div>
  </section>
</div>
    <div class="postbit" id="368212" data-post-id="368212">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I feel like the old struct update syntax encourages fuzzy thinking, deprecation is the right move.</p>
<p>If you write:<br>
<code>new_user = %User{user | email: new_email}</code></p>
<p>You are saying two things</p>
<ol>
<li>I assert that  <code>user</code> is of type <code>User</code></li>
<li>I want to update their email</li>
</ol>
<p>That syntax serves mixes two unrelated purposes together: assertions and updates. So this leads to bad habits.</p>
<p>I reviewed my own code to see for myself. Many of my uses of the <code> %User{user | email: new_email}</code> syntax were lazy thinking. By chance, I was updating a variable and I thought “oh why not let me make sure to assert the struct type”. If I had thought of assertions on their own, in 90% of the cases, I would have asserted much sooner than the update to catch failed assertions earlier.</p>
<p>And one more point: I think readability can be solved better at the editor level rather than the language level.</p>
<p>For example Zig chooses to show inferred types inline:<br>
<img src="https://forum.elixirforum.com/uploads/default/original/3X/f/4/f4ecae905e401c579025b4547337301621fa18ba.png" alt="CleanShot 2025-06-28 at 10.26.18@2x" data-base62-sha1="yWHAFlqAHFJXT3mfGBpTJHC2aka" width="690" height="55" data-dominant-color="282727"></p>
<p>I did not type any of those gray types. The type inference is telling me what they are!</p>
<p>I personally find the above to be a bit noisy, but my point is, <em>this does not need to be solved at the language level</em>.</p>
<p>Solving this at editor layer has a few advantages:</p>
<ul>
<li>Less work - you don’t have to keep retyping the same struct just to remind yourself what the type is at that point. Your editor can show you the type it <em>will</em> be based on type inference.</li>
<li>Optional - If you’re reading code for the first time, you may want to turn on type inference hints. If you are familiar with the code, the hints may be noise</li>
</ul> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="368212" 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/changes-to-the-struct-update-syntax/71232/62">Post #61</a>
	                </div>
	            </div>
              <div id="likers-container-368212" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="368212"
                     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 #61"></div>
  </section>
</div>
    <div class="postbit" id="368266" data-post-id="368266">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’m aware of how they work but I’d suggest that it’s unlikely to be anything beyond user error <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"></p>
<p>DSLs are just elixir expressions, i.e</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">schema "schema" do
  field :foo, :string
end
</code></pre>
<p>Is, to tree sitter, just two function calls.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">schema("schema", do: field(:foo, :string))
</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="368266" 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/changes-to-the-struct-update-syntax/71232/63">Post #62</a>
	                </div>
	            </div>
              <div id="likers-container-368266" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="368266"
                     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 #62"></div>
  </section>
</div>
    <div class="postbit" id="368271" data-post-id="368271">
  <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">
								<p>No idea what happened a year or so ago then.</p>
<p>But you got me curious. I’ll check again in an Ash project. Bookmarking this.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="368271" 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/changes-to-the-struct-update-syntax/71232/64">Post #63</a>
	                </div>
	            </div>
              <div id="likers-container-368271" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="368271"
                     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 #63"></div>
  </section>
</div>
    <div class="postbit" id="377941" data-post-id="377941">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Sorry for necrobumping this thread. I only just saw this topic and wanted to post my 2 cents since this is planned to be revisited for v1.20. <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>
<p>It looks like a lot of the discussion around the struct update syntax is related to type inference/assertions/safety and how this affects the maintainability of a project. I regularly work in Typescript professionally, and I’ve also done a lot with static typing in Python and some C++, so I would like to add some perspective from other languages to the discussion in case its helpful since they can provide examples of non-obvious problems.</p>
<p><strong>tl;dr</strong></p>
<p>I think the struct update syntax as a type assertion has value for self-documenting code but would actually lead to extra maintenance burden over time. Offloading too much work to the type checker can have a significant impact on compile times, so it’s often not worth it when alternative patterns exist. If the removal of the direct struct update syntax can simplify the compiler architecture, this may make it easier for the compiler team to make more significant improvements in the future, but I’m not a compiler engineer so that’s just conjecture on my part.</p>
<p><strong>About type assertions</strong></p>
<p>My experience with static typing (particularly structural typing) is that developers tend to overuse declarative typing inline instead of defining proper interfaces around their functions and classes.</p>
<p>I fell in love with Elixir the first time I used it because it has incredibly expressive function declaration syntax. Being able to pattern match in the signature of a function and set an <code>@spec</code> that says the return value is a particular struct or has a particular shape like <code>{:ok, non_neg_integer()} | {:error, String.t()}</code> is sufficient for ensuring type safety throughout a program and also for human readers to know what to expect. If I’m calling a function, I only need to know what arguments it takes and what it is <em>supposed</em> to return. If I get something different out of it, that’s a bug in that function, and I can go and fix it or file a ticket with the team that maintains it.</p>
<p>If the compiler can determine that the return type is incorrect based on the function head via pattern matching, I can focus on defining my interfaces through the function signature and I don’t have to add a bunch of defensive type checking code in the body. And none of the consumers of my code need to care about what I’m doing inside that function either. This reduces the surface area of code that needs to be updated during a refactor as well, so the code is more amenable to change.</p>
<p>Complex or dynamic code that doesn’t use pattern matching or guards in the signature and can’t be verified by the type checker should be covered by a parametrized unit test. No amount of static analysis will make up for a missing unit or integration test for dynamic code.</p>
<p><strong>About maintenance</strong></p>
<p>The self-documenting nature of the struct update syntax inside a function body is definitely a real benefit, but it can also become a maintenance burden when updating data structures due to a refactor or after iterating on a core module and improving its design. Particularly if used in a conditional branch inside dynamic code.<br>
Something like this (not typesafe, just an example of the refactor cost):</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def conditional_func(x) do
  if (some_condition(x)) do
    %MyStruct{x | key: val}
  else
    :something_else
  end
end
</code></pre>
<p>If instead of the inline assertion, we used pattern matching in the function head for an overloaded function call like this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def conditional_func(x = %MyStruct{}) when some_condition(x), do: %{x | key: val}
def conditional_func(_), do: :something_else
</code></pre>
<p>That refactor would be a lot less painful since all of the updates related to that data structure would be contained in a single implementation of the <code>conditional_func</code> instead of spread throughout different conditional branches in function bodies. If the compiler can guarantee the same level of type safety in both versions, I see no reason to have the inline assertion via struct update syntax.</p>
<p>Another problem with moving more work into the type checker is that type checking is not free. Developers such as myself tend to treat the type checker and the compiler as a magic black box that has no cost since it’s not part of our application, but this is untrue. Compile/transpile/build times are a significant factor for DX. This is painfully obvious in large Typescript projects that do a lot of type inference. Build times are often abysmal past about 20k LoC, and they can actually impact a team’s ability to meet deadlines. This is particularly painful for R&amp;D programmers (which is mostly what I do) since we tend to do more exploratory coding and refactoring than is typical in regular application development. I love Elixir, and I really don’t want it to become anything like Typescript. <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>
<p>I’m not a compiler engineer, so I don’t know how accurate this all is, but I would think that removing a special case from the compiler code would open up a lot of possibilities for new optimizations. In application development, special cases always make iterating and improving difficult because we can’t just redesign a data structure or implement a new pattern. We have to add that one extra conditional to every new feature we implement to account for that legacy code path that no one has time to rewrite. And every time we do that we increase the cost of finally refactoring/rewriting since we now have one more piece of code that has to be updated during that work. I would think that even if the first-hand effect of removing the struct update syntax makes no real difference, the reduced cost of implementing new features and optimizations in the compiler will have a compounding effect on quality and speed over time.</p>
<p>Sorry, this got super long, but it’s a very interesting topic, and I hope this perspective is helpful in some way. <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="377941" 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/changes-to-the-struct-update-syntax/71232/65">Post #64</a>
	                </div>
	            </div>
              <div id="likers-container-377941" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="377941"
                     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 #64"></div>
  </section>
</div>
    <div class="postbit" id="377961" data-post-id="377961">
  <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="GrammAcc" data-post="65" data-topic="71232">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/grammacc/48/40380_2.png" class="avatar"> GrammAcc:</div>
<blockquote>
<p>I love Elixir, and I really don’t want it to become anything like Typescript.</p>
</blockquote>
</aside>
<p>FYI, I love your take. One of my top 3 complaints towards Rust are compile times. It can and does rid you of an entire class of bugs just by the mere virtue of the program compiling but I sometimes want to yell at my computer when a recompile takes 15 seconds.</p>
<p>I agree that correctness and DX must be balanced. Full support.</p>
<p>That being said, if I was forced to pick one of the two with a gun to my head, I’d still choose correctness.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="377961" 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/changes-to-the-struct-update-syntax/71232/66">Post #65</a>
	                </div>
	            </div>
              <div id="likers-container-377961" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="377961"
                     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 #65"></div>
  </section>
</div>
    <div class="postbit" id="378006" data-post-id="378006">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Yeah, most of my fear of compile times comes from C++. I actually had to buy a better laptop a while back because it took too long to compile Godot from source when I was trying to do small bug fixes. <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">   I agree that if I had to choose I would prioritize tooling to ensure correctness at compile time, but in this case, I’m arguing in favor of removing the struct update syntax because IIUC the compiler can still provide the same (or even better) guarantees with pattern matching in the function head or variable declaration instead of the inline type assertion, so in this case, the tradeoff is readability and not correctness.</p>
<p>Readability is often subjective, but poor readability can also can lead to incorrectness, so it’s an important factor to consider as well.</p>
<p>But I really do believe that Elixir’s pattern matching is powerful enough that this won’t become a problem in practice. It will definitely take some getting used to though.</p>
<p>If it turns out that we lose something significant on the correctness front by removing this inline assertion, than my vote would probably change.</p>
<p>I think it’s similar to how it took me a few weeks to stop looking for the word “return” in every function and just start reading them as self-contained blocks of expressions when I first started learning Elixir. <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="378006" 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/changes-to-the-struct-update-syntax/71232/67">Post #66</a>
	                </div>
	            </div>
              <div id="likers-container-378006" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="378006"
                     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 #66"></div>
  </section>
</div>
    <div class="postbit" id="378094" data-post-id="378094">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="GrammAcc" data-post="65" data-topic="71232">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/grammacc/48/40380_2.png" class="avatar"> GrammAcc:</div>
<blockquote>
<p>I think the struct update syntax as a type assertion has value for self-documenting code but would actually lead to extra maintenance burden over time. Offloading too much work to the type checker can have a significant impact on compile times, so it’s often not worth it when alternative patterns exist. If the removal of the direct struct update syntax can simplify the compiler architecture, this may make it easier for the compiler team to make more significant improvements in the future, but I’m not a compiler engineer so that’s just conjecture on my part.</p>
</blockquote>
</aside>
<p>This is a valid point, however i doubt this brings that much burden that it’s gonna slow anything to keep the syntax.</p>
<p>Especially so that it’s an opt-in feature. If, in my code, I’m using <code>%User{user | email: email}</code>, i’m okay to accept there’s gonna be a bit more compiler involved. If compile time becomes so much of a problem that I wanna make any improvement possible, I can always come back to it and convert those to <code>%{user | email: email}</code> and save these extra steps.</p>
<p>I see this a little bit as <code>@doc</code>, <code>@spec</code> or behaviours. You don’t need to use them, but you can if you want to improve documentation of your code and the readability at the cost of a bit more compile work (maybe not in prod, though).</p>
<p>By the way, we upgrade our app to 1.19.2 this week and it helped us uncover a couple of places where we were missing pattern match beforehand (where we only had struct update), the warning is a really nice improvement, we would have miss those bits if we weren’t using struct update syntax and only map update syntax. I love it how it is right now personally.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="378094" 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/changes-to-the-struct-update-syntax/71232/68">Post #67</a>
	                </div>
	            </div>
              <div id="likers-container-378094" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="378094"
                     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 #67"></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/71232/load_more?page=7">Load more posts (12 remaining)</a>
</div></template></turbo-stream>