update index
This commit is contained in:
parent
99e238ba89
commit
5e444fe7b0
9 changed files with 1062 additions and 25 deletions
|
|
@ -14,13 +14,13 @@ This article is about JavaScript for web browsers, not NodeJS or TypeScript.
|
|||
|
||||
## TL; DR
|
||||
|
||||
JavaScript combines all the problems of both high and low level languages.
|
||||
JavaScript combines most of the problems of both high and low level languages.
|
||||
|
||||
## Lack of features
|
||||
|
||||
JavaScript is obviously not made for being used in webpages.
|
||||
|
||||
* need jQuery
|
||||
* jQuery is needed for manipulating DOM or network in a convenient way.
|
||||
* no native HTML escaping function
|
||||
* no native basic templating system (need `String.replaceAll("{{foo}}", foo)`)
|
||||
* no easy-to-use bytes array (like `Bytes` in Python or `Vec<u8>` in Rust), but many different bytes arrays with weird interfaces
|
||||
|
|
@ -28,6 +28,8 @@ JavaScript is obviously not made for being used in webpages.
|
|||
* no native date/time string formatting
|
||||
* When defining an anonymous function (such as a callback) you can't reliably move variables to it.
|
||||
|
||||
Having a decent standard library would reduce the use of weird hacks hence the number of bugs, and the use of libraries hence the traffic and webpage size and loading time.
|
||||
|
||||
## What the fuck
|
||||
|
||||
JavaScript doesn't respect anything.
|
||||
|
|
@ -35,7 +37,6 @@ JavaScript doesn't respect anything.
|
|||
* You never know whether you're copying or borrowing (a table or an object), and how deeply.
|
||||
* Python suffers the same problem.
|
||||
* Time is expressed in milliseconds, while the convention is seconds everywhere else.
|
||||
* `"1" == true && "2" != true && "2" != false` is true
|
||||
* ```js
|
||||
if("2" == true)
|
||||
console.log("I am not executed.");
|
||||
|
|
@ -44,7 +45,8 @@ JavaScript doesn't respect anything.
|
|||
```
|
||||
* Hence `==`, `===` and `if` have three distinct strictness levels.
|
||||
* `&&` is not commutative: `(true && "2") === "2" && ("2" && true) === true` is true
|
||||
* Operators are inconsistent: `"1"+1 === "11" && "1"*2 === 2` are true
|
||||
* It is even inconsistent: `"0" == false && "1" == true` is true... but so is `"0" && "1"`.
|
||||
* Operators are inconsistent: we have both `"1"+1 === "11"` and `"1"*2 === 2`
|
||||
* ```js
|
||||
var n = "1";
|
||||
n += 1;
|
||||
|
|
@ -63,3 +65,11 @@ JavaScript doesn't respect anything.
|
|||
console.log(foo.length); // 0
|
||||
```
|
||||
* `document.getElementsByClassName` does not return an array: its return type supports indexing but not for/in loops.
|
||||
|
||||
|
||||
|
||||
## Conclusion
|
||||
|
||||
Let's deprecate JavaScript and replace it with better languages compiled into WASM.
|
||||
|
||||
However, plain HTML/CSS should *always* be prefered, for performance, compatibility and accessibility. Form inputs crafted with tons of CSS and JS are often unresponsive, not accessible to screen readers, incompatible with native features, inefficient. It is even worse for pages rendered in a canvas. Please use the wonderful possibilities offered by HTML5 and CSS3, and follow the accessibility recommendations by the [W3C](https://www.w3.org/WAI/) and [Mozilla](https://developer.mozilla.org/en-US/docs/Web).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue