惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
J
Java Code Geeks
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
阮一峰的网络日志
阮一峰的网络日志
爱范儿
爱范儿
量子位
N
Netflix TechBlog - Medium
博客园 - 聂微东
博客园 - Franky
aimingoo的专栏
aimingoo的专栏
The Cloudflare Blog
T
The Blog of Author Tim Ferriss
MyScale Blog
MyScale Blog
Google DeepMind News
Google DeepMind News
小众软件
小众软件
博客园 - 三生石上(FineUI控件)
C
Check Point Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
B
Blog
Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC

ashishb.net

A day in Luxembourg - the richest country in the world I was asked to install malware during a fake interview Book summary: Breakneck - China's quest to engineer the future by Dan Wang Book summary: How to Teach Your Baby to Read Book Summary: The Discontented Little Baby Book by Pamela Douglas Introducing Amazing Sandbox - run third-party tools and AI agents securely on your machine Why software outsourcing gets a bad reputation? Book summary: The Natural Baby Sleep Solution by Polly Moore A day in Antwerp, Belgium Journey of online influencers Two days in Brussels, Belgium Shortcuts - when we love them and when we don't A visit to Rakhigarhi Three days in overhyped Paris Empty Japan, crowded Tokyo The real lock-in in GitHub is not the code, but the stars 11-day Norwegian Breakaway East Caribbean cruise Sanskrit and Sri Lankan Air Force Use REST with Open API The Achilles heel of American capitalism Costa Rica in 4 days At a juice stall in Sri Lanka A short stay at Warsaw, Poland Best practices for using Python & uv inside Docker Two days in Vilnius, Lithuania How IntelliJ IDEs waste disk space Pregnancy Why there aren't many digital nomads from India Two days in Riga, Latvia To keep your machine secure, run third-party tools inside Docker
Minimize Javascript in your codebase
Ashish Bhatia · 2024-11-24 · via ashishb.net

Javascript isn’t a language. It is just a specification. Well, that’s true for many other languages like Python and Java. However, most languages have just one de facto implementation. For example, CPython for Python. Java has two major ones - Oracle’s JDK and Google’s Android Java. That’s not true for Javascript though.

  1. Different implementations - All browsers have slightly different implementations of Javascript. To cover the gaps there are magical libraries called Polyfills. Of course, that doesn’t help with the issue of server-side vs client-side Javascript. All the libraries are on npmjs.com, and it is for you to guess which one works and the subtle differences due to security restrictions that are imposed on browser-side JS.
  2. No built-in libraries (batteries) - Unlike Java, Go, Python, etc. Javascript ships with no batteries included. So, even for simple tasks like padding, there are third-party libraries. The idea that these libraries are not buggy or have security issues is preposterous. While all projects depend on third-party libraries, Javascript takes it to the next level due to a lack of batteries.
  3. Server-side Javascript - Node.js’s founder has moved to Deno. But Deno support is still poor across libraries. You will start with Node.js in 2024 and will be forced to migrate in a few years once everyone moves to Deno. This reminds me of Python of 2015-20 era. Python 2 was deprecated but Python 3 support was poor. You would write code in Python 2 despite knowing its limited shelf-life.
  4. Single backend frontend codebase - Well, good luck with that. God forbid if your engineer is lost where the backend Javascript code ends and the frontend begins leading to leaks of Database credentials.
  5. Typescript - Kotlin is better than Java. I have heard that Swift is better than Objective-C. TypeScript isn’t better than Javascript though primarily because it is a superset of Javascript. It is better than Javascript but not the magic bullet. Further, your gazillion poor-quality Node.js dependencies might still be written in Javascript.
  6. React - React is the most popular framework. Vue, however, is a better framework that neatly separates Javascript, CSS, and HTML into three separate sections of the same component definition file. React, on the other hand, prefers a multi-indented hideous JSX syntax. I can’t imagine why someone feels that HTML embedded inside Javascript is superior. Further, Vue has batteries like redux, etc. built into it.

While Javascript is unavoidable, here’s how I think one should try to limit its spread.

  1. No Javascript for the backend codebases - My preference is Go but even Python is more maintainable.
  2. No React Native for mobile
  3. Use Typescript
  4. And if you can, avoid React. Vue is much superior but about one-fifth of the market share of React.
  5. Run npm and yarn inside docker using Amazing Sandbox to ensure safety from supply chain attacks.