<story><title>Why use Rust on the back end?</title><url>https://blog.adamchalmers.com/why-rust-on-backend/</url></story><parent_chain><item><author>dijit</author><text>&amp;gt; I really like using Diesel because it generates all your SQL queries for you, from a typed SQL schema that it generates from your SQL migrations.&lt;p&gt;Fair that the author says that this is their opinion, however... I can&amp;#x27;t agree.&lt;p&gt;Maybe I&amp;#x27;m too stupid, but for me SQLx is the real killer crate when it comes to databases.&lt;p&gt;Everything, from the migrate macro, to the way it validates at compile-time the types in the DB, feels (to me) very ergonomic.&lt;p&gt;Diesel, by contrast, I spent so long trying to set up and I never really understood the three different files that need to somehow be in sync and generated. I just never really grokked the &lt;i&gt;split&lt;/i&gt; of these files and when to run the diesel-cli commands...&lt;p&gt;but SQLx is great, I often lament that there isn&amp;#x27;t anything comparable in Golang.</text></item></parent_chain><comment><author>necubi</author><text>We originally used SQLx but eventually moved away for a couple of reasons:&lt;p&gt;* The sqlx::query! macro is a neat hack, but the fact that it calls out to a database in a proc macro is pretty insane. It significantly slows down compilation with a lot of queries, and doesn&amp;#x27;t work reliably with rust-analyzer.&lt;p&gt;* Inconsistent handling of nullability that would regularly break compilation&lt;p&gt;We now use Cornucopia (&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;cornucopia-rs.netlify.app&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;cornucopia-rs.netlify.app&amp;#x2F;&lt;/a&gt;) which I think is a much better approach. You write your queries in a separate SQL file, alongside annotations that let you specify nullability. A standard build.rs integration performs codegen from that, which means compilation itself doesn&amp;#x27;t require a DB and IDE features work well. It also lets you share data types between queries which reduces boilerplate significantly.</text></comment>
<story><title>Why use Rust on the back end?</title><url>https://blog.adamchalmers.com/why-rust-on-backend/</url></story><parent_chain><item><author>dijit</author><text>&amp;gt; I really like using Diesel because it generates all your SQL queries for you, from a typed SQL schema that it generates from your SQL migrations.&lt;p&gt;Fair that the author says that this is their opinion, however... I can&amp;#x27;t agree.&lt;p&gt;Maybe I&amp;#x27;m too stupid, but for me SQLx is the real killer crate when it comes to databases.&lt;p&gt;Everything, from the migrate macro, to the way it validates at compile-time the types in the DB, feels (to me) very ergonomic.&lt;p&gt;Diesel, by contrast, I spent so long trying to set up and I never really understood the three different files that need to somehow be in sync and generated. I just never really grokked the &lt;i&gt;split&lt;/i&gt; of these files and when to run the diesel-cli commands...&lt;p&gt;but SQLx is great, I often lament that there isn&amp;#x27;t anything comparable in Golang.</text></item></parent_chain><comment><author>adamch</author><text>Hello, author here. My coworker Olivia (of &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;losslessbits.com&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;losslessbits.com&amp;#x2F;&lt;/a&gt;) really likes SQLx, I haven&amp;#x27;t personally used it though. I&amp;#x27;d love to try it for a future project, as long as it can help typecheck my SQL queries.</text></comment>