Dynamic Swift
The posts in the first linked series (<a href="http:&#x2F;&#x2F;inessential.com&#x2F;2016&#x2F;05&#x2F;" rel="nofollow">http:&#x2F;&#x2F;inessential.com&#x2F;2016&#x2F;05&#x2F;</a>) seem to mostly focus on how dynamism can avoid the need for boilerplate.  For example, he states that the following code is tedious to write and error-prone:<p><pre><code>    if localObject.foo != serverObject.foo {
      localObject.foo = serverObject.foo
      changeDictionary[fooKey] = serverObject.foo
    }
    if localObject.bar != serverObject.bar {
      localObject.foo = serverObject.bar
      changeDictionary[barKey] = serverObject.bar
    }
</code></pre>
But there&#x27;s another language feature that can replace boilerplate, <i>without</i> dynamism and its associated performance and type safety penalties.  A feature that&#x27;s reviled by many, and was omitted from Swift, but serves this purpose perfectly: macros.  What if you could write this?<p><pre><code>    macro_rules! merge {
        ($localObject:expr, $serverObject:expr, ($($prop:ident),+)) =&gt; {
            $(
                if $localObject.$prop != $serverObject.$prop {
                    $localObject.$prop = $serverObject.$prop;
                    changeDictionary[stringify!($prop)] = $serverObject.$prop;
                }
            )+
        }
    }
    merge!(localObject, serverObject, (foo, bar, baz));

</code></pre>
Actually, this is valid Rust code, as you might have guessed if you know that language.  I picked it because it has similar syntax to Swift and a powerful, hygienic macro system.  (This case is simple enough that a C macro would also work fine without any ugly arcane stuff - you&#x27;d have to have a separate macro invocation for each property, but whatever.  But Rust&#x27;s system scales better to slightly more complicated scenarios.)<p>Admittedly, not everything you can implement with dynamism is as easy to replace with macros.  Many things are essentially impossible with the simple pattern matching language used above.  In Rust, there is also the option to write a compiler plugin that can do arbitrary-ish things with ASTs, so almost anything is <i>possible</i> with enough work, including things you can&#x27;t implement with dynamism, but fiddling with AST transformations is hairy enough that boilerplate looks a lot more attractive, relatively speaking.<p>Even so, I bet macros would satisfy most of the people advocating for &quot;Dynamic Swift&quot;.  And for the people who hate them - do you really think doing crazy things at runtime is any safer or easier to understand?  It&#x27;s certainly slower.<p>(By the way, you can implement dynamism with macros.  For example, you could autogenerate functions like &#x27;setProperty(name: String, val: Any)&#x27; that switch on the name and do the appropriate casting and such.  Though depending on your attitude, you might consider this crucial enough that it should be built into the language.)