“The hardest challenges in programming: Naming Variables, Invalidating Cache, and Off-by-one Error”
Chau Tran - Admin at Angular Vietnam & Senior Engineer at Nx.dev
I work at Nx.dev, which is a business that focuses on open source. Those of you who use Angular or React to build systems have probably used this tool before. It’s a build tool that lets you make a monorepo for your projects and businesses. It can handle complex workflows with multiple packages. Using the
executor, you can set up jobs for your project and run them in topological order. These tasks can be one-time jobs like
build, or they can be long-term jobs like
Nx also makes it possible for these jobs to be done at the same time. For example, running the frontend and backend at the same time without the need for different terminals, like
The most interesting thing about Nx is its ability to cache tasks. For example, say you have 3 apps, ABC, that share 10 libraries. Nx knows which libraries A uses, how to build them, and does so in the way that A wants (this is called “topological”). The next time you rebuild A, Nx knows what A has built and what hasn’t changed. This means that Nx can cache the files that haven’t changed, which speeds up the building process. These caches are kept on your computer, so if you run it, you’ll have your own cache and your coworker will have a different one. This gives rise to the idea of “Remote Caching” or “Distributed Caching,” which means caching in the cloud. Even if you run the cache on your local machine, Nx puts that cache in the cloud so that when your coworker runs it in the cloud, they can pull that cache and save a lot of time.
The feature that saves the most time is that your colleague can be an agent running on his pipeline, when CI/CD is running, it can automatically pull the cache back if there is a cache. When I build on my machine and update the read cache in the cloud, when CI/CD runs and reads the cache, it is guaranteed that what I build is what CI/CD will receive. This somewhat reduces the “accuracy” of a myth in the tech industry: “It works on my machine”. Nx is an Open-source product and is completely free to use. However, Remote Caching is a product that we use to “earn revenue”, but it is still free for open source, or non-profit organization. One of Nx’s most important missions is ensuring Cache accuracy; when to read from cache; when to destroy and create a new cache (Invalidate Cache). This is one of the two most difficult tasks in programming: Naming Variable, Invalidate Cache, and Off-by-one Error 😅.
Another thing I really like about this company is the flexibility here. I joined the company from 2021, doing open source products, unrelated to web writing, Angular, the things that I liked before. After working for 2 years, I told my boss, I’m so bored, can I make a website? So the boss switched to working as Nx Cloud (remote caching), where it had a dashboard for web. I just switched to web development 3 4 months ago. The culture here is “oh you want to try something new, you want to do something else, I’ll give it to you”. Our company is very comfortable in employees being able to choose the right project for them even though it has nothing to do with that person’s JD. I don’t feel restrained, the company listens to me and wants to keep me to work.
Every year the company gives employees $ 2500 to buy books, courses, attend seminars … to improve professional capacity. CEO said if you don’t spend 2500$ in 1 year, points will be deducted. Being given money to spend, but not using it all is a problem with the boss. Engineering team always has lunch-and-learn every 2 weeks, sharing what everyone knows with each other. For example, a frontend like me doesn’t know anything about Dev Ops, I can ask Simon, you work as Dev Ops in the company, “hey, in the next lunch-and-learn, can Simon introduce Kubenetes to the team ?”. Simple as that, that’s it, Simon shared 1 hour about Dev Ops and it was done.
That’s why I really like my current company, and the salary is also very good hehe.