As a JavaScript developer I find the stupidity versus opportunity cost virtually impossible to distinguish. After all, its how I involuntarily became a developer in the first place.

I was hired by Travelocity late in 2007 to be a designer. In early 2008 I was a UI developer and if I wanted to continue to be employed I would have to figure it out. JavaScript developers, at least competent ones, were nearly impossible to find, so it made sense for the company to convert me into a developer instead of struggling to hire somebody who probably couldn't do the job anyways. Keep in mind this is before jQuery became popular, before JavaScript became fast, and before massive MVC frameworks did your entire job for you. Competent JavaScript developers were nearly impossible to find for what companies were willing to pay. Also, keep in mind that at that time JavaScript developers earned about half what a Java developer earned but had a wider distribution of responsibilities to account for. My incompetence that first year writing logic was a profitable opportunity cost to the employer.

As an aside I can remember Google Web Toolkit (GWT) from that time. It would compile Java logic to JavaScript, which was great for barely competent Java developers who couldn't figure out JavaScript. The compiled JavaScript was garbage though. The logic was a mess that often broke. The people who generated that code were afraid of it and hid from it leaving nobody to own or maintain it. It was like some horrid combination of pride, insecurity, hubris, and negligence rolled up in a ball. Was this an opportunity cost or just stupid, it is a challenge to distinguish.

Fast forward to modern times and people who write JavaScript are easy to find and are paid much better. Actual JavaScript developers are still almost as rare though. Most people who write JavaScript are not actually JavaScript developers, but rather something like: Angular, React, or Vue developers. They do not write original code, but supplement a framework. If you put a gun to these guys heads and told them they had to write an application without their favorite framework they would happily take the gun from you and shoot themselves in the face. They have no idea what the DOM is, how to architect anything, and in many cases writing any original logic scares them to death.

In many cases people who write JavaScript have absolutely no idea what to write, so they only write browser facing single page applications, because that is the preference of their pet framework. To be fair some of the React developers might possess some vague half notion about the DOM, but they would call it a virtual DOM and get angry when I ask them to find "virtual DOM" in the standard DOM specification. In fact many technical requests that are explicitly outside the immediate documentation of their favorite pet framework might make these developers immediately angry (inwardly insecure). This folly is commonly known and accepted as an opportunity costs so employers set the expectations very low and don't ask for such things. The stupidity and incompetence are also distinguished by hiring employers during hiring and candidate selection whether they are looking for a Node.js developer or a UI developer even though its all the same language.

The better pay and frequent incompetence are opportunity costs, because somebody has to write this code. The business need is present and so factors are adjusted to ensure delivery of necessary business solutions while reducing hiring risks. It made sense to hire people who could get by just writing minimal logic over a framework tool, because developers are interchangeable assets of the business that come and go rapidly in the marketplace. When there is a shortage of talent you take what you can and ensure it is commonly replaceable. It should also be stated the conditions for hiring developers were well in the developers' favor because the business need was clear and businesses could afford to hire more people while enjoying the longest running bull market in history.

I suspect, though, this party is over. We now exist in a period of rapid economic contraction unlike anything in history. Before the recent bull market developers primarily existed to provide automation. The value of most developers was in the reduction of expenditure on the employer's internal operating costs. During this bull market that value became lost as the lines between automation and product creation frequently blurred. Regardless employers just knew they need people to write code and could happily afford it.

COVID has put many developers out of work and economists are anticipating the economic hardships will continue for about 2 more years. From a business perspective developers are expensive cost centers. Developers do not add to the revenue of the employer. They only exist to substitute business expense for automation. The people who actually generate revenue are called something like sales, marketing, or merchandising. So, for a hiring manager of a business struggling to stay afloat why would they hire 12 barely competent people who write a few lines of code here and there for a framework SPA when instead they could hire 2 or 3 developers at a slightly hire rate that focus on automation in general? In other words the safe expectation moving forwards is to expect that developers will require more from fewer developers or will find a completely different medium with which to engage their users/clients. With many developers suddenly out of work talent is no longer rare.

The opportunity costs have drastically changed in response to market pressures. The employers who will most rapidly adapt their hiring and use of developers are those under greatest financial pressure. The employers who are currently safe from market pressures, whether by their essential status or cash liquidity, will not feel this pressure and will become the new dinosaurs as they retain older and less efficient ways of shipping products.