The Rune Programming Language
~I love when I see programming languages who&#x27;s first advertised features are implementable in 8 lines of rust~<p>Edit: ^ the above had the wrong tone. Thanks to dang for pointing it out. What I meant to express was that it&#x27;s possible to accomplish a similar safety&#x2F;ergonomics at the library level in rust in not too many SLOC. My personal preference is towards Rust&#x27;s approach because the type system gives really powerful composable primitives which makes it possible to have the compiler check a wide range of invariants, instead of just the ones that are common&#x2F;special enough to go into the language itself<p>(Example edited after comments from mumblemumble)<p><pre><code>    &#x2F;&#x2F; The struct is public, but the contents are private, meaning you can&#x27;t directly access the secret once it&#x27;s inside the struct
    pub struct Secret&lt;T&gt;(T);

    impl&lt;T&gt; Secret&lt;T&gt; {
        &#x2F;&#x2F; The only public way to access the secret, returns a new secret
        pub fn map&lt;U&gt;(&amp;self, func: impl FnOnce(&amp;T) -&gt; U) -&gt; Secret&lt;U&gt; {
            Secret(func(&amp;self.0))
        }
    }
    
    impl&lt;T: AsRef&lt;[u8]&gt;&gt; PartialEq&lt;&amp;[u8]&gt; for Secret&lt;T&gt; {
        &#x2F;&#x2F; == does the correct thing (and only works for types that would make sense (`AsRef&lt;[u8]&gt;`)
        fn eq(&amp;self, other: &amp;&amp;[u8]) -&gt; bool {
            constant_time_eq(self.0.as_ref(), other)
        }
    }

    &#x2F;* Some other file *&#x2F;

    use secret::Secret;
    
    &#x2F;&#x2F; Translated from the example
    fn check_mac&lt;T: AsRef&lt;[u8]&gt;&gt;(mac_secret: Secret&lt;T&gt;, message: &amp;[u8], mac: &amp;[u8]) -&gt; bool {
        &#x2F;&#x2F; This returns a new Secret&lt;[u8; 32]&gt;
        let computed_mac = mac_secret.map(|secret| hmac_sha_256(secret.as_ref(), message));

        &#x2F;&#x2F; This uses the `constant_time_eq` impl from above
        computed_mac == mac
    }

</code></pre>
Edit: It looks like you can implment SOA as a macro too <a href="https:&#x2F;&#x2F;github.com&#x2F;lumol-org&#x2F;soa-derive" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;lumol-org&#x2F;soa-derive</a><p>Edit: mumblemumble helpfully points out I demonstrated this poorly, so I tried to better demostrate what I was going for in this comment <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=33764037" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=33764037</a>