The anarchy of web ecosystem
Tags: webdev, javascript, rust
Published: 2023-07-30 12:14:20


## The web of anarchy
Current web is really a mess. List of w3c standards is infinitely growing, and the old standards are not going away, we have to support them.

> Total number of actual standards is **300+**

## What causes the most problems?
### Spoiler: JavaScript
Javascript is the language written for not executing billions of lines of code and not for running the most popular and large apps. It was written as quick scripting lang

But for me it's not that JS is bad language makes web broken, it's the bundlers, transpilers, runtimes that break JS, they try to fix the ecosystem and they create complexety, like we must now use `typescript` to build apps that work and error out when logically needed(like unknown vars), then it converts into ugly bundler code.

### Node.js
Yea, that thing, the idea of running js in the backend was awful, but ok, we have it, except Node.js bringed us CommonJS, a **very hacky way** to use external modules.

But hallelujah, we have imports now, *oh stop I forgot about backward compatibility*, yea with introductions of **imports** `requires`  are not going away.

### Bundlers
The most scary thing in JS. What is broken with them
- Configs(**Any zero config option will eventually go to a config**)
- **Output**:
	- Requires multiple files, **because of different module systems** and **environments**
	- Joins everything **into one bundle**
- **Build times**:
> [!warning] Build times
> Almost all of the bundlers are written in js for node, and really unoptimized.
> But a lot of bundlers are moving in the right way, we will talk about that later
> Each **webpack** bundle with monaco takes **at least 1 minute to build**

Everything above takes time and resourses, just to setup a new projects.
### Frameworks
They are confusing for beginners, poping up very quickly and each has a different syntax or strategy.
**Why the popped up?**
Because the web and JS are imperative and imperative is not right choice for big apps or quality code. For scripting a button it's fine but not for making a hole code editor.
### **Examples of much better ui langs:**
All of them are declarative, have a nice way to connect ui with logic.
{% embed https://slintpad.com/? %}
{% embed https://developer.apple.com/xcode/swiftui %}
{% embed https://flutter.dev/development %}


## The solution
I can talk about broken all day, but let's get to my point.

### Surely, the way to fix it, it's to rewrite?
No, the rewrites only make the web more broken, also the full incompatable rewrite is **NOT AN OPTION**, we need backwards compatability to work with ecosystem


### Wasm doesn't help
Wasm is a great thing, but it doesn't improve the performace, only performance stability and you will be loading a big binary to platform that doesn't have syscalls and you will need to call js to do anything
I thing if you are making an app in rust and need ssr with dynamic frontend go with it, but for the sake of rust


### The way we are heading and I hope we will continue heading
Many tools have optimized dev builds and use imports in browser to their advantage, like **vite**.
The **new tools** that are made with **static compiled langs** for web ecosystem are in development like [turbopack](https://turbo.build/pack), [stc](https://github.com/dudykr/stc), [bun](https://bun.sh/) and more.
Many more are already here: [rspack](https://www.rspack.dev/), [deno](https://deno.land/),[swc](https://swc.rs/), [vite](https://vitejs.dev/),[oregone](https://github.com/orogene/orogene)


Most of my idea is: Tools go faster and simpler

Thanks for reading!
You can comment on my mastodon toot or on lemmy or dev.to.