<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: theScottyJam</title>
    <description>The latest articles on DEV Community by theScottyJam (@thescottyjam).</description>
    <link>https://dev.to/thescottyjam</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F652440%2F1d7308b0-3cc9-49bc-a9b9-2fbb86c3865a.jpeg</url>
      <title>DEV Community: theScottyJam</title>
      <link>https://dev.to/thescottyjam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thescottyjam"/>
    <language>en</language>
    <item>
      <title>The "write code you can read at 3am" phrase (and similar variations) is getting a little old. Sometimes it's better for code to be more complex if it helps DRY it. I'm glad we don't blindly DRY everything anymore, but the opposite extreme is also bad.</title>
      <dc:creator>theScottyJam</dc:creator>
      <pubDate>Sat, 27 Dec 2025 22:20:38 +0000</pubDate>
      <link>https://dev.to/thescottyjam/the-write-code-you-can-read-at-3am-phrase-and-similar-variations-is-getting-a-little-old-19e9</link>
      <guid>https://dev.to/thescottyjam/the-write-code-you-can-read-at-3am-phrase-and-similar-variations-is-getting-a-little-old-19e9</guid>
      <description></description>
      <category>discuss</category>
      <category>programming</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>"exceptions are for exceptional behavior" makes no sense. People realize that "exceptional" means "uncommon", right? If you find out people rarely use a particular feature, you go in and change the code path to an exception, and vice versa? I hope not.</title>
      <dc:creator>theScottyJam</dc:creator>
      <pubDate>Tue, 12 Aug 2025 14:38:22 +0000</pubDate>
      <link>https://dev.to/thescottyjam/exceptions-are-for-exceptional-behavior-makes-no-sense-people-realize-that-exceptional-means-5d0h</link>
      <guid>https://dev.to/thescottyjam/exceptions-are-for-exceptional-behavior-makes-no-sense-people-realize-that-exceptional-means-5d0h</guid>
      <description></description>
      <category>softwaredevelopment</category>
      <category>software</category>
      <category>discuss</category>
    </item>
    <item>
      <title>"multi-paradigm" language is a bit of a mis-nomer that implies explicit support for many paradigms, letting you pick your favorite to use. A better name is "no-paradigm-in-particular". They mix ideas from different paradigms and expect you to do the same.</title>
      <dc:creator>theScottyJam</dc:creator>
      <pubDate>Sun, 13 Apr 2025 21:48:16 +0000</pubDate>
      <link>https://dev.to/thescottyjam/multi-paradigm-language-is-a-bit-of-a-mis-nomer-that-implies-explicit-support-for-many-paradigms-57cj</link>
      <guid>https://dev.to/thescottyjam/multi-paradigm-language-is-a-bit-of-a-mis-nomer-that-implies-explicit-support-for-many-paradigms-57cj</guid>
      <description></description>
      <category>programming</category>
      <category>discuss</category>
    </item>
    <item>
      <title>In Defense of Using Large Frameworks for Small Problems</title>
      <dc:creator>theScottyJam</dc:creator>
      <pubDate>Mon, 10 Feb 2025 00:03:53 +0000</pubDate>
      <link>https://dev.to/thescottyjam/in-defense-of-using-large-frameworks-for-small-problems-57n6</link>
      <guid>https://dev.to/thescottyjam/in-defense-of-using-large-frameworks-for-small-problems-57n6</guid>
      <description>&lt;p&gt;This article is actually quite unlike me - I'm usually someone who advocates against using tools or dependencies when you don't really need them. Stay away from micro-libraries, just copy-past something you find online instead. You probably don't need Lodash in your project - &lt;a href="https://thescottyjam.github.io/snap.js/#!/nolodash" rel="noopener noreferrer"&gt;I even made a webpage full of built-in ways to replace every individual Lodash functions with native JavaScript counterparts&lt;/a&gt;. But when it comes to frameworks, well, the irony of it all is that even though my little webpage is just static content, I still used a larger framework, and I don't regret it.&lt;/p&gt;

&lt;p&gt;There's been a growing outcry against using frameworks on small problems, especially static webpages, and I'm grateful that this pushback exists to help us remember there's other options out there, but if I'm being honest, in many scenarios, the other options just aren't that great. Let's discuss some of them.&lt;/p&gt;

&lt;h2&gt;
  
  
  No Framework
&lt;/h2&gt;

&lt;p&gt;There are two main things that frameworks give you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A templating system, to let you easily build a tree of HTML, sanitizing your data before inserting it to help prevent XSS attacks.&lt;/li&gt;
&lt;li&gt;A reactive system that allows the DOM to be automatically updated based on changing data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without a framework, what would normally be a trivial item can quickly escalate into a complicated, error-prone task. Want to see what I mean? Try making a function without a framework where, every time you call it with a list of user objects, it will render or rerender a table of users. The user objects can be as simple as &lt;code&gt;{ "id": 123, "name": "Cookie monster" }&lt;/code&gt;. Did you do it? Did you do it &lt;em&gt;right&lt;/em&gt; - if you have content selected when this update function gets called, will it stay selected? If you were to add checkboxes to each row, would the checkboxes stay checked after a rerender? Without a framework, a task like this takes quite a bit of intense code. With a framework? Well, in React's case:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;UserList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some other frameworks may have a bit more boilerplate required to define a component, but they all let you perform this actual task in a relatively terse and easy-to-read fashion.&lt;/p&gt;

&lt;p&gt;The opposing voice might argue that bringing this sort of thing up is unfair - framework-less development should only be done on static content, to which I would respond that it's more nuanced than that.&lt;/p&gt;

&lt;p&gt;My Lodash replacement's page only has static content, but it could grow to be more interactive over time. For example, at the moment I display all examples in JavaScript, but one day I could choose to add a toggle option to let you view the examples in TypeScript instead, or perhaps a button to display unit tests for the code samples, and so on. An otherwise static webpage can grow and receive interactive behaviors over time. If the website's content was written as a bunch of traditional HTML pages without components, then each time I needed to add these kinds of dynamic behaviors, I would need to do refactor quite a bit to componentize pieces of the webpage so it can support those new behaviors. Even some of the existing behaviors wouldn't be possible if I didn't organize the code by components - when you click on a Lodash function, it'll quickly fade content in using a pop-over side-panel. It doesn't require a full page reload. Perhaps in many scenarios this kind of SPA-like behavior is overkill, but for this webpage, I explicitly wanted users to feel as little friction as possible when navigating between different the different Lodash function alternatives.&lt;/p&gt;

&lt;h2&gt;
  
  
  Web Components
&lt;/h2&gt;

&lt;p&gt;Just use Web Components! They're like frameworks, except native!&lt;/p&gt;

&lt;p&gt;No, they're not.&lt;/p&gt;

&lt;p&gt;Remember from earlier the two things I mentioned that frameworks give you?&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;A templating system, to let you easily build a tree of HTML, sanitizing your data before inserting it to help prevent XSS attacks.&lt;/li&gt;
&lt;li&gt;A reactive system that allows the DOM to be automatically updated based on changing data.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;Yeah, Web Components don't do either of those things. The vision is that one day they would, and I can't wait for a future where JavaScript has the most important parts of frameworks built-in, but that day isn't today.&lt;/p&gt;

&lt;p&gt;Today, what web components give you is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;encapsulation, which is admetidly pretty nice, although they're still working out a couple of kinks related to accessability.&lt;/li&gt;
&lt;li&gt;A standard way to define a components so different frameworks can talk to each other, which kind of works, but it is also such a pain to define components this way, use these components, and interop with them. In many cases, it would actually be easier to just make your own ad-hoc component design than using web components. The issues are, in part, because they're trying to mimic the behavior of native HTML elements, and native HTML element lifecycle-management and data-passing is actually quite complex. Now that we get to define native-like elements, we get to inherit all of that complexity, and since frameworks get to interop with them, they too inherit the same complexity. Loads of fun.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Anyways, lots has already been written on this subject, so I won't dwell on it further.&lt;/p&gt;

&lt;h2&gt;
  
  
  Server side rendering
&lt;/h2&gt;

&lt;p&gt;...is limiting.&lt;/p&gt;

&lt;p&gt;Some of the afore-mentioned tasks that are difficult to do without a framework are completely impossible with traditional server-side rendering. Again, consider how I would dynamically populate a pop-up side-panel with content - how would you do that with server-side rendering? An iframe perhaps? That would be quite the hack for an everyday task.&lt;/p&gt;

&lt;p&gt;And again, things like being able to toggle between JavaScript and TypeScript examples would, what, require a full page reload and a dedicated URL?&lt;/p&gt;

&lt;p&gt;Then there's the fact that this is a &lt;em&gt;GitHub page&lt;/em&gt;. GitHub pages, like many other platforms, only lets you host static files. It's much more difficult to find a place that's willing to run your server-side code for you unless you're willing to pay a monthly fee, and I'm not about to do that for a project this small.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's wrong with frameworks anyways?
&lt;/h2&gt;

&lt;p&gt;As mentioned before, I do like to reduce dependencies when reasonably possible. Each dependency you add is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Bloat, as you might be depending on a lot more than what you really need. Tree-shaking doesn't always fix this issue - it isn't magic.&lt;/li&gt;
&lt;li&gt;Another security hazard - dependencies are often changing owners than going rogue.&lt;/li&gt;
&lt;li&gt;A maintenance burden - if you need to use some of the latest features from a dependency, you'd also need to update, which means dealing with breaking changes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If the benefit of adding the dependency is relatively little, than perhaps it's not worth it. For example, I personally don't see any real reason to install Lodash when the most-used functions are now native functions and the remainder aren't too difficult to just copy from the internet and use. I recognize that there's a maintenance cost associated with copying code and everything, but ultimately, I still favor writing code without Lodash. The amount of time Lodash saves you, all things considered, is typically in the order of minutes or seconds, at least that's been my own experience thus far. On the other hand, opting to go without a framework can cost you many hours of work if future feature requests come in that your framework-less codebase can't support very well.&lt;/p&gt;

&lt;p&gt;I also want to add that frameworks aren't inherently as bloated and slow as people make them out to be. Most bloat that you feel when using a React/Angular/Vue/some-other-SPA-framework comes from the webpage being developed with no thought for performance in mind, not from the framework itself. Tell those developers to build something without a framework, and they will still build something that will feel similarly sluggish. On the other hand, take performance-minded individuals and ask them to use a SPA framework to build a webpage, and it's going to be blazingly fast.&lt;/p&gt;

&lt;h2&gt;
  
  
  Concluding remarks
&lt;/h2&gt;

&lt;p&gt;I'm not trying to preach the opposite extreme here. There are still many, many scenarios where you really should go without a framework and choose one of the other options available. Use your own judgement and some common sense. My main point here is to simply say that, just because your website is small or mostly static, does not automatically mean going frameworkless is best, despite what the current popular opinion may be saying.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>webcomponents</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Just 'cause something throws an error, doesn't mean you need to catch it.</title>
      <dc:creator>theScottyJam</dc:creator>
      <pubDate>Fri, 07 Feb 2025 06:09:01 +0000</pubDate>
      <link>https://dev.to/thescottyjam/just-cause-something-throws-an-error-doesnt-mean-you-need-to-catch-it-495o</link>
      <guid>https://dev.to/thescottyjam/just-cause-something-throws-an-error-doesnt-mean-you-need-to-catch-it-495o</guid>
      <description>&lt;p&gt;Good code has good error handling. Error handling involves the use of &lt;code&gt;try&lt;/code&gt;/&lt;code&gt;catch&lt;/code&gt;. Therefore, anytime you suspect an error might be thrown, you should &lt;code&gt;catch&lt;/code&gt; it. And once you've caught an error, you... um... well, I guess you log it out?&lt;/p&gt;

&lt;p&gt;My goal is to convince you to be ok with letting errors go uncaught, regardless of what kind of environment you are coding in. We'll discuss a small handful of environments, but the general idea extends to any environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Browsers
&lt;/h2&gt;

&lt;p&gt;What is the problem with the error handling in this code?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.refresh-button&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;redrawRecords&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetchRecords&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Failed to fetch records:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lets start by asking - do you know what the browser will do if you let an error go uncaught? It'll log it out. So why are we bothering to catch the error and log it when that's exactly what the browser was going to do anyways? You can toss the &lt;code&gt;try&lt;/code&gt;/&lt;code&gt;catch&lt;/code&gt;, it's just extra noise.&lt;/p&gt;

&lt;p&gt;You might argue that the &lt;code&gt;console.error()&lt;/code&gt; is adding some valuable context - it's informing you that the error happened while we were trying to fetch records. But that too is redundant, you already have easy access to that same context by looking at the stack trace. If an error really did happen while attempting to fetch records, you will see the function name &lt;code&gt;fetchRecords()&lt;/code&gt; in the stack trace, which gives you the exact same context.&lt;/p&gt;

&lt;p&gt;In this specific scenario, an even better solution would be to notify the user when an error happens, but when that's done, don't feel ashamed to rethrow that error and let the browser handle logging it out for you.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.refresh-button&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;redrawRecords&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetchRecords&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;informUserOfError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Node Servers
&lt;/h2&gt;

&lt;p&gt;What's wrong with the error handling in this Node server code?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;sendEmailToUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;emailOpts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To give some context, when an error goes uncaught in Node, the entire process will crash. But remember, &lt;em&gt;this was an intentional design decision&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The idea is that once an unknown error happens, your server will be left in an unknown state, and the best thing you can do is to let it crash, then automatically spin up a new server in a clean state. This philosophy, however, only works if all of these conditions apply to you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your code is crash-ready. You never have a scenario where you're blindly doing &lt;code&gt;await writeThing1(); await writeThing2()&lt;/code&gt;, because the server might crash between those two async steps and leave your saved data in an invalid state. In the ideal world, you would be writing robust code anyways that accounts for the fact that a crash can happen at any point in time anyways, but the reality is that you, like many people, might not be writing code to that kind of standard.&lt;/li&gt;
&lt;li&gt;Any dependencies you might use should also be crash ready in the same fashion.&lt;/li&gt;
&lt;li&gt;You should have auto-restarting set up, so when your server does crash, it'll automatically bring itself back up. Ideally, you would have a cluster of instances running at the same time, so one of them crashing wouldn't cause any real downtime.&lt;/li&gt;
&lt;li&gt;Say someone find a particular set of inputs they can give to one of your endpoints, to cause an uncaught error to happen and your server to crash. Is there anything stopping this person from sending a request, every few seconds, to this endpoint, and causing your servers to repeatedly crash, preventing anyone else from using your services? You will need to have protection in place against these kinds of exploits.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you agree with Node's default error-handling philosophy and are writing the kind of enterprise code that can support it, then stop trying to fight the philosophy with your code by trying to catch and log every error imaginable. When something unexpected happens, let your process crash.&lt;/p&gt;

&lt;p&gt;If you're not running a server that can support this kind of unexpected crashing, then Node's default behavior will actually do more harm than good for you. There's a simple solution. Just throw the below code snippet somewhere in your codebase - it'll catch all uncaught errors and log them out, effectively making the default uncaught error behavior match that of a browser.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;uncaughtException&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you are in the habit of catching and logging every error in Node to prevent Node from crashing, then you are effectively hand-implementing the behavior of the above code snippet, in a tedious, error-prone fashion.&lt;/p&gt;

&lt;h2&gt;
  
  
  Libraries
&lt;/h2&gt;

&lt;p&gt;If you're a library author, you can't necessarily globally configure Node to log uncaught errors instead of crashing - it's not your place to make that kind of decision. But that's ok. When things go wrong in the internals of your library, it's your responsibility to make sure those errors become uncaught errors, and it's the consumer of your library's responsibility to decide what to do when unexpected issues happen (whether that's crashing Node, logging the issues to stderr, or something else entirely). Don't try and take that choice away from the consumers. Let your unexpected errors go uncaught.&lt;/p&gt;

&lt;h2&gt;
  
  
  Concluding thoughts
&lt;/h2&gt;

&lt;p&gt;As always, take everything being said with a grain of salt. While, in general, it's ok to let errors go uncaught, there are specific scenarios where preventing errors from bubbling up is a good thing. In some cases, catching errors just to log them is the best option available. I won't go over the nuances on when these scenarios may or may not be appropriate, instead, I just ask that you use your judgement, and to not be afraid to consider uncaught errors as a valid option as you weigh your options.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>node</category>
    </item>
    <item>
      <title>Embrace complexity</title>
      <dc:creator>theScottyJam</dc:creator>
      <pubDate>Thu, 14 Nov 2024 15:25:00 +0000</pubDate>
      <link>https://dev.to/thescottyjam/embrace-complexity-oi0</link>
      <guid>https://dev.to/thescottyjam/embrace-complexity-oi0</guid>
      <description>&lt;p&gt;There seems to be this ever-present mantra in our programming culture to keep things as simple as possible. We hear it manifest in several different ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;KISS (keep it simple stupid)&lt;/li&gt;
&lt;li&gt;YAGNI (You ain't gonna to need it)&lt;/li&gt;
&lt;li&gt;Don't over-engineer&lt;/li&gt;
&lt;li&gt;Avoid "accidental complexity"&lt;/li&gt;
&lt;li&gt;Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live.&lt;/li&gt;
&lt;li&gt;Code for readability.&lt;/li&gt;
&lt;li&gt;etc&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are good, solid piece of advice, but I worry that some of us (me included) may have been taking this rhetoric too far. What have we been sacrificing at the alter of "simplicity"? Are we avoiding powerful design patterns because they might make the code harder to read? Are we staying away from various tools and libraries because of their learning curve? Conversely, are we hanging on to tools or libraries that we have long outgrown because we are worried about the added complexity of a home-grown solution? Are we avoiding adding features that would really benefit the end-user, because it would require the team to do a complex task (such as building a DSL parser, implementing a technical specification, etc)? Perhaps you can see real value in applying certain philosophies like the hexagonal architecture, dependency injection, the CQRS patterns, railroad programming, etc, but what would the next set of maintainers think? Will they just rewrite it all to be simpler?&lt;/p&gt;

&lt;p&gt;Many of these worries are justified to some degree, but that doesn't mean we should always limit ourselves to only picking the simplest options, because, well, that's pretty limiting. Instead, perhaps as a community we need to take a step or two away from the "keep everything simple" philosophy. Life is complex. Programs are complex. Your job is complex. That's ok.&lt;/p&gt;

&lt;p&gt;So don't feel bad for introducing complexity into a codebase when the complexity is justified.&lt;/p&gt;

&lt;p&gt;Be less judgemental when entering a new codebase. Everything is going to feel complex and abstracted in odd ways. Resist the impulse to rewrite it all, instead, start by walking a mile or two in the previous maintainers' shoes, coding in the fashion they intended you to code in. You might learn a thing or two.&lt;/p&gt;

&lt;p&gt;Embrace complexity.&lt;/p&gt;

&lt;p&gt;Embrace simplicity.&lt;/p&gt;

&lt;p&gt;Balance.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>softwareengineering</category>
      <category>softwaredevelopment</category>
    </item>
  </channel>
</rss>
