However, CSS and JS are not error-tolerant. A syntax error in a CSS rule causes it to be ignored. An unhandled JavaScript exception is a hard stop. This way, web does not run on tolerance.
However, CSS and JS are not error-tolerant. A syntax error in a CSS rule causes it to be ignored. An unhandled JavaScript exception is a hard stop. This way, web does not run on tolerance.
I think you mean HTML5, which exhaustively specified how to do parsing in a fault-tolerant, normalizing way. HTML 4 (and 4.01) predated XHTML 1.0, and HTML 4.01 attempted to take things in a stricter direction, introducing a "Strict" DTD that did things like drop the <font> tag, in pursuit of separating structure and presentation.
- Wanna subtract a string from a number? That's not a type error, that's a `NaN` -- which is just a perfectly-valid IEEE 754 float, after all, and we all float down here.
- Hell -- arithmetic between arbitrary data types? Chances are you get `[object Object]` (either as a string literal or an *actual* object), which you can still operate on.
- Accessing an object field but you typoed the field name? No worries, that's just `undefined`, and you can always operate on `undefined` values.Frankly, while I haven't had a frontend focus in about 15 years, I struggle to think of any situation where calling a stdlib function or standard language feature would result in an actual exception rather than just an off behaviour that'll accumulate over time the more of them you stack on eachother. I guess calling an undefined variable is a ReferenceError, but beyond that...
(This comment shouldn't be taken as an endorsement of this school of language design)
Can't access a network resource? API returns an unexpected error? Library crashes? Browser extension breaks something? Doesn't matter. The user can still view and scroll the page, and the rest of it will probably keep working, too.
The amount of articles on HN that render perfectly, then vanish a second later and are replaced by this error message is insane. Yes, I'm using an old unmaintained Android HN reader with a questionable webview. No, that's not an excuse to delete a perfectly rendered from right in front of my eyes.
That is error-tolerant, in basically the same way HTML is.
> An unhandled JavaScript exception is a hard stop.
A more appropriate example here is that a JS syntax error stops the entire script from running. That’s the XML parser approach.
This is good though as it provides a means for progressive enhancement using new features only when they are available and falling back on previous rules if they are not. It's very different from the syntax error -> RIP page nonsense of XHTML.
I don't think this was a "strength" of html so much as a necessity to not break the internet. I certainly preferred the formal nature of xhtml to html 5. But, we're stuck with needing to render obviously formally-broken documents.
I'm not sure these words mean what you think they do...
And CSS syntax error causing only that single line of code to be ignored while every other line of code works fine is the very definition of fault tolerance.
What else could you possibly want?
With (almost) everyone using an up-to-date standards-compliant browser, you can sidestep most of the complexity and weirdness by just using the standard library and ES Modules (instead of frameworks, libraries, build systems etc.) and an IDE with good intellisense + inline documentation lookup.
MDN documentation is good and up to date overall, but I'm not sure there is a good overview/entry point resource that is up to date as of today... maybe I'll have to write it!
Now the tables have turned (to some degree). I can write programs in JS in 1-3 days that take weeks or months in C++/C#/Java
Some of this comes from the browser environment. I get portable 2d/3d/gpu graphics, portable audio, image loading, video playback, and complex text rendering and layout, portably and for free. Back in C++/C# land, every new project is a chore of setup and fighting with linkers and build options etc. I post some code in a github repo with github pages on, or in some JS playground like codepen, and instantly share it with all friends regardless of platform.
Another comes from the language itself. I can often generically wrap existing APIs in a few lines of codes, things that used to take days and/or large program refactors to do in C/C++.
And, the tools are pretty good, Chrome DevTools are as good or better than my experience in C/C++. Right now, when I try to debug in C++ in XCode, std::string shows nothing and containers are inscrutable. I'm sure that's fixable. The point is, I shouldn't have to fix basic stuff.
Now of course I'm using TypeScript for some projects and the types help but I'm often glad for the escape hatch for more generic code. It takes me 15 mins to write some generic system in JS and then 2-4hrs to figure out how to get TypeScript happy to type it. As an example, a function that creates a new TypedArray of the same type as some src array. Easy to write in JS. Harder to type in TS. That's effectively part of the same issues I have in C++, the part that stalls progress, that I don't have the escape hatch for generic solutions.
PS: Yes, it's not that hard to type a generic TypedArray function in TS. But it's certainly a learning curve, or was before LLMs, and I've had to type much more complex functions that required no typing in JS