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

推荐订阅源

U
Unit 42
罗磊的独立博客
博客园 - 聂微东
T
The Blog of Author Tim Ferriss
博客园 - 司徒正美
Stack Overflow Blog
Stack Overflow Blog
F
Fortinet All Blogs
A
About on SuperTechFans
腾讯CDC
Apple Machine Learning Research
Apple Machine Learning Research
B
Blog RSS Feed
IT之家
IT之家
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
宝玉的分享
宝玉的分享
C
Check Point Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Vercel News
Vercel News
爱范儿
爱范儿
Microsoft Security Blog
Microsoft Security Blog
月光博客
月光博客
T
Tailwind CSS Blog
The Cloudflare Blog
Hugging Face - Blog
Hugging Face - Blog

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.