Gnarly Learnings from June 2023
Tags: typescript, ruby, architecture, rails
Published: 2023-06-30 19:18:49

At The Gnar we are always reading, watching, and listening in order to keep our skills sharp and our perspectives fresh. Here are some of the resources we learned from this month.


## [Understanding TypeScript’s Newest Keyword: `using`](https://www.totaltypescript.com/typescript-5-2-new-keyword-using)

One of the reasons I appreciate TypeScript’s place in the Node.js ecosystem is how they approach incoming JS proposals, and how eager and willing they are to bring these new advancements to the ecosystem early enough to get excited, but late enough to trust it. `using` is a reflection of the upcoming ECMA TC39 proposal for more explicit handling of “temporary” connections (DB executions, file handlers, etc), and since it has made it far enough to be eventually adopted into JS proper, TypeScript is more than happy to prepare me by adopting it now. 


## [Backtick Strings vs `URLSearchParams`](https://spin.atomicobject.com/2023/06/05/javascript-backtick-strings-wrong/)

The title of the article linked above is a _little _clickbait-y but hey, I read it and I am glad I did. The React documentation provides an example of building a URL string to query an API using template literals or “backtick strings”. However, as the author correctly points out, this is not the best tool for the job. Template literals will _work _but aren’t made for creating serializable strings. For that, we have <code>[URLSearchParams](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)</code>, which will properly escape parameter values, among other things.


## [Removing Active Storage Objects via Form POST](https://github.com/rails/rails/pull/48339)

Gone are the days of needing to reach for clunky conditionals to massage Active Storage-related params when using direct uploads! Previously, to remove an Active Storage object from a record it would need to be explicitly set to `nil`. This was all well and good until you would try to do it on form submission and receive an error because the passed value in the `params` was _actually_ an empty string. Now, setting the value to `nil` or an empty string yields the same result. 🎉


## [The Gateway Pattern](https://mattbrictson.com/blog/gateway-pattern)

Especially on large projects, my services directory admittedly ends up looking a bit like a junk drawer. So, if you’re like me and wrap all external API communication in service objects, you’ll be glad you found this article. A gateway is used to formalize the boundary between your app’s domain and an external API, translating between the two. This is more specific and nuanced than how I typically use service objects, and helps clean up the codebase.


## [Shopify’s Ruby LSP in VSCode](https://shopify.engineering/improving-the-developer-experience-with-ruby-lsp)

I was shopping around for a simpler way to auto-format my Ruby code with minimal extensions and config. In my research I came across the Ruby LSP (Language Server Protocol) created by Shopify, who maintain one of the most well-known commercial Rails monoliths. This article describes the LSP and the VSCode integration of it, but it also includes a nice dive into LSPs in general.


## [Stack Overflow Releases Their 2023 Developer Survey](https://survey.stackoverflow.co/2023/#overview)

Here at The Gnar, we love a good developer survey. Admittedly, this is my first experience with the one released by Stack Overflow (SO). There are a bunch of interesting takeaways but I loved reading about how Postgres is now the most loved, admired, _and_ popular relational database (this is true here at The Gnar too - we have a whole [series](https://www.thegnar.com/blog/history-tracking-with-postgres) on some of its lesser-known features). SO also includes a new section on the prevalence of AI search tools where ChatGPT (unsurprisingly) is sitting pretty with 83% of professional respondents leveraging it in the past year.


## Contributors:

* [Alex Jarvis](https://github.com/alxjrvs)
* [Ethan Fertsch](https://github.com/efertsch)
* [Mike Stone](https://github.com/mikestone14)
* [Taylor Kearns](http://github.com/taylorkearns)


_Learn more about how The Gnar [builds software](https://www.thegnar.com/software-development)._