r/node • • Jun 28 '21

Node.js humor

1.5k Upvotes

79 comments sorted by

3

u/yulistr Jun 29 '21

WOW, this post got 1k upvotes. Crazy numbers.

8

u/Cazineer Jun 28 '21

Ah yes, good old Node. This meme made me chuckle. Thanks for posting it.

After many years of navigating Node.js and its ecosystem (started pre 1.0) we switched from Node.js to Go, just over a year ago. Life has been so much better. It was like leaving an insane asylum. šŸ˜‚

5

u/[deleted] Jun 28 '21

Can you make a side by side side comparison?

9

u/Horyv Jun 29 '21

Left side: many problems

Right side: fewer problems

Please note that I’m a human being, and this is volunteer work. If you don’t like my work, then you can’t buy me a beer, and I don’t drink beer anyway and there’s a very strong chance that I might just go away on my own.

1

u/[deleted] Jun 29 '21

What about coffee?

6

u/CupCakeArmy Jun 29 '21

The go tooling is far superior. However the language is so stupidly restrictive. Go is all about lean, I get it. However with the lack of generics one has to write for loops just to check if something is an array. Function declaration gets super messy as you cannot overload. No ternary, no optional types, no union/sum types. Sure the Compiler ist fast, but because it's dumb af. So while Go ist nice, I would much rather code something in node.

1

u/Cazineer Jun 30 '21

You are correct about one thing, Go is very opinionated and that is one of the things that makes Go such a great language. Go is all about productivity. I can grab any Go library and understand it in a matter of hours. Node libraries are the exact opposite. With Node you have libraries written in a functional programming style, then the next uses an imperative style, then the next use an OOP style, then the next mixes them all together, then the next uses TS, and so on. Understanding larger libraries in Node can take a week or more compared to hours in Go. There is no consistency in the Node ecosystem. It’s literally a toxic wasteland.

Go is a proper statically typed language with a compiler, which drastically reduces the cognitive overhead when developing applications. TS is not a compiler, it’s a transpiller. You can’t pass a house to a function that takes a car because they have the same fields in a proper statically typed language.

Node applications are slow. VERY slow. There is no shared memory and no true threading model. Writing applications that share memory and maximize CPU cores is a breeze in Go. Node processes are single threaded. You can’t even compare the performance of a Node application to a Go application, Go applications are just on another level. It’s like a supercar vs a family sedan.

Go is a compiled language. You get a binary that you can deploy anywhere. You don’t need NPM or the Node installed. You build, deploy, done.

The Go standard library is very complete. On a large project I might have to use a handful of third party libraries. In Node, I’ve seen projects with thousands of third party libraries (dependencies), which is what this meme is all about.

Go doesn’t have generics currently but they are being added in the next major release so this is kind of a non issue and to be honest, after 10,000 hours of writing highly generic JS code in Node, at first I hated not having generics but I got over it really fast and it’s really just a minor inconvenience from time-to-time now. Using interfaces also solves 90% or more of the uses cases where you might need generics anyways.

The rest of the things you listed like a ternary operator are really trivial and really just personally preferences.

At the end of the day, you couldn’t pay me to return to Node. It’s Go for most uses cases and Rust when performance truly matters. The productivity, consistency, performance, the reduction in cognitive overhead, far superior tooling, etc, make Go a far superior language in 2021 IMO and I have like 10K hours in Node.

1

u/CupCakeArmy Jun 30 '21 edited Jun 30 '21

I like that Go is opinionated. There is one way to format and no need for discussion. This extends to code style and I agree that that is a generally good thing.

About the standard library.. not really. Both don't really have great standard libs. Go a notch more but it does not even come cose to python.

Your point on TS though is just plain wrong. If you turn all the strict checks in TS your app will be typesafe, that's not an opinion.Typescript is compiler. With the difference that it outputs JS and not binary and does not do optimization. But type safety is there. Of course most people don't even turn on strict null checks wich leads to confusion, but thats another issue.

Performance and especcialy parallelism in go are amazing, there is no way around it. While the GB can get in the way, for 99% of the people Go performance won't be an issue. That said, performance of servers is important but not the deciding factor. Few k18n nodes more in the balancer are waaay cheaper than engineers, so if all you are doing is building APIs and similar stuff performance is quite irrelevant.

At the end of the day it's proabaly personal preference as always.

10k also seems a bit much xD would mean 8/5 no breaks for 7,8years taking no vacation or sick leaves.

Edit: You said you where in the Node since pre 1.0 so 7 years makes sense xD

1

u/Cazineer Jun 30 '21

10K is allot I guess for an employee. I founded a startup in 2016 and we used Node. Over 2 years I logged over 9,200 hours @ 16 hours a day, 6 days a week. It wasn’t healthy but it was what had to be done at the time. At one point it in my life I was building a business and I took 1 day a month off to travel for 3 years. At the end of the 3 years my product was in thousands of industry leading businesses throughout North America and the industry leading competitor bought us out.

1

u/CupCakeArmy Jun 30 '21

Respect for that, hope you found some relief nowadays ā™„ļø

-1

u/yulistr Jun 28 '21 edited Jun 28 '21

I am with golang.

66

u/Secular12 Jun 28 '21

In 1 week:

You have 23456 vulnerabilites, 3421 High.

npm audit fix

*cross fingers*

7

u/am0x Jun 29 '21

This is why we have an internal npm library. I had a junior developer arguing with me about using npm component libraries over our own because it was easier. As a manager I let him have 2 projects using his stuff.

As of now all sites are on Vue 3 without much headache, except those. We spent weeks trying to transfer over, but all the npm packages don’t work and we have 70+ high vulns on each.

4

u/[deleted] Jun 29 '21

What are you doing that requires significant management of packages like this? I just do JSON REST APIs and React frontends. All the api needs is express, sequelize, and pg package. All the frontend needs is whatever create-react-app sets up (and assume they verify well before publishing a release)

1

u/Secular12 Jun 30 '21

TBF react front ends are generally more npm dependent than his choice of Vue. Idk ifI am respondeding to this simply because I have a Vue preference or not lol

67

u/chowchowthedog Jun 28 '21

I swear I have no idea what NPM was doing whenever I install npm packacges... I just cross my fingers and hope it works without giving me errors...

21

u/[deleted] Jun 28 '21

hours of learning throughout the years, tons of practice and yet am still vulnerable while installing npm packages

37

u/Koeke2560 Jun 28 '21

It's actually the one package manager I think is really straightforward.

I have so much PTSD from fucking with python/pip/python3/pip3/conda/venv. With npm it's basically do I need the -g flag or not.

10

u/n1ru4l Jun 28 '21

exactly my feel everytime I use pip... no lockfiles?!

5

u/neckro23 Jun 28 '21

Not to give pip the benefit of the doubt (I feel the Python ecosystem is kinda a disaster) but doesn't pip freeze do exactly that?

5

u/mixini Jun 28 '21

pip freeze > requirements.txt is not great, because it doesn't manage relationships between dependencies. poetry kind of solves this, but it's not nearly as ubiquitous as npm or yarn.

3

u/n1ru4l Jun 29 '21

we kinda do that and bump dependencies with renovate - still this is kind of weird and cumbersome. in the beginning we did not do this and regulary had issues with breaking changes from dependency dependencies 😩

14

u/AtroxMavenia Jun 28 '21

You almost never ever need -g

10

u/Koeke2560 Jun 28 '21

Basically only if you are installing some kind of cli which you use across projects.

6

u/AtroxMavenia Jun 28 '21

Yeah, and even then rarely. For example, eslint, I wouldn’t install it globally because I may need different versions in different projects.

2

u/zvive Jun 28 '21

I've noticed lately eslint init fails if you don't already have it in the project folder... So might as well run npm I eslint && npx eslint init...

2

u/mailto_devnull Jun 28 '21

I still don't understand why they can't just install all the binaries into a .bin folder in $HOME.

All they have to do is echo a line at the end of installing npm to say "paste this in your .bashrc to add the directory to your path"

3

u/Regis_DeVallis Jun 28 '21

Bundler and cargo are pretty straightforward too.

5

u/evert Jun 28 '21

The only package manager I've used that felt better was composer for PHP. They did lock files first too.

5

u/neckro23 Jun 28 '21

I don't know the actual history (just that Composer was first) but Composer seems like an NPM predecessor in a lot of ways. They work pretty similarly.

4

u/evert Jun 28 '21

Yeah, I think you are right. Composer at the time was a game changer, and when npm came along it felt strongly inspired by composer.

-7

u/asiraky Jun 28 '21

Yuck.

8

u/evert Jun 28 '21

Great contribution, thank you!

2

u/cadred48 Jun 28 '21

And between npx and npm scripts you almost never need the -g flag.

1

u/Like_A_Boushh Jun 28 '21 edited Jun 29 '21

I currently get a venv/anaconda path error that yells at me when starting up bash.

That’s nothing compared to the absolute hell that is rvm.

19

u/ruttino Jun 28 '21

Laughs in react-native project folder

5

u/SteveTheBiscuit Jun 28 '21

For real… mix in cocoapods in the mix too šŸ˜…

25

u/bkjojo1 Jun 28 '21

When you enter "npm install"

7

u/DepravedPrecedence Jun 28 '21

pnpm helps to minimize disk space impact of node_modules. Highly recommend it.

6

u/Senseistar86 Jun 28 '21

And a few months later, you'll have to dig through and update them when flagged by D-Track

6

u/zvive Jun 28 '21

I once ran a script for old code and side project ideas to clean out all node modules.... Goddamn I got rid of like 150gb just in node dependencies... Jesus why!

I wish you could somehow get webpack but use cdn as actual source and still use import es6 etc... Or at least have one global node modules folder and then Vue/2.56, Vue/2.57 so versioning isn't an issue but you only ever have one of everything....

3

u/TwiNighty Jun 29 '21

Or at least have one global node modules folder and then Vue/2.56, Vue/2.57 so versioning isn't an issue but you only ever have one of everything....

You have pretty much just described pnpm.

Modern yarn can also be configured to do something similar.

2

u/Hyoretsu Jul 15 '21

This. PNPM also runs 3x faster than Yarn/NPM for me.

1

u/Upbeat-Fly9656 Feb 26 '24

One of my project takes several minutes to install with yarn, and only about 5 seconds with pnpm when things are cached, really great and saves probably 10s of GB in storage over all my projects using it

2

u/FriesWithThat Jun 29 '21

Another thing people can do is run npx npkill in their projects directory.

This tool allows you to list any node_modules directories in your system, as well as the space they take up. You can then select which ones you want to erase to free up space. Yay!

3

u/LazaroFilm Jun 28 '21

isNull

3

u/[deleted] Jun 28 '21

is-number

3

u/HanzLuo Jun 29 '21

Need npm audit

3

u/am0x Jun 29 '21

I love and hate npm. There is too Much dependency on it for lower level FE devs, so it makes projects a mess.

However, using only well maintained packages where necessary are great.

4

u/johnslegers Jun 28 '21 edited Jun 28 '21

Those are loooooots of packages!

And this is why I've never been a fan of using package managers by default literally everywhere.

The less you look under the hood, the less you know how well-designed your motor really is...

Especially for small projects, manually managing your dependencies does have its perks, in the sense that you get a much better sense of how much bloat you're adding with each depencency!

3

u/[deleted] Jun 28 '21

How does this work with modern frontend dev?

4

u/johnslegers Jun 28 '21

You'd just manually drag-and-drop a folder with a dependency into your node_modules folder.

Or you create your own new one there.

You're not supposed to, because that's where npm puts the dependencies it gets for you at install time and the content of node_modules isn't supposed to maintained in any repo...

But it totally works fine.

And you can totally have your repo maintain node_modules if you want to.

But yeah, we've grown so accustomed to using package managers anywhere that there's really no authorized way to do it manually in node... not AFAIK... but it totally works fine if you do things this way...

4

u/[deleted] Jun 28 '21

Hmmm… I see your point, but I’d be curious to get some data (which I assume no one has) on the ROI aspect of this.

I agree with what you’re saying generally, but we don’t code in a vacuum. We code in the context of brutal cold capitalism. Meaning ā€œit worksā€ code is often just as good as ā€œreally good codeā€ in the sense that it makes the same amount of money.

This approach to me seems very time consuming and prone to issues, especially on boarding new engineers. Especially in the context or building yet another B2B sass product that’s basically just excell for a niche industry on the web lol.

Imo the only time this would make sense, from a business perspective, would be if what you’re writing is very critical and must be stable at all costs (finance, healthcare, anything where someone could die or lose their livelihood if the app fucks up).

I don’t want to come off like I’m saying it’s a bad idea. It’s not and I get your argument. I’m just not convinced it’s worth the time and money

I actually already do this kind of. I have a project that consumes a library, and when developing locally I sometimes have to build the library and then reinstall it in the main project. I used to build then npm install the built lib, but that took too long. So after building it, I would just copy it into my node modules dir and it was much faster haha

1

u/johnslegers Jun 29 '21

I agree with what you’re saying generally, but we don’t code in a vacuum. We code in the context of brutal cold capitalism. Meaning ā€œit worksā€ code is often just as good as ā€œreally good codeā€ in the sense that it makes the same amount of money.

Short term : yes. Long term : no.

The less you invest in the quality of your code, the more technical debt you accumulate. The more technical debt you accumulate, the more expensive your maintenance will become.

The longer your software needs to run, the more important it is to optimize the quality of your code ASAP, to keep technical debt at least at manageable levels...

This approach to me seems very time consuming and prone to issues, especially on boarding new engineers.

I remember the days when almost every PHP project out there that had any notoriety whatsoever was PSR-0-compatible. Back in those days, you could just manually copy-paste any PHP project into your project to be optionally used by any of your code with a single import.

If your project uses a few dozen dependencies at most and the code of your dependencies is stable enough they don't require to be updated all the time, this is IMO still by far the easiest approach.

PHP also took the package manager approach with Composer, though, and they messed it all up with PSR-4, which broke backwards compatibility with PSR-0 and made it a lot more difficult to create projects without package manager because PSR-4 favored configuration over convention.

1

u/[deleted] Jun 29 '21

Totally agree with you ideologically. In practice I have yet to see a successful company that has ā€œgoodā€ code. I think it’s pretty clear that ā€œgood enoughā€ Is more important from a business sense than ā€œgood codeā€.

All your points are valid, but don’t matter if you’re already the lead in the market. Meaning in a new space the one that can grow the quickest (the one putting out it just works code), will likely out compete the others. Changing platforms is a pain, and users are all too susceptible to the sink cost fallacy.

I’ve seen it so many times I’ve lost count. A popular company, been around a while, leaders in their space, code is shit but it works.

Again, I’m not saying that’s how I would want to do things. I think it sucks and makes our lives annoying, but my opinion doesn’t change the reality of the industry

1

u/johnslegers Jun 29 '21 edited Jun 29 '21

In practice I have yet to see a successful company that has ā€œgoodā€ code. I think it’s pretty clear that ā€œgood enoughā€ Is more important from a business sense than ā€œgood codeā€.

In practice, pretty much every company out there uses some form of Agile development these days. And, in my experience, Agile is great for prototyping because it allows for fast iteration of new features, but it's horrible for maintaining and updating an existing platform, because with every Agile project I've done this comes at a cost of a massive amount of technical debt.

I used to be employed in maintenance and development of LuciadRIA, a massive frontend JavaScript framework used for geospatial visualization. Originally, about a decade ago, LuciadRIA started out as a 2D-only partial port of the Java library LuciadLightspeed, built around the Dojo Toolkit. Gradually, it was converted into a fully standalone library with a WebGL component, supporting both 2D and 3D, developed partially in JavaScript and partially in C++ that was compiled to JavaScript with Emscripten. Now, can you imagine the technical debt you get with a project this old, this complex and this large?

Because technical debt is one of my pet peeves, one of the first things I pretty much decided to do on my own when I joined the company was stripping any remaining dependencies on Dojo, manually harmonizing the module format across the entire codebase and various similar improvements. The only reason I was allowed to do this, was because I had the freedom to experiment with technical debt cleanup rather than being put on projects where new features were developed due to still being pretty new in the company.

I did the harmonizing mostly because it makes code a lot more readable when every module is written the same way. And fewer dependencies means better optimizability. These changes also had an impact on other things, though. When I left the company, they were about to convert the entire library from AMD modules to ES6 modules. Just having a single AMD module format and no more Dojo depencency made AMD module conversion to ES6 module conversion a hell of a lot easier.

This harmonizing process I did still was a pretty massive enterprise, though, considering the number of modules involved, but precisely because there was no consistency in module definition and various other inconsistencies I fixed, the lack of consistency kept getting worse with every development cycle...

I’ve seen it so many times I’ve lost count. A popular company, been around a while, leaders in their space, code is shit but it works.

This is one of the reasons I'm considering leaving the industry as an employee and either create a business around a yet to develop software platform of my own or do something completely different!

In my experience, even in high tech companies where management actually contains civil engineers & other folks with a strong technical background, all too often the piling up of technical debt is ignored in favor of producing new features faster and business problems are consistently prioritized over technical problems. While I do understand where it's coming from, I find it very frustrating to work in an environment where technical problems are consistently ignored in favor of business problems, even though those technical problems continue producing more and more busness problems and other technical problems in the long run!

Even most very smart people seem to have become incapable of thinking long term these days...

1

u/[deleted] Jun 29 '21

Ideologically I’m on your side. I would love to be able to write good code, after good planning, in a fair time frame. But that’s just not the reality of the industry.

I’ve thought about doing my own thing as well, but the game Is played the way I described for a reason… that’s how everyone else plays. And if business bros are rihjt about anything, it’s that first to market, first with a new feature, etc gets the $$$. And that’s without getting into the whole exploitation aspect of having employees.

I have begun considering starting a coop or a worker owned enterprise with some people. But that would only resolve the exploitation aspect. To compete in the market, it’s likely we would make a lot of those same compromises.

It’s not like business people are stupid, it’s mot that they don’t understand when you tell them tech debt is bad.

I also don’t think it’s a lack of being able to think long term. Like I said now, they’re mot stupid. But the way our market works is well this way. Not to mention that the goal of the industry has changed dramatically. People used to want to build their own thing and grow it into an empire. Now tech has been monopolized by a few players, and the goal for most companies is to get bought by one of those players.

Or for example how VC firms operate. They buy a bunch of companies, hope one of them gets big, if not they polish the turd and try to flip it to another firm.Ʊ (6year ownership average i believe).

The fact is the game has become all about appearances and inflating your perceived worth; not about building good products or services.

The profit motive has corrupted and ruined tech. It’s no longer some geeks trying to build cool shit. It’s business people trying to squeeze the most money out of us as possible.

Thank you capitalism! I joke, i fucking hate capitalism

1

u/johnslegers Jun 29 '21

I would love to be able to write good code, after good planning, in a fair time frame. But that’s just not the reality of the industry.

And, as I said, that's one of several reasons I'm considering leaving the industry altogether;

I love programming as a hobby, but I've come to hate it when doing it professionally as an employee. Sure, the pay is decent, but somehow the way software projects are run I still feel more like a the high tech equivalent of a slave, just with manual labor replaced with intellectual labor. And, at least for me, that sucks the fun out of it entirely!

I’ve thought about doing my own thing as well, but the game Is played the way I described for a reason… that’s how everyone else plays.

Just because something is more popular doesn't mean it is better.

To compete in the market, it’s likely we would make a lot of those same compromises.

You will probably have to make at least some compromises. But giving tech people more control of tech decisions would be a good start. Making technical debt a priority would be a good start. As would be dropping Agile methods like Scrum.

The reason Agile is called Agile is it's supposed to provided agility, but it's become the very opposite. Real life Agile has become nothing more than just one of several methods business people use to try to control tech people and to force them to prioritize poorly!

Be lower-a agile, not capital-a Agile, I say!

It’s not like business people are stupid, it’s mot that they don’t understand when you tell them tech debt is bad.

Business people pretty much ALWAYS underestimate the impact of technical debt. They don't understand how piling technical debt on technical debt reduces the budget available for everything else with every iteration, which is why it's almost always ignored.

They always push technical debt issues forward as something that can be fixed later because it has no business impact, but it does. A steady but gradual reduction of the budget remaining for everything but technical debt with every iteration is a pretty critical business impact if you ask me, unless your platform is the kind of platform that requires little to no maintenance and rarely gets new features!

The fact is the game has become all about appearances and inflating your perceived worth; not about building good products or services.

True.

But the worse this gets, the greater the chances are for competitors that actually do do things right. End customers in particular still tend to prefer products with the best value for money!

The profit motive has corrupted and ruined tech.

There's nothing wrong with profit per se. But when short term profit becomes the key priority, things can get messed up pretty fast!

The profit motive has corrupted and ruined tech. It’s no longer some geeks trying to build cool shit. It’s business people trying to squeeze the most money out of us as possible.

The only way to change this, is for geeks to say "no more" and do better with their own businesses by creating better products at lower cost!

2

u/lars-by-the-sea Jun 28 '21

Amen. And it honestly is very unnerving.

1

u/starcoder Jun 28 '21

Reminds me of the old file tree

1

u/[deleted] Oct 15 '21

1

u/[deleted] Jun 28 '21

Still prefer this to the mess of packages in python, or go

0

u/[deleted] Jun 28 '21

[deleted]

5

u/[deleted] Jun 28 '21

How does databunker relate to this?

0

u/[deleted] Jun 28 '21

[deleted]

9

u/DepravedPrecedence Jun 28 '21

Interesting, what's your field?

22

u/shortround10 Jun 28 '21

They have a comment from 25 days ago that says ā€œI’m new to Nodeā€, lol. Those are just the first two packages they’ve come across in tutorials.

0

u/[deleted] Jun 28 '21

[deleted]

5

u/Suepahfly Jun 28 '21

left-pad, is-even, is-odd. that’s what’s wrong with the eco-system. But I’m not about to write my own fetch-library with caching, re-fetch, aborts or my own date utilities.Also at the larger, multi-team companies I worked at there was a bigger focus on package dependencies and tech. dept that the smaller ones.

5

u/shortround10 Jun 28 '21 edited Jun 28 '21

There is a huge difference between your original comment and having a pragmatic concern for dependency bloat.

The downvotes are because you acted like you had a ton of experience in Node with only having needed ESLint and Electron. It’s hyperbole and unhelpful.

3

u/vexii Jun 28 '21

que? šŸ™ƒ

4

u/SODOMIZE_ME_CAPN Jun 28 '21

found the junior engineer

3

u/micaww Jun 28 '21

That's a horrible habit to get into. Using 3rd party libraries aren't "an excuse for laziness or lack of programming ability", they allow developers to focus on what matters in a product, and that is business logic.

Deciding which libraries to use is a different process, and depends on your project's needs:

  • Does size matter? Likely yes if sending over the network to a client

  • How many people use it / how well is it supported? Important for determining possible vulnerabilities and long term support

"Corps" don't stay away from using dependencies either. They help increase their engineers productivity and generally overall product stability.

0

u/[deleted] Jun 28 '21

[deleted]

5

u/zvive Jun 28 '21

Does the std lib have all the es6 features without babel, db bindings for mongo, MySql, postgres, redis, and a way to bundle without webpack or parcel with tree shaking, and handle routing and creating a server?

Not ragging just feel that doing all that without using packages which is like 60 to 80 percent of a web app.... Would require basically reinventing the tire...

Plus ui and state management...I mean there's lighter tools like Alpine but it's still nice to have something with good two way binding etc...

0

u/[deleted] Jun 28 '21

[deleted]

1

u/zvive Jun 29 '21

I've mostly used express, or fastly for server...the latter being way superior... but I'm a laravel/vue/tailwindcss dev and I have a love/hate relationship with packages, but laravel-mix makes webpack super easy, and I'd rather just not have to think about everything that goes into my build and just work on stuff.. :) -- I'd like to do more work w/ go though actually... gofiber is an amazing server stack.