Live data from Hacker News

Huge no. of files for Angular 2

stackoverflow.com

71–80 of 105 posts

Re: Huge no. of files for Angular 2

#71

Earlier quoted context omitted.

> If there is a well written, well tested, and widely used micro-library out there that does one thing and does it very well, why not use it? Because every dependency comes with a cost. First of all, it needs to be available and the author might decide to pull it - maybe not from npm, but from github. Second is a matter of trust: Someone just needs to take over the left-pad authors npm account an all of a sudden he c…

I still maintain that those problems can be solved with better tooling and package management rather than "bundling" dependencies. Bundling to me is such a sledgehammer solution. Yeah, it can somewhat prevent many of those issues, but it also comes at a pretty large cost. * it leads to code duplication * it can ruin the performance of tree-shaking and minification systems * it prevents you from swapping out a small m…

I wasn't talking about bundling but rather about something like C glibc or rusts stdlib. Having a solid stdlib that covers for example string padding can at the same time minimize code duplication and number of dependencies.

Neither did I deny that inlining everything comes at a cost as well, so the goal is to find a good point on the scale. I was just pointing out that having tons of small dependencies is not free of cost.

Re: Huge no. of files for Angular 2

#73
post #46

Earlier quoted context omitted.

Instead of "50% in size" I'll assume "50% fewer dependencies", because I think that's the point here. I believe that creating a module without relying on other modules will likely lead to reinventing the wheel. Well, lots of wheels. However, that might still be fine. But what about that one corner case you missed? It might already be solved in a third-party module that focuses on one thing only. It's really not that…

This is the major part of the whole "left-pad" fiasco I don't get. If there is a well written, well tested, and widely used micro-library out there that does one thing and does it very well, why not use it? Even if you think you can re-implement it in 5 minutes, will yours be as fast? Will yours be as well tested? Will yours have an interface that many other developers already know and use? Sometimes reinventing the…

One reason is diversification.

If there are N ways to write a program, M of which are security hazards, it's better to have M/N of all programs exposed to risk than have a M/N chance that all programs are borked.

"Reinventing the wheel" is a leaky cliché: the problem at hand isn't that people would independently try to come up with the solution to a simple problem (rolling something down a hill), but that the instantiations of a solution would be irrevocably linked, such that one flat tire stops all cars.

What's more - jesus, go outside, look at how many kinds of skateboard wheels, car wheels, bike wheels you see in five minutes time.

Re: Huge no. of files for Angular 2

#74

Okay, but when you run the build process, how big is the resulting distributable?

My results of the hello world tutorial in Angular2 was 53 requests, 4933.49KB, and loaded in 1.74s on local dev, according to browser dev tools. All for one html file that had one h1 element.

Plus, it started out broken. I had to search elsewhere to find the solution to the error the tutorial produced.

Re: Huge no. of files for Angular 2

#75

Earlier quoted context omitted.

I still maintain that those problems can be solved with better tooling and package management rather than "bundling" dependencies. Bundling to me is such a sledgehammer solution. Yeah, it can somewhat prevent many of those issues, but it also comes at a pretty large cost. * it leads to code duplication * it can ruin the performance of tree-shaking and minification systems * it prevents you from swapping out a small m…

I wasn't talking about bundling but rather about something like C glibc or rusts stdlib. Having a solid stdlib that covers for example string padding can at the same time minimize code duplication and number of dependencies. Neither did I deny that inlining everything comes at a cost as well, so the goal is to find a good point on the scale. I was just pointing out that having tons of small dependencies is not free o…

Fair enough, but with a language like Javascript a large standard library will never be a reality.

There are too many implementations (by design) and the language is such a "mutt" of designs that it will never happen.

I personally don't think that's a bad thing, but it is different to how many languages work.

Re: Huge no. of files for Angular 2

#76
post #57

Interesting fact that I recently came across: bower and many other npm packages, has some dependencies that eventually depends on a package called "wordwrap". And this "wordwrap" package somehow has its test folder exposed in npm. The result: Every single person using bower would have one or more copies of In Praise of Idleness by Bertrand Russell on your local machine, depending on how many of your projects has a np…

I used to `touch node_modules/.metadata_never_index` to prevent Spotlight from wasting disk cycles by indexing that stupid folder. After searching "In Praise of Idleness", it doesn't seem to prevent it. :/ Anyone knows how to prevent all node_modules folders from getting indexed by Spotlight?

I ended up excluding the whole projects folder to prevent spotlight from indexing any source code. I never use spotlight to search any of my code anyway.

Re: Huge no. of files for Angular 2

#77
post #74

Okay, but when you run the build process, how big is the resulting distributable?

My results of the hello world tutorial in Angular2 was 53 requests, 4933.49KB, and loaded in 1.74s on local dev, according to browser dev tools. All for one html file that had one h1 element. Plus, it started out broken. I had to search elsewhere to find the solution to the error the tutorial produced.

That's not a production build.

Minify it, run dead code elimination. Exactly as you would with any other language with a compiler.

Also, worth noting that the tutorial being broken isn't symptomatic of JS, that's a problem with Angular (which has a history of sucking, and IMO Angular 2 just takes all of the problems with Angular 1 and adds more baggage to it).

Be aware as well that Angular 2 is a full-fledged Web Framework. Even after all of this compression and such, it is not going to be as lightweight as you'd expect simply due to the nature of what you've installed.

If you want something really lightweight, go with Rivets or React.

Re: Huge no. of files for Angular 2

#79
post #66
post #6

Earlier quoted context omitted.

It's actually not possible due to the way Node looks up dependencies. You could have a situation like: node_modules/ a/ node_modules/ c/ (1.0.0) b/ node_modules/ c/ (1.0.0) c/ (2.0.0) Both a and b depend on c version 1.0.0, but since there's a version 2.0.0 in the root node_modules folder c can't be placed there, and has to be duplicated in a and b's own node_modules folder, otherwise Node couldn't find it for each o…

I've built a fairly hacky solution to this before (for a different package manager) - it can be pretty simple: node_modules/ versions/ a@1.0.0 node_modules/ c -> ../../c@1.0.0 b@1.0.0 node_modules/ c -> ../../c@1.0.0 c@1.0.0/ c@2.0.0/ a -> versions/a@1.0.0 b -> versions/b@1.0.0 c -> versions/c@2.0.0

Some other people have linked to npm alternatives ied and pnpm which do essentially this.

Re: Huge no. of files for Angular 2

#80

Earlier quoted context omitted.

Not a lot better: $ unzip -l /usr/java/jdk1.8.0_77/jre/lib/rt.jar | wc -l 20138 It's just less of a burden on the host filesystem because those files are usually loaded straight from the jar (i.e. zip file).

JRE is a platform, so if you counting platform files, why not also counting NodeJS or browser sources too? I'd rather look at comparable thing like JEE server + Spring + some server-side renderer like Thymeleaf.

I'd argue that Angular2 is a platform as well.
Post reply on HN