<story><title>Rust is for Professionals</title><url>https://gregoryszorc.com/blog/2021/04/13/rust-is-for-professionals/</url></story><parent_chain><item><author>ahelwer</author><text>Here I am on day three of an attempt to modify a rust program with logic that would have taken about twenty minutes to implement in C# or Java. It has to do with operations on strings (use a regex to find a string in some text, escape all the regex-reserved characters in that string, then use the string as a regex to find other occurrences of itself in the text) so I get that I&amp;#x27;m really thrown into the borrow-checker deep-end, but man writing rust feels like working on one of those puzzles where you try to fit a set of tiles inside a rectangle. You&amp;#x27;ll almost get it but then some edge is sticking out. So you move the tiles around but this leads to two edges sticking out now! So you do a whole bunch of additional exploring before ending up right back where you started with the one edge sticking out.&lt;p&gt;I even abandoned the learn-by-stackoverflow-search approach to rust and read the first seven or so chapters of the rust book. But even that hasn&amp;#x27;t helped very much. I know I am just currently in the painful, frustrating stage of learning where nothing really makes sense, and at some future point it will all click, but it really can&amp;#x27;t be overstated just what a wicked learning curve this language has.</text></item></parent_chain><comment><author>hardwaregeek</author><text>I don&amp;#x27;t know if this helpful, but from your description of your problem, here&amp;#x27;s how I&amp;#x27;d do that in Rust:&lt;p&gt;- Use a regex to find a string in some text: use regexes, get a &amp;amp;str&lt;p&gt;- Escape all the regex reserved characters in that string: Okay this requires mutation but we can&amp;#x27;t mutate a &amp;amp;str, let&amp;#x27;s loop over the &amp;amp;str&amp;#x27;s characters (using the Chars iterator) and push them into a new String with the proper escapes&lt;p&gt;- The new String we own, so we can easily turn it into a regex and use it to search the original string.</text></comment>
<story><title>Rust is for Professionals</title><url>https://gregoryszorc.com/blog/2021/04/13/rust-is-for-professionals/</url></story><parent_chain><item><author>ahelwer</author><text>Here I am on day three of an attempt to modify a rust program with logic that would have taken about twenty minutes to implement in C# or Java. It has to do with operations on strings (use a regex to find a string in some text, escape all the regex-reserved characters in that string, then use the string as a regex to find other occurrences of itself in the text) so I get that I&amp;#x27;m really thrown into the borrow-checker deep-end, but man writing rust feels like working on one of those puzzles where you try to fit a set of tiles inside a rectangle. You&amp;#x27;ll almost get it but then some edge is sticking out. So you move the tiles around but this leads to two edges sticking out now! So you do a whole bunch of additional exploring before ending up right back where you started with the one edge sticking out.&lt;p&gt;I even abandoned the learn-by-stackoverflow-search approach to rust and read the first seven or so chapters of the rust book. But even that hasn&amp;#x27;t helped very much. I know I am just currently in the painful, frustrating stage of learning where nothing really makes sense, and at some future point it will all click, but it really can&amp;#x27;t be overstated just what a wicked learning curve this language has.</text></item></parent_chain><comment><author>ajross</author><text>That&amp;#x27;s where I always end up when I start playing with Rust too.  At this point I genuinely think I&amp;#x27;ve given up on belief that the &amp;quot;borrow checker&amp;quot; paradigm is ever really going to be broadly successful (vs. &amp;quot;screw it, just do it in &amp;lt;other managed language&amp;gt;&amp;quot;).&lt;p&gt;Problems with well-constrained allocation paradigms do really well in rust.  Problems with reading&amp;#x2F;parsing&amp;#x2F;storing messy data structures from external data just &lt;i&gt;really, really hurt&lt;/i&gt;.&lt;p&gt;I think a big part of the problem is that the ownership analysis layer has the dual crises of being (1) really complicated and too hard to keep in your head as a single model and (2) specified in an ad-hoc way that resists formal rules.  So eventually you end up in of those puzzles like you mention where... there&amp;#x27;s just no answer!  No one&amp;#x27;s been where you have, and the lack of rigor means you end up trying to reverse engineer the compiler front end trying to find the trick that works.  And then you give up and write it in Go or Python or whatever.</text></comment>