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