19
10Dev
4y

How I wasted my Sunday:

A programmer I know claimed that his Nodejs app was lightweight since it only relied on 2 dependencies (express and mongodb)

So I wrote a script to recursively transverse the npm dependency tree and count the number of dependencies there actually is

Installing those 2 packages alone means your app depends on 73 pieces of software in total

In conclusion, nothing written in Node is ever lightweight

Oh yeah, it was also Easter I guess

Comments
  • 2
    It's just that you know these dependencies, Those are popular and obviously "Big" dependencies, you can't expect it to be a 10KB App.
  • 5
    Ah yes I love these tutorials "Get started with X with just 10 lines of code!" (by installing 100MB of dependencies)
  • 1
    An honest question:
    Isnt that the same as going through your package.lock.json? I am baffled that these two I often use myself have that many dependencies. Or does your count include node modules that are included?
  • 1
    And btw thats not a wasted sunday at all. You can reuse that script maybe and include it in your pipeline which is a great insight when expanding your app.
  • 3
    Might be useful for this kind of job: https://bundlephobia.com/
  • 4
    You only looked laterally. You should also look vertically.

    NodeJS runs on a JS engine (likely v8), which runs a virtual machine, which runs on an abstraction layer in the OS, which runs on several more abstraction layers, which runs on abstractions over the hardware, which in turn runs assembly — which the cpu translates into microcode, which finally runs on the hardware.

    If you want something “lightweight,” write it in C or Assembly, and only rely on whatever libraries you must.
  • 2
    Lightweight...

    The term itself is a ridiculous statement.
  • 0
    Imagine using Node and saying you've written something lightweight, jfc
Add Comment