aboutsummaryrefslogtreecommitdiff
path: root/content/2020-03-30-my-love-and-hate-relationship-with-nodejs.md
diff options
context:
space:
mode:
authorMitja Felicijan <m@mitjafelicijan.com>2023-07-08 23:25:41 +0200
committerMitja Felicijan <m@mitjafelicijan.com>2023-07-08 23:25:41 +0200
commitcd6644ea4ddc78597934ab0ef5ba50e3c3daa927 (patch)
tree03de331a8db6386dfd6fa75155bfbcea6b4feaf3 /content/2020-03-30-my-love-and-hate-relationship-with-nodejs.md
parent84ed124529ffeee1590295b8de3a8faf51848680 (diff)
downloadmitjafelicijan.com-cd6644ea4ddc78597934ab0ef5ba50e3c3daa927.tar.gz
Moved to a simpler SSG
Diffstat (limited to 'content/2020-03-30-my-love-and-hate-relationship-with-nodejs.md')
-rw-r--r--content/2020-03-30-my-love-and-hate-relationship-with-nodejs.md111
1 files changed, 111 insertions, 0 deletions
diff --git a/content/2020-03-30-my-love-and-hate-relationship-with-nodejs.md b/content/2020-03-30-my-love-and-hate-relationship-with-nodejs.md
new file mode 100644
index 0000000..dec6f8d
--- /dev/null
+++ b/content/2020-03-30-my-love-and-hate-relationship-with-nodejs.md
@@ -0,0 +1,111 @@
1---
2title: My love and hate relationship with Node.js
3url: my-love-and-hate-relationship-with-nodejs.html
4date: 2020-03-30T12:00:00+02:00
5type: post
6draft: false
7---
8
9Previous project I was working on was being coded in
10[Golang](https://golang.org/). Also was my first project using it. And damn,
11that was an awesome experience. The whole thing is just superb. From how errors
12are handled. The C-like way you handle compiling. The way the language is
13structured making it incredibly versatile and easy to learn.
14
15It may cause some pain for somebody that is not used of using interfaces to map
16JSON and doing the recompilation all the time. But we have tools like
17[entr](http://eradman.com/entrproject/) and
18[make](https://www.gnu.org/software/make/) to fix that.
19
20But we are not here to talk about my undying love for **Golang**. Only in some
21way we probably should. It is an excellent example of how modern language should
22be designed. And because I have used it extensively in the last couple of years
23this probably taints my views of other languages. And is doing me a great
24disservice. Nevertheless, here we are.
25
26About two years ago I started flirting with [Node.js](https://nodejs.org/en/)
27for a project I started working on. What I wanted was to have things written in
28a language that is widely used, and we could get additional developers for. As
29much as **Golang** is amazing it's really hard to get developers for it. Even
30now. And after playing around with it for a week I felt in love with the speed
31of iteration and massive package ecosystem. Do you want SSO? You got it! Do you
32want some esoteric library for something? There is a strong chance somebody
33wrote it. It is so extensive that you find yourself evaluating packages based on
34**GitHub stars** and number of contributors. You get swallowed by the vanity
35metrics and that potentially will become the downfall of Node.js.
36
37Because of the sheer amount of choice I often got anxiety when choosing
38libraries. Will I choose the correct one? Is this library something that will be
39supported for a foreseeable future or not? I am used of using libraries that are
40being in development for 10 years plus (Python, C) and that gave me some sort of
41comfort. And it is probably unfair to Node.js and community to expect same
42dedication.
43
44Moving forward ... Work started and things were great. **Speed of iteration was
45insane**. For some feature that I would need a day in Golang only took me hour
46or two. I became lazy! Using packages all over the place. Falling into the same
47trap as others. Packages on top of packages. And [npm](https://www.npmjs.com/)
48didn't help at all. The way that the package manager works is just
49horrendous. And not allowing to have node_modules outside the project is also
50the stupidest idea ever.
51
52So at that point I started feeling the technical debt that comes with Node.js
53and the whole ecosystem. What nobody tells you is that **structuring large
54Node.js apps** is more problematic than one would think. And going microservice
55for every single thing is also a bad idea. The amount of networking you
56introduce with that approach always ends up being a pain in the ass. And I don't
57even want to go into system administration here. The overhead is
58insane. Package-lock.json made many days feel like living hell for me. And I
59would eat the cost of all this if it meant for better development
60experience. Well, it didn't.
61
62The **lack of Typescript** support in the interpreter is still mind boggling to
63me. Why haven't they added native support yet for this is beyond me?! That would
64have solved so many problems. Lack of type safety became a problem somewhere in
65the middle of the project where the codebase was sufficiently large enough to
66present problems. We started adding arguments to functions and there was **no
67way to implicitly define argument types**. And because at that point there were
68a lot of functions, it became impossible to know what each one accepts,
69development became more and more trial and error based.
70
71I tried **implementing Typescript**, but that would present a large refactor
72that we were not willing to do at that point. The benefits were not enough. I
73also tried [Flow - static type checker](https://flow.org/) but implementation
74was also horrible. What Typescript and Flow forces you is to have src folder and
75then **transpile** your code into dist folder and run it with node. WTH is that
76all about. Why can't this be done in memory or some virtual file system? Why? I
77see no reason why this couldn't be done like this. But it is what it is. I
78abandoned all hope for static type checking.
79
80One of the problems that resulted from not having interfaces or types was
81inability to model out our data from **Elasticsearch**. I could have done a
82**pedestrian implementation** of it, but there must be a better way of doing
83this without resorting to some hack basically. Or maybe I haven't found a
84solution, which is also a possibility. I have looked, though. No juice!
85
86**Error handling?** Is that a joke?
87
88Thank god for **await/async**. Without it, I would have probably just abandoned
89the whole thing and went with something else like Python. That's all I am going
90to say about this :)
91
92I started asking myself a question if Node.js is actually ready to be used in a
93**large scale applications**? And this was a totally wrong question. What I
94should have been asking myself was, how to use Node.js in large scale
95application. And you don't get this in **marketing material** for Express or Koa
96etc. They never tell you this. Making Node.js scale on infrastructure or in
97codebase is really **more of an art than a science**. And just like with the
98whole JavaScript ecosystem:
99
100- impossible to master,
101- half of your time you work on your tooling,
102- just accept transpilers that convert one code into another (holly smokes),
103- error handling is a joke,
104- standards? What standards?
105
106But on the other hand. As I did, you will also learn to love it. Learn to use it
107quickly and do impossible things in crazy limited time.
108
109I hate to admit it. But I love Node.js. Dammit, I love it :)
110
1112023 Update: I hate Node.js!