• squaresinger@lemmy.world
      link
      fedilink
      arrow-up
      9
      ·
      19 hours ago

      On the one hand, tree shaking is often not used, even in large corporate projects.

      On the other hand, tree shaking is much less effective than what a good compiler does. Tree shaking only works on a per-module basis, while compilers can optimize down to a code-line basis. Unused functions are not included, and not even variables that can be optimized out are included.

      But the biggest issue (and one that tree shaking can also not really help against) is that due to the weak standard library of JS a ton of very simple things are implemented in lots of different ways. It’s not uncommon for a decently sized project (including all of the dependencies) to contain a dozen or so implementations of a padding function or some other small helper functions.

      And since all of them are used somewhere in the dependency tree, none of them can be optimized out.

      That’s not really a problem of the runtime or the language itself, but since the language and its environment are quite tightly coupled, it is a big problem when developing on JS.

      • Caveman@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        7 hours ago

        “Mature ecosystem” it’s called in JS land.

        I wish nodejs or ecmascript would have just done the Go thing and included a legit standard library.