[Translation] Rinse off

Hello, Habr! I present to you the translation of the article “To Wash It All Away” by James Mickens.



When I was in graduate school at Ann Arbor, I had a friend who was deeply passionate about the environmental movement. He bought food from local farmers, rode a bicycle instead of a car, wanting to reduce emissions, and kept a creepy compost bucket, which is likely to be the source of the next flu pandemic. Once he told me that he was going to live on a farm for a week. I asked why, and he replied that he wanted to "be closer to the ground" - a phrase that you can pronounce with a serious face, only commenting on a documentary about ancient South American tribes. I told my friend that the land does not want to be closer to him and that if he really looked closely at the ground, he would see not milk rivers and jelly banks, but hunger, vultures, excessive labor using wheelbarrows and generally unacceptable amounts of insects.He burst into a lengthy lecture on environmental responsibility, which I immediately overlooked because I realized that my naive friend would give oak on this farm, and advised him to return without hesitation if he was not well enough there. He smiled at me like people in horror films were smiling a minute before meeting with an ax, and set sail.Exactly 37 hours later, he called. I asked how things were going, to which he responded with a long, chilling sound, like the singing of sirens during the mating season. I asked him to describe his first day, and he answered that his whole life revolved around bleating things: bleating goats, hungry ravens, who wanted to steal food from bleating goats and bleating mechanisms, consisting of rotating steel blades and not having any reasonable application, not counting ensuring your membership in the club "Prosthesis of the month".
I asked my friend when he was going home, to which he replied that he was calling from the train station in Ann Arbor; he is already here. And then he again gave out that howl of sirens, that creepy, lingering sound, and I realized - LIKE THIS IS THE FIRST SYMPTOM OF A COMPOSEDUE INFLUENZA.

IT professionals often see on web pages what my friend saw in the farms. People think that web browsers are such elegant computing platforms, and that web pages are such light, fluffy gizmos that you can edit in notepad by throwing ironic comments with friends in the coffee shop. There is nothing farther from the truth. A modern web page is a disaster. It is similar to a scene from one of those apocalyptic medieval paintings depicting the consequences of the coming of Galactus: people roll head over heels into a fiery abyss, are afflicted with various crushing things, and hang from equipment for playgrounds that would not pass safety certification. This is exactly what you will see when you look at HTML, CSS, and JavaScript in a modern web page. No, of course, no one is able to really “look” at this content, because a typical web page these days is similar to V'Ger from the first Star Trek - a technology that we once understood, but now we can’t even to realize the crushing Leviathan of the code and markup written by people so unreliable that they’re not even the third party here, they are the fifth side, NOT called at all to this party,but appeared anyway, because the hippies were right and free love or do not care. I am sure that the web browser is one of those “unholy dens” that Fox News is constantly talking about; I would personally check this by searching on the net, but searching on the net would require me to use a browser, AND THIS IS EXACTLY WHAT THE ENVIRONMENTAL LIBERAL ELITES WANT FROM ME.

A description of why the Web is terrible, similar to a description of why it is terrible to drown in the ocean from puffer fish pregnant with little Freddy Kruegers - every detail is nightmare in itself, but the total amount is deliciously added to an evergreen hate flower. For example, the World Wide Web Consortium (W3C) provides “official” specifications for many client-side web technologies. Unfortunately, these specifications are binding on browser makers to about the same extent that you can, in principle, ask a venomian to meet you at the airport [1]but the venomous tooth, perhaps, has more interesting activities. Each W3C document is filled with disgusting sentences, mainly consisting of hyperlinks to hyperlinks. For example, if you are a browser manufacturer and want to add support for HTML selectors, you should remember that in the third step of parsing the selector line “If the result is invalid ([SELECT], section 12), you should throw a SYNTAX_ERR exception ([DOM-LEVEL-3-CORE ] , section 1.4)and abort this algorithm. " Such a romantic study in clerical tones will undoubtedly appeal to people who yearn for the stupidity of the list of Doshirak's ingredients, multiplied by the multilayer bureaucracy of the Soviet Union. Indeed, one can imagine a world in which browser makers hire legions of interpreters of the Talmud to understand why SYNTAX_ERR is orange rather than lilac, and how exactly this orange is related to cropped lilac ([DOM-LEVEL-3-CORE]) And you can imagine a world where browser manufacturers do not do this, instead implementing 53% of each specification, and then hoping that no web page will try to use HTML selectors, then the geolocation interface, and then the <canvas> tag, therefore that this combo will free the Antichrist and / or display a web page similar to one of those works by Picasso that you supposedly understand, but who all secretly want to throw into the ocean, because no one is happy to contemplate the image of a blue man from isosceles triangles growing from his forehead a guitar for no reason.

[1] « » — , . , « , », « , » « , , , ».

Given the unbearable swelling of web standards and the clownishly inaudible semantics of these standards, browser manufacturers should just spit and advise society to stop wanting something strange. However, this opinion is unpopular, because no one will look at your performance at TED if your sense of optimism is based on reality. I keep trying to explain to friends why they should give up web pages and exchange information using sunlight reflected from a system of mirrors, well, or energetically waving colored flags. My friends inevitably respond with a meaningless set of words like “people invented aircraft, so we are certainly able to make a good browser!” Unfortunately, the criterion for the success of an aircraft is simple ("I AM THIS AM BUT I AM A BIRD")while the success criterion of a web browser includes cascading style sheets - a technology that, by its very existence, dooms any project to an epic failure. For the uninitiated, cascading style sheets are such cryptography designed by Masons to hide the visual nature of reality and encourage people to draw pictures with pseudographics. CSS files supposedly allow you to separate the definition of your content from the definition of how that content looks - using CSS, you can specify the placement for your HTML tags, as well as the fonts and color schemes used by these tags. Unfortunately, CSS and HTML are combined in the same way as instructions for assembling your bed from IKEA and a set of vicious wooden sticks, supposedly concealing the structure of the bed. CSS is not so much a description ofhow your web page will eventually look, how much a superficial, high-level overview of whathappen to your page depending on the weather, the situation on the stock market and when was the last time you called mom. Like a naive gamemaster who has not been spoiled by the sorrows of adulthood, you create abstract CSS classes for the <div> and <span> tags, distributing their strengths and weaknesses, and defining the roles that they will play in the comprehensive and sublime narrative of your HTML . Everything is strictly in place; you load the page into the browser and prepare for a glorious victory. However, you will soon find that your <elf> tag is overweight. ELF CANNOT HAVE AN EXTRA WEIGHT. Even worse, your <barbarian> tag has no hefty hammer or ax. Without a hefty hammer or ax YOUR BARBAR IS JUST A LITTLE GAME. And then you look at your <mage> tag and seethat this is not a white old man with a flying beard, but a young black man from Brooklyn. FOR MANY COMPLEX REASONS, TAKING THEIR BEGINNING IN EUROPEAN COLONIAL STORIES, YOUR MAGICIANS HAVE TO BE A WHITE CARICAN WITH A FLOWING BEAR AND NOT SHARE SLIGHTLY SHORTLY SHORTLY. These are the troubles that CSS will sow to you. Or you reap. Honestly, I don’t know which verb and in what form is more appropriate here, but I’m sure that you understand me. Figure 1 shows a specific example of CSS seed. Or CSS sowing. MY STEP-BY-STEP GUIDE ON STYLES FIGHT FOR MY SOUL.AND NOT A BLACK IN HIPSTER SHOES AND WITH A LUXURY COLLECTION OF PLATES. These are the troubles that CSS will sow to you. Or you reap. Honestly, I don’t know which verb and in what form is more appropriate here, but I’m sure that you understand me. Figure 1 shows a specific example of CSS seed. Or CSS sowing. MY STEP-BY-STEP GUIDE ON STYLES FIGHT FOR MY SOUL.AND NOT A BLACK IN HIPSTER SHOES AND WITH A LUXURY COLLECTION OF PLATES. These are the troubles that CSS will sow to you. Or you reap. Honestly, I don’t know which verb and in what form is more appropriate here, but I’m sure that you understand me. Figure 1 shows a specific example of CSS seed. Or CSS sowing. MY STEP-BY-STEP GUIDE ON STYLES FIGHT FOR MY SOUL.



1: - . JavaScript , JavaScript' . - , — , HTML . . , , TM. CSS , , . : , , . - , HTML- Z, , , , . CSS , , , . , , , .

If you're a web developer, CSS is just one of your worries. The cumulative stack of web technologies is so fragile that the developers simply put up with the fact that various parts of the web page will fall off at arbitrary points in time. Apparently, this is the norm, because nobody takes e-commerce seriously, and if you really crave secure banking operations, you are not averse to visiting the bank personally, as in the 19th century, instead of using the bank’s web portal, which constantly ( but quietly ) emits errors execution in the console log (the console log, which the browser does not show you by default, because if you knew about it and heeded its woeful epics, you would have dropped computer science and switched to making wooden shoes).
Figure 2 shows an original example of such a console log; The log was generated by a real web page on one popular site.


Figure 2: They said that I can be anyone, and now I have a web browser error log. I have fifteen cats, where are all the parties?

  • , JavaScript, , MIME — text/html. : , , . , — , , , , . , : .
  • , , , . , , ? : , . . « » , HTML CSS. « » , . - , - , «--» . , - , . -, , , . « »; , , , . , , « » «» , , . , , , . , , - , , . .
  • JavaScript. - , , , . «, , ''». JavaScript , , , , , . , , , - init() , init(). , - , . . , « , », , , , , . , , . , - , , , , , , .

The interpretation of the remaining errors is provided to the reader as an exercise. Note that understanding the eighth error requires coffee grounds, the eye of the newt and a crystal ball.

At this point, it should become intuitive that different browsers may or may not generate the same error log for the same page. In general, if a web page contains more than three bits of entropy, different browsers will generate extravagantly unique combinations of the intentions of the web developer and the schizophrenic animal palette used by browsers to convey a picture of the world. Thus, choosing the “best browser” is like playing one of those creepy confidence-building exercises where you decide which three of your five feelings you would rather lose, and then your colleagues scold you for the compromises they had to make, in spite of the fact that there is no partial ordering capable of comparing diving accidents during which you lose your eyes and ears,with industrial accidents during which you lose your nose and tongue. All options are bad; this is the world of trampling on the spot. Indeed, trying to choose the best browser is like trying to decide which of your worthless children should inherit a family business. Little Oliver rejects the generally accepted notions of what an event loop should do, so whenever a user presses a key on the keyboard, Oliver fires not one keyPress event, but three KeyDown events, a KeyUp event and a cut out saxophone solo from Mozart’s eighth symphony. The dearest Fiona, an adamant workaholic, designs her browser so that when you “close” it, the graphical interface disappears, but the main process spins in the background, quietly,viciously and slowly consuming entries in the kernel tables and making it impossible to restart the browser without contemplating the error message “Somewhere else in the world is working another copy of the browser; find Carmen SanDiego and she will reveal the secret. ” Favorite Christopher, in an attempt to make his browser quick and easy, decides to replace his Flash-plugin with code that prints “Shockwave fell,” and then immediately dereferences the null pointer; this ensures that most of your attempts to watch the video result in a desire for more mundane spectacles, such as wood carvings or cave paintings. And poor IE6, it’s “there won’t be any sense because IE6 is not the right Christian name”, somehow managing to waddle around the world, surviving more assassination attempts than Fidel Castro.find Carmen SanDiego and she will reveal the secret. ” Favorite Christopher, in an attempt to make his browser quick and easy, decides to replace his Flash-plugin with code that prints “Shockwave fell,” and then immediately dereferences the null pointer; this ensures that most of your attempts to watch the video result in a desire for more mundane spectacles, such as wood carvings or cave paintings. And poor IE6, it’s “there won’t be any sense because IE6 is not the right Christian name”, somehow managing to waddle around the world, surviving more assassination attempts than Fidel Castro.find Carmen SanDiego and she will reveal the secret. ” Favorite Christopher, in an attempt to make his browser quick and easy, decides to replace his Flash-plugin with code that prints “Shockwave fell,” and then immediately dereferences the null pointer; this ensures that most of your attempts to watch the video result in a desire for more mundane spectacles, such as wood carvings or cave paintings. And poor IE6, it’s “there won’t be any sense because IE6 is not the right Christian name”, somehow managing to waddle around the world, surviving more assassination attempts than Fidel Castro.that most of your attempts to watch the video will end with a desire for more mundane spectacles, such as wood carvings or rock paintings. And poor IE6, it’s “there won’t be any sense because IE6 is not the right Christian name”, somehow managing to waddle around the world, surviving more assassination attempts than Fidel Castro.that most of your attempts to watch the video will end with a desire for more mundane spectacles, such as wood carvings or rock paintings. And poor IE6, it’s “there won’t be any sense because IE6 is not the right Christian name”, somehow managing to waddle around the world, surviving more assassination attempts than Fidel Castro.

Each browser is foolhardy and bizarre in its own way, but all browsers equally share the love of epic swapping to disk. Not a rare rain of miniature I / O aligned to the file system location, no, I'm talking about the collisions of snow storms of reading and writing, about the primeval flood that forces you to collect your fellow tribesmen and decide which creatures to take in a pair and whether to forget the fire ants, because fire ants spoil the summer. Browsers do not need a specific reason for sticking a disk, no; swapping is a browser lifestyle, a leisure activity that delivers on its own. If you are not an IT professional, you are simply resigning to the fact that visiting CNN.com will cause the green flashing light with the cylinder icon to stop flashing and to glow green constantly. However, if you still know how computers work,then endless swapping drives you crazy. It turns you into Torquemada - a miserable figure, obsessed with the fear that your whole ideology is just a fanciful lie, necessary only to hide the excessive disk operations of the gray cardinals. You open your task manager, and you find that your browser has launched 67 different processes, all of them called “browser.exe”, and all of them are desperately scorching from all I / O on such mysterious areas of the file system as “\ Roaming \ pots \ pans \ cache \ 4 $$ Dtub.partial ", where" \ 4 $$ "is an exotic ESC sequence that unfolds in Latvian double umlaut. You search the Internet for potential solutions and come across a bunch of conflicting and unsubstantiated opinions: your browser has a virus; your virus has a virus; I had to use Emacs; you had to use vi,and that’s why your marriage cracked.

Naturally, the most popular advice for resolving any browser issues - clear your browser’s cache. Undoubtedly, clearing the cache sometimes will help, in much the same way as kicking a tree with a rogue sometimes leads to a series of funny events, ending with the fall of a large bag of money on the ground and the note “Spend it all! Tsem, Life. ” Unfortunately, kicking a tree usually does not lead to wealth, so your faith-backed act of aggression towards trees really only makes you a wild, kicking tree monster reproved by children and emotionally sensitive adults. Likewise, your sudden clearing of the browser cache, despite good intentions, is only a local painkiller that briefly brightens up the pangs of life. Fixing the browser by clearing the cache is like your dad taking you to kindergarten, and when the car suddenly starts to smoke, trying to fix it with three pops on the hood,and then asking you if you still smell carbon monoxide, and you say, “Yeah, it's better,” because you don’t want to expose your dad as a swindler, and then you both spend the rest of the way silently, trying not to lose consciousness.

So, yes, it would be great if fixing your browser was related to actions that would not be semantically equivalent to voodoo. However, on the other hand, it could have been even worse. For example, it would be really awful if your browser's scripting language combined the prototype inheritance of Self, quasi-functionalism borrowed from LISP, structured syntax drawn from C, and an aggressively-asynchronous I / O model requiring non-trivial callback chains spanning several generations of hardworking Americans. OH NO, I JUST DESCRIBED JAVASCRIPT. What an unpleasant turn of events! People longed for the combination of Self, LISP and C as desperately as the inhabitants of Middle-earth begged Saruman to cross the orcs with people, so that he would get Uruk-hai.Orcs and people fought nicely for their existence in their separate communities, creating a new race with the shortcomings of both is not the best way to become the first guy in the village. However, despite its shortcomings, JavaScript is still widespread. Investigating these causes is similar to trying to understand the causes of the First World War - everyone agrees with the five main reasons, but everyone has their own opinion about their paramount importance. The bottom line is this: in the 90s, when JavaScript and Java competed for superiority on the client, Java applets were monstrously slow and could not boast of interacting with HTML; JavaScript was only half monstrously slow and could lousy (but could) interact with HTML. So Java lost despite:However, despite its shortcomings, JavaScript is still widespread. Investigating these causes is similar to trying to understand the causes of the First World War - everyone agrees with the five main reasons, but everyone has their own opinion about their paramount importance. The bottom line is this: in the 90s, when JavaScript and Java competed for superiority on the client, Java applets were monstrously slow and could not boast of interacting with HTML; JavaScript was only half monstrously slow and could lousy (but could) interact with HTML. So Java lost despite:However, despite its shortcomings, JavaScript is still widespread. Investigating these causes is similar to trying to understand the causes of the First World War - everyone agrees with the five main reasons, but everyone has their own opinion about their paramount importance. The bottom line is this: in the 90s, when JavaScript and Java competed for superiority on the client, Java applets were monstrously slow and could not boast of interacting with HTML; JavaScript was only half monstrously slow and could lousy (but could) interact with HTML. So Java lost despite:when JavaScript and Java competed for superiority on the client, Java applets were monstrously slow and could not boast of interacting with HTML; JavaScript was only half monstrously slow and could lousy (but could) interact with HTML. So Java lost despite:when JavaScript and Java competed for superiority on the client, Java applets were monstrously slow and could not boast of interacting with HTML; JavaScript was only half monstrously slow and could lousy (but could) interact with HTML. So Java lost despite:

  • JavaScript , , , Monty Python. , 12 == «12», . ,  . , null == undefined. ; , null, , NULL. , , : "\r\n\t" == false. : , , false 0 . ( ), "\r\n\t" 0, - 0. — 0 0! . «Inception», , « false».
  • , — ! , JavaScript NaN (« »)? , , , ParseInt(«»). , NaN , . , typeof(NaN) … «». « , ", .
  • , NaN != NaN, « ».
  • , JavaScript (=== !==),  , ; , NaN !== NaN. , JavaScript, , ALU. , .
  • , , . C++, , JavaScript . , «» . ,   Circle JavaScript, - :

    // ,   "radius"
    //  .
    function Circle(radius){
        this.radius = radius;
    }
    
    //-   
    //  "prototype",  
    //  .
    Circle.prototype.getDiameter = function(){
        return 2*this.radius;
    };
    var circle = new Circle(2);
    alert(circle.getDiameter()); // "4".

    Circle Circle.prototype, - JavaScript. , , . , . , - , …

    Circle.prototype.getDiameter = function(){
        return -5;
    };

    … , , . , ,   ( «») JavaScript . - …

    Number.prototype.valueOf = function(){return 42;};

    , Number, , , , :

    
    alert((0).valueOf());   //0   0    0,   42.
    alert((1).valueOf());   // , 1  42.
    alert((NaN).valueOf()); //NaN  42.      

    , , , JavaScript , . , - - JavaScript , , . , « JavaScript» .
  • C, JavaScript . , JavaScript, , JavaScript , , , , , , , . , , . , . , , « ». , . JavaScript , , (, HTTP ), JavaScript - . « ». , - , , C++.

I can talk endlessly about the reasons why JavaScript is a cancer sent down to this world. I know that there are people who love JavaScript, and I hope that these people will find the psychiatric help that they so desperately need. I don’t know the answers to all the questions in life, but I know all the things that aren’t such answers, and JavaScript falls into the same category as Scientology, Homeopathy, and putting on tiny sweaters on dogs because of the erroneous opinion that this is what dogs would do if they had access to looms and thumbs.

To summarize, web browsers are similar to quantum physics: at best they offer probabilistic guarantees, and anyone who claims to fully understand them is a liar. At this stage of human development, there are more pressing problems: climate change, heart disease, poor financial situation of Nigerian princes who want to contact you personally. Since all these problems have not been resolved, browsing the web is a terrible way to spend time; launching unstable operating systems written for a fan and downloading strange JavaScript files from strangers - the latestwhat we should do. Instead, we should exchange information using fixed-length ASCII messages written in a statically verifiable subset of the Latin alphabet, with images represented as mathematical combinations of line segments, arcs, and other eternal forms described by dead philosophers who believed that the minotaurs exist, but not able to get out of the labyrinths. It is such clear thinking that will help us defeat the cosmic Egyptians emerging from the Stargate. Well, or whatever. I am American and not strong in history, but I firmly believe that the Greeks spoke Latin to defeat the intergalactic Egyptians. #Give a polemic! In short, I want to say that browsers are too complex to trust. Unfortunately, children are wasting their youth, and the current generation of software developers is convincedthat browsers need more features, not less. So we are invited to rejoice that browsers are turning our computers into small taverns from Star Wars, where everyone is happy and where you can drink a blue drink, if you want a blue drink, and if something goes wrong, then perhaps the Jedi will save you, and if not, THIS IS THE STAR WARS TAVERN, DAAAAA. Space taverns are good, but it's fantastic; it's just a bunch of ridiculous details sewn together to entertain the public. Open your eyes and see that in the real, non-hyperbolic world in which you live, your browser will interrupt the video every now and then and then show the blinking of epileptic pixels, making the same sound that the TVs make in Japanese horror movies before turning pale the child will go off the screen and will void your warranty. It can actually happen,and we have to wash it all away.

All Articles