📜 ⬆️ ⬇️

2017: Hitchhiker's Guide to the Galaxy Javascript

Deciphering the report by Ilya Klimov at the JavaScript fwdays JavaScript conference.


We will try to track some trends in the development of JS, as a community, as a movement, in the 2017th year. I will try very hard to avoid value judgments. Although anyone I cheat, still will not work. And somewhere in a year you will be happy to open this presentation on YouTube and understand how wrong I was.


So let's move to 2015. Let's see how JS developed.




For me personally, 2015 in JS was marked by anarchy.




We had an explosive growth of all that is possible. I came to every project that came to support, with a revelation in the plan: "what can I expect?"




The leader of this anarchist movement was and remains Babel. If you don’t remember, by the end of 2015 Babel 6 came out. And this game - guess who uses which set of presets. Like real hipsters use Stage-0, and all you can: bind expressions, orthogonal classes, and so on. Guessing how hipster one project was was fun, but didn’t like it. As my practice has shown, I did not like this game only.




Everybody ached: JavaScript Fatique, we are tired of this, people demand change. In principle, change has come.




2016 was a sign of democracy. Finally released Angular2. We have already wanted, on that and wrote. The community has moved from a zoo to sane decisions. There was a Create React App - the embryovtsy showed Dan Abramov that this is cool. Vue2 appeared, which I do not get tired of haipering. Why is the community moving in 2017?




2017th year passes for me under the sign of dictatorship. Diktarura is different. Which of you is familiar with the BDFL abbreviation? "Good life dictator". The first such title was awarded to Guido Van Rossum. Now Linus Torvalds also says that he is a dictator, though he adds that he is not for life. Well, and so on. What is it about - what changed the life, for example, of the reactor community in the 2016-2017th year?


Create React App


Of course, this appearance of the Create React App is a unified way to quickly launch a Reactor application. A way that everyone likes. For example, I recently tried the Create React Native App - generally an excellent way to start an RN project using, as they say, a couple of commands and no headaches, since I'm not a fan of Apple technology - all these horrors with XCode, I try to stay away. What is the beauty? You know, Linux, which I like very much as an operating system, has a good motto: Linux - you can customize everything and you will customize everything. In the case of the Create React App, the motto is: you cannot tune anything, and no one will let you tune it. The idea is that decisions are made for you. The community has adopted some sort of “facebookies”. Under the hood Stage-3. Exclusively these decisions, the majority moves within their framework - when we talk about tyranny.


Prettier


There is another project, for example, for which we regularly fight with my technical director - he is more retrograde than I, although he has a beard, as it should be for hipsters, and not for me. Nevertheless, many large open source projects have already accepted this piece. Prettier takes your beautiful lovingly written code and formats it according to predefined rules. Pay attention, as befits a good dictator, he wanted to spit on your personality. He wanted to spit, that in this scenario it’s convenient for you to keep these two lines like this, because it's pretty. What does he offer in exchange? Unified code. How did we previously distinguish junior from seniera? In particular, the purity of the design code that he writes. Forget it. Now you are writing code, and I pretend that you cannot distinguish between junior and seigneur. Of course, junior is good, when you show the code, there is a chance to get more money. But the bottom line is that when the Prettier first appeared, Dan Abramov created an excellent issue in it: "Please, do not add a configuration here in any way."




In Prettier, there are only five or six settings that are completely holivar: use semicolons or not, use spaces or tabs, indent values, single quotes or double quotes. Why? If you have at least 10 settings that you can turn on or off, then this is 2 to the tenth power, 1024 possible Prettier combinations, each of which should be tested. This is not what everyone wants. Everyone wants to have a piece that allows the code to look the same. Do I agree with the authors of Prettier, how do they make out the code? Not always. Am I willing to tolerate it? I'm ready. Some of my colleagues regularly have pain that Prettier does not agree with them. But then again, as befits a tyrant - who asks? And this is on the one hand good. It's nice when I can take the code in any project, I understand that I don’t need to write a huge style guide, I just say: "listen, we use Prettier, in the pre-hook command, he will fix it all." This is how I struggle with my technical director. He sees the corrected code at the very end, when they start - everything is too late already.


Corporate power


One more trend where in my (and not only my) opinion the JS community is moving is the power of corporations. About 10 years ago, with the phrase "Enterprase JS", hysterical laughter would be heard. Now he heard a little less. Let's see our mainstream.




Google is behind Angular, Facebook is behind React, listen to Vue, well, we all love this beautiful story, as David defeats Galiaf, one person stands behind Vue - Evan Yu, and this is actually not true. If you do not know, the work of Evan Yu is now financed by more than 60% such a small Chinese company called Alibaba. Who runs the JS development, do you think the community? Well, not quite. We have terrible evil guys called TC39 - a program committee that decides whether or not it enters the standard of the next language. How long have you opened the list?




Google, Google, Google, Microsoft, a little Mozilla, Apple, Intel. Are you really sure that these people will defend your interests? Something it starts to remind me of the deputy’s election program. And the most interesting, as long as my assumptions were not justified, I treated this assumption calmly, until I was touched for living. tc-39 / proposal-cancelable-promises - we are all looking forward to the standard language, which was written by a person from Google, who walked-walked, walked to Stage-1 (or Stage-2, I do not remember), and one fine moment was recalled. Why? He said: "people, this proposal meets with very strong resistance in Google, I don’t want to conduct it anymore, and never speak about it with me again." I mean it sounded like that. As a result, we have 2017th, and we still cannot fetch fetch. This is the question of where corporations are moving all this.


One more. You know, never liked CoffeeScript. (I know the sudden transition). However, there was one great thing. She is called the Elvis Operator. When you need to climb into an embedded object, you could instead put a question mark and a dot, and say that if this thing is null or undefined, then return undefined. Some time ago, a story appeared in the React Native blog that we are presenting idx to you - this is a function that does absolutely the same thing as the Elvis operator.




And this is not some kind of magical getter - then all this is done in unison with the Babel plugin for idx, and turns into a chain of if -s. So far, nothing interesting. This can be emulated on Proxy, for example, to come up with many different options. What became interesting to me? Since I am a big fan of static typing, and they said that this thing is fully compatible with Flow (the static typing tool from Facebook), I wondered how they provided it - it’s quite a difficult task to provide correct output of static types. Got into source codes Flow.




The idx function type is $ Facebookism $ Idx. That's all you need to know, how corporations quietly and quietly penetrate our lives. Note that there are more than one such Facebook users announced. The corporation, in this case Facebook, develops the necessary tools (not exclusively), from the point of view from which it is useful for them. This is a business. OpenSource is actually very expensive. A lot of people invest their money in it, many donate their time. And corporations are developing it where we want. We just have to submit.


Ocaml


What is another interesting trend I noticed in the 2017th. Next we start a very optional zone. Short version - learn OCaml.




Don `t come in. Okay, let's go a long way.


Static typing


We all love static typing. No Yes? Good. I don’t get tired of quoting a delightful phrase that people of the JS community are divided into two types: those who understand that we sometimes need static typing and those who are not yet 22. Of course I'm exaggerating. But no one will hide that the last time movement around static typing is gaining momentum. And amazing when Dart appeared? With powerful static typing. And who needed it? I am not asking where is Dart now. This can be asked about half of Google’s projects. Although the third version of Angular-Dart was recently released, the bridge between Angular2 and Dart is quite convenient.




So, we have a typeScript. Which I regularly scold. But, in fairness, he is developing very strongly, with each version improves his type inference. Although in some places it is still useless a little more than full. Not that Facebook pays me. But I like Flow more than TypeScript. Although right now I am writing on the fourth Angular and I am crying.


ReasonML




A little insider, recently inside Facebook there was a gathering of people who saw Flow on OCaml, and they said that it was somehow bad that Flow was felt on the outskirts of the ecosystem, because Flow is an important part of React Native. (So ​​important that they broke the definition of Flow for RN and nobody noticed this for a month - on the issue of "important"). Why is it important? And we want to optimize the code that we generate for mobile platforms based on those static types that will be written in the code. Angular in NativeScript also has such ideas. And what to do? One of the coolest apologists for Flow, Patrick Stafer, posted an interesting tweet: "In the near future, if you show me another mistake, I'll ask you why you are not yet writing ReasonML?"




ReasonML is another Facebook attempt to reinvent OCaml. Why does Facebook bet on OCaml? Well, they liked him. At first there was Reason - you write code on OCaml, and at the output you get code on JS. But recently they released a very, very strange thing - a compiler from JS to OCaml. There is an assumption that Facebook is thinking about transferring its entire front-end stack to OCaml. To do this, they are going to take existing JS implementations, translate them into OCaml, and then plant a billion interns to lick it in Reason. And after that you get a beautiful client code generated from OCaml, a very fast server-side. For example, Facebook's Ovam Flow is written in OCaml and the parser that builds AST (abstract syntax tree) from the text of the JS code is three times faster than the same parser used by Babel. Other things being equal, and despite the fact that this parser is one of the targets for optimizing the V8. Those. V8 team from Google ensures that everything works fast in this parser.


MirageOS



Another thing that Facebook is counting on, which of all of this I like (I’m suspicious of OCaml), is MirageOS. What it is? Everyone loves Docker. If you still do not like him, then you need to urgently love. For deployment and more. A standardized container is cool, the problem is that it weighs under 100 megabytes. Lot! MirageOS is a thing for unikernel build. Those. such a thing that takes your application, ideally, an application that has a minimum of runtime dependencies (people developing Go and OCaml happily waving checkboxes - there’s one binary output without dependencies); and sticks your application to the kernel. Takes only the necessary, in the end you can get a container weighing 5 megabytes. Cool. Facebook probably wants to save space on their servers. This all starts very quickly, deplots very quickly, and I want to believe that they will gain a community. Nobody knows about MirageOS yet.


It was also about (video from the right place): Lighthouse and PWA , WebAssembly , WebVR .


')

Source: https://habr.com/ru/post/328570/


All Articles