r/webdev • • May 18 '25

Discussion I wonder why some devs hate server side javascript

I personally love it. Using javascript on both the server and client sides is a great opportunity IMO. From what I’ve seen, express or fastify is enough for many projects. But some developers call server side javascript a "tragedy." Why is that?

193 Upvotes

254 comments sorted by

View all comments

887

u/c-digs May 18 '25 edited May 18 '25 • All-Seeing Upvote Bless Up

You haven't done it at scale in a serious enterprise context.

Build and CI

  • In CI, we frequently have issues with 4GB build runners running out of memory while building JS
  • We're using TS so we also randomly run into issues with type recursion and depth at build crashing out and requiring explicit type hacks
  • Because of the lack of runtime types, it also means our CI is more rigorous and requires more expensive build cycles (more tests, more artifact generation for runtime schemas, etc.) and thus CI takes longer. Again, you don't run into this with toy and side projects so it doesn't matter.
  • Current TS tooling is slow (TS 7 will speed this up!) so it's excruciatingly slow at scale to build large TS projects in CI

Lack of Types at Runtime

  • If you care about data integrity, you'll need schemas and validators to make up for the lack of runtime types. 
  • That means A LOT of extra drudge work writing Zod, et al
  • This is actually because JS has very limited runtime types and type introspection compared to typed runtimes
  • This is also why OpenAPI is pretty much "free" on other platforms and something you have to explicitly address on Node (e.g. via Zod, class-validator, some other type of manual spec definition).  I'm taking C# as an example, but I only need to add the OpenAPI middlewares and runtime introspection will generate my OpenAPI without additional effort
  • If you're doing it at scale, then you're doing TypeScript (or JSDoc typing which is just extra baggage) and that creates a lot of extra drudgery when working in a multi-package environment to export and manage types in a workspace. While it doesn't seem like much, compare that to Java or C# where there's no extra work to use types across packages

Performance and Throughput

  • Node is also slow and low throughput so you need more servers to handle the same load at scale (can be as much as double compared to Go or .NET or Java)
  • Adding Zod, class-validator at your routes just makes them even slower (and significantly so). I have done some testing and depending on the size of the model if you are using Zod, you are looking at something like 100-125ms cost on some routes we have.

    • I only started a cursory look at this issue today after noticing a route that was returning a static JSON file was taking 200ms.....
    • Removed the Zod and it was a fraction of that....
  • Source generators in langauges like C# mean that you can have dev+build-time generated serializers that are extremely fast. There is one equivalent in Node that I know of which is build-time (Typia) but otherwise, Zod is runtime and is always going to be slow for basic serialization
  • For compute intensive routes, Go, C#, Java make multi-threading easy to reach for and use to boost performance

DX and Power of Language/Platform Tools

  • Other languages have macros or source generators like C#'s Roslyn that can reduce a lot of boilerplate code
  • The lack of source generators/macros combined with the lack of runtime type introspection means that the JSON serialization/deserialization process is not nearly as powerful nor as fast as other platforms. 
  • JS ORMs are pretty much universally bad or lacking compared to more mature solutions.  Try .NET's EF Core and the Node options just look like toys.  (Though shout-out to Kysely.dev on the read side; well done!)
  • One reason is that the language does not expose expression trees as first class objects so all ORMs require you to express those valid paths either structurally or as strings whereas in a language like C#, you can use an expression instead and your ORM queries become much, much more terse and legible. For example, this is a valid, fully-typed Entity Framework ORM query condition statement: .Where(user => user.Email.EndsWith('example.org') && user.IsActive) because this is an expression tree in C# and the expression tree can be parsed into SQL statements at runtime.
  • Another is that there is no standard transaction library so different ORMs run different transactions whereas in a runtime with a common TX library, you get true ambient transactions.  Why is this important?  ORMs are often better for the write side while query builders are better for the read side where maximum flexibility is needed.  But you cannot mix these in ambient transactions in Node because they are not truly ambient.
  • Basic day to day ergonomics are a tragedy with dozens of lines of imports at the top of files. This kind of stuff is normal in JS/TS
  • Then on the flip side, stupid barrel files!
  • The fact that modules are file-based versus namespace based means that it is not ergonomic to break up big modules (barrel files) compared to just sharing a virtualized namespace
  • If you happen to be using classes (e.g. Nest.js) it takes discipline to keep your class from becoming massive 1000+ line files.  C# for example, has partial classes that make this easy to organize (e.g. big controllers or sevices)

Compliance and Security

  • The lack of runtime types means that any code operating in a more compliant environment needs schema validators (because JavaScript will allow you to assign a string to a number variable at runtime without complaint)
  • Let's not forget about node_modules and supply chain accounting (e.g. for compliance like SOC2). A platform like .NET ships with a huge first party standard library ecosystem which makes this much, much easier to do since depenencies are minimal. To get a picture of just how bad this is in Nodeland, check out the State of the Octoverse 2020 Security report (download all 3 and check out the security one and issues with CVEs and supply chain attacks in NPM).
  • In enterprises, it is much, much easier to audit a platform like .NET where so much of the baseline code is first party standard and base class libraries shipped from Microsoft in Microsoft namespaces.
  • JavaScript's dynamic type system also allows for a class of supply chain attacks that are not possible on runtimes like Java, Go, and .NET/C#

I can go on and on.  I use JS and TS for my personal and side projects, but at scale it is a tragedy for any serious work even in a mid sized team.  I'm using it at work now at a series C startup with some 20 (?) BE engineers and it is absolutely hell every day dealing with massive piles of Zod schemas, perf issues, CI issues, and everything else I listed.

C# is close enough to JS (https://typescript-is-like-csharp.chrlschn.dev/) that I'd prefer it in the backend beyond toy projects.

Bottom line is that developers who get too comfortable with JS and aren't using it in an enterprise context don't know what they are missing with other platforms and really need to broaden their horizons. You like JS on the backend because you don't know what you don't know. If you want to overcome that ignorance, try another backend platform and start a blog, podcast, or Vlog so you can educate others why Node.js is absolute, bottom-of-the-barrel sludge for serious, enterprise backend work.

27

u/LakeInTheSky May 19 '25

Thank you for mentioning the lack of types at runtime. This is very important and people don't talk much about it.

I've been working as a front-end dev for many years now, but my first languages were C++ and Java. When TypeScript appeared, I liked it, but I knew it could never fully solve the lack of type checking for JavaScript.

→ More replies (5)

82

u/AshleyJSheridan May 18 '25

If I had an award to give I would, this answer covers everything incredibly well. I really find the lack of a decent well-built framework to be a massive problem as well. Like you said, the ecosystem of C# has this built in, but even other typical server-side languages have well established mature frameworks that put the Javascript offerings to shame.

37

u/c-digs May 18 '25

Just trying to make sure folks are educated 👍

A lot of people simply don't know what they don't know and can't know it until they've felt the pain or worked on a project at scale. I've worked with JS for over 20 years now so I've seen it at every stage of its growth. I know what I would use it for and what I would not use it for.

More folks need to broaden their horizons and just try different platforms for the sake of learning and self education. With LLMs and AI copilots nowadays, it's easier than ever.

→ More replies (3)

29

u/tsunami141 May 18 '25

Thanks for writing this up! This is great.

13

u/divad1196 May 19 '25 edited May 19 '25

That's a long comment to say: "You need ultra speed, it's not good! Types are important" without considering for 1 second the context.

The post mentions javascript, but we can easily assume typescript as well. So here are the types.

We don't always care about high performance, so go down your high horses with the "you never done it at scale in big companies". A good dev takes the context into consideration, only beginners always jump on the fastest techs. There are many projects done in javascript and are fine.

For the security, you are also just giving one side of the story. Supply chain attacks happens everywhere, remember log4j? You have native random library, great but is it cryptographically safe? Etc... if you just consider the OWASP20 list, that concerns mostly all languages. I am not saying javascript is safe, I am saying that any language is equally as bad, maybe in it's own way.

For the CI, you again mostly focus on the duration/speed. The heaviest jobs happen once the MR exists. With proper flow, it doesn't run that often. It's not that slow or bottersome compared to what is needed with C/C++.

All languages have their pros and cons, including javascript. But you have a narrow vision. I wouldn't say that javascript is the best choice at scale, but it's not as bad as you mention, you just never used it professionally while you did with C#. And the most important thing: most projects are small.

5

u/leixiaotie May 19 '25

If ultra performance and runtime type is a consideration, use golang (or maybe rust), not C#. Everything's a tradeoff

→ More replies (2)

4

u/shruest May 18 '25

I wish to be able to reach this level of detail someday to understand what this is

RemindMe! 1 year

10

u/c-digs May 18 '25

🤣 You just have to have really burning hate for JavaScript backends used in an enterprise context at scale. I hate it so much, I think about why I hate it every day I run into an issue with it. I think to myself "how can I take this pain away?" Sometimes there are solutions (e.g. Typia), other times, there are none and my hatred simply accumulates in a well deep inside of me and spills out into Reddit, blog posts, whole websites, my co-workers, LinkedIn, my spouse (much to her chagrin).

→ More replies (2)
→ More replies (1)

4

u/cyclotron3k May 19 '25

Very well written - absolutely nailed it. I think you also need a section on how unstable the 3rd party package ecosystem is, and how 50% of your dependencies will have critical vulnerabilities by the end of the year, 25% will no longer be maintained, and you'll be dealing with breaking changes all the time. The larger your project, the higher the maintenance burden is.

People often say languages with small standard libraries are a good thing, for reasons. But I don't think it ever stacks up. The void is always filled with a huge variety of 3rd party options that all suffer from the same problems as above. And a large enough JS project will end up including them all.

→ More replies (1)

4

u/overcloseness May 19 '25

I agree with all of this, but, the whole “toy and side projects” thing irks me. It sounds like you equally are pigeonholed into the one thing you seem to know about, “serious enterprise”. The world of online development is vast and some projects have tight deadlines and shelf lives, not everything is run as a long term product.

Node.js is fine for like 90% of what people need backend for, and strictly speaking probably higher than that. You likely use it every day if you’re an average internet user.

I’m from a C++ background and have recently been using Rust, but Node.js is a no brainer if you consider business needs outside of microsecond return times. I think Node.js is the wrong choice if you’re looking for scalability and longevity. That doesn’t mean it’s a bad choice.

→ More replies (1)

7

u/xaraca May 18 '25

But I already know Javascript /s

7

u/mattaugamer expert May 18 '25

Unfortunately this is the answer. :(

3

u/KingCrunch82 May 19 '25

They were told they are "Full-Stack" and can do everything. So, yeah, exactly this

22

u/JohnCasey3306 May 18 '25

Long story short, just because you can use JavaScript doesn't mean you should.

You'll select JavaScript if you don't have access to a more appropriate tool.

3

u/thekwoka May 19 '25

At least it isn't python :kek:

3

u/0aky_Afterbirth_ May 19 '25

All great points here. The team I work on builds and maintains enterprise backend services for software that has several million daily active users, and about 90% of our codebase is Typescript, and we’ve run into pretty much every single issue that’s called out here.

I like TypeScript as a language, but for enterprise backend services, it just doesn’t scale well, in pretty much every way (development, CI, and runtime).

We continue to use it because our team has, in recent years, more experience with TS than any other language, and we’ve invested thousands of lines of code in common internal TS utils and tooling for our organisation (several of our front end teams use TS as well), so it would be prohibitively expensive and time consuming to migrate most of our services to another language.

But know what we know now, TypeScript is just not the best tool for the job for our enterprise backend APIs.

I predict that sometime in the near future, we’ll reach the tipping point where TS becomes the bottleneck in terms of overall performance/cost optimisation (taking the TS refactor cost into account), and we’ll have no choice but to start rewriting.

→ More replies (2)

18

u/[deleted] May 18 '25

I appreciate your thoughts on the lack of runtime types. I've been surprised how many developers think TS is actually a language and not essentially an opinionated linter. I almost prefer not to use it and insist on unit tests guaranteeing essential type safety because TS gives so many devs a false sense of security.

26

u/c-digs May 18 '25

"False sense of security" is a great way to put it.

Devs are sometimes surprised to learn that:

type Cat = {
  sounds: 'meow' | 'hiss' | 'purr'
}

async handleCat(cat: Cat) {
  // Do cat things
}

Will readily and happily accept this payload at runtime without a schema check:

type Gem = {
  hardness: number
}

Can be dicey when the backend is a document-oriented database!

3

u/thekwoka May 19 '25

Will readily and happily accept this payload at runtime

yeah, but if you are doing the static analysis, how do you have this happen?

4

u/c-digs May 19 '25

Runtime: via an API payload, loading data from storage like S3, loading data from a backend database storing JSON like Postgres jsonb. If you're application only has static data, it's not doing much, is it?

→ More replies (23)

10

u/30thnight expert May 18 '25

This is a great response.

For addressing some of the warts listed:

  • node supports typescript type stripping now - which can be used to reduce your tooling requirements (or just use bun/deno)
  • modern validation libraries adhere to the standard spec and can be used interchangeably. This is useful because modern api servers like hono.js support automatic openapi codegen from your validation schemas like this (Arktype and Zod v4 are great options)
  • in cases where performance is your primary concern, consider your validation library to Typia (the fastest feature complete system I know that doesn’t require writing validation schemas and supports its own openapi spec generation - benchmark
  • use a monorepo structure with NX to share types across domains / packages.
  • for small apis that only have a single JS based consumer, consider using tools like orpc or trpc.
  • for sql orms, very little can compete with EF core but for what we’re talking about - I highly recommend using Drizzle.
  • for package security, many companies I’ve been at used snky.io for dependency checks. Others would mirror packages in our internal setup (GitHub packages or Artifactory). In 2025, I’d advise people to avoid packages that don’t publish provenance data and use checks like this: https://github.com/actions/dependency-review-action

asp.net, golang, and elixir are my choices for most usecases but I personally would choose typescript before ruby or python for general crud work.

10

u/c-digs May 18 '25

You and I think alike.

You might like this deck I put together recently: Nestia + Typia + Kysely which to me is a really, really good stack on Node.js.

→ More replies (3)
→ More replies (42)