📜 ⬆️ ⬇️

Three Big Lies about JavaScript

Hi, Habr! I present to you my translation of the article " The Three Big Lies About JavaScript " by Richard Kenneth. This article was written in May 2016, but its relevance, in my opinion, has not disappeared. I am a novice programmer, so errors are possible in terms of "understanding." So…

Three Big Lies about JavaScript


There are two options for lying: a lie we tell others, and a lie we tell ourselves to justify it
There are three big lies that JavaScript fans tell me again and again.

False # 1


JavaScript is the world's most misunderstood programming language.
People do not know how to use it correctly, and therefore they constantly get into all kinds of trouble. And this is a lie, because there is nothing incomprehensible in JavaScript .
')
It is an ordinary imperative / procedural programming language with a small amount of programming functionality (FP) and a controversial “object-oriented” function, called object prototypes. And what is special about it?

Basically, all the problems that arise when using JavaScript are only the fault of the people who use it: they are ignorant, they are lazy, they are used to how programming is done in Java or Python. What do not they know? Functional programming?

Why, then, do people not make mistakes when using other languages ​​of FP, such as C #, Clojure, Dart, Elm, Erlang, F #, Julia, Haskell, Scala and Scheme ? Functional programming is a fairly well-understood paradigm in the IT industry. So what makes JavaScript so particularly problematic in this regard?

Maybe people are not sufficiently aware of the prototype objects. In that case, read "What JavaScript's Object Prototypes Aren't . " Prototypes, of course, are not suitable for software development. They are not a particularly high level of programming abstraction. Prototypes are mostly renowned hash tables, quite a low level, and this is what I call “building blocks” for real object-oriented programming (class-based OOP). People may not understand how to use prototypes of objects, but why do you need to learn to “lay bricks”? It does not deserve your effort.

Yes, I understand. Prototypes are very flexible. They do not possess all the “rituals” on which the classic OTP stands. In this sense, they are fun to use. But they do not scale well for large applications, and therefore people return to classes. If prototypes were such a useful technique, you would see its adaptation everywhere, because prototypes can be modeled in languages ​​based on classes, just as classes can be modeled in languages ​​based on prototypes. And this is something that JavaScript programmers cannot understand.

False # 2


Asynchronous programming is the key strength of javascript. Well, let's first understand why asynchronous programming generally exists in JavaScript .

To develop a graphical user interface (GUI), the event loop is - de rigueur (the usual thing) , whether in Windows , or the X Window , or OS X's Cocoa , or a web browser. They all handle user input events asynchronously. Does this mean that asynchronous programming is also the power of C ++ or Objective-C ? Event cycles (with asynchronous libraries) have also been used in Python and Perl and Tcl . Then, I suppose they all possess the power of asynchronous programming? (I laugh when people use the non-existent word “ asynchronicity ” ( asynchronous is an adjective describing objects or events that are not coordinated in time ).

JavaScript also uses event looping and asynchronous processing to support the user interface of a web browser. Does that make it a great language?

And now this computation model has made Node.js quite popular on the server side, where it is used for non-GUI development, i.e. for high-performance parallelism. Node is obviously useful for many applications, but it is unlikely to capture the world of concurrency. Recent events show the limitations of Node.js. And yes, this should convince everyone to use only javascript.
The cycle of events was described as the “parallelism of the poor.
Node supporters like to show the same examples of large enterprises over and over again (PayPal, Netflix, Walmart, Uber, etc.). So for each Node.js example you can match in response? - hundreds of Java examples? Java has proven itself countless times for development in an enterprise. That is why it is an industry standard. Node.js , has not yet proved itself. We don’t actually know how many corporations tried to use Node.js and eventually abandoned it. We have no idea what the real success rate of Node.js projects are. For an enterprise, choosing Node.js is still a risk.
I confidently predict that Go will crowd out Node in the future as soon as it builds up its ecosystem of frameworks and packages. His trajectory is undeniable.
Languages ​​such as Go and Erlang / Elixir can easily surpass Node in most concurrency scenarios. Even the event / asynchrony cycle model is not sustainable in the long run. We should be interested in using real parallel programming languages ​​if our goal is maximum performance. Why compromise javascript ?

False # 3


JavaScript is the most popular programming language in the world.

Is it really so? There is a huge difference between a language that is widely used by default and a language that is widely used.
Remember that in any area other than the Internet, developers are not hostages of the same language. We ignore this fact at your own risk.

JavaScript is the only native language for the web browser, so this is the most direct way to write a browser application. Most developers, however, despise this language and, if they really had the best choice, they would have made it. You can see this for yourself if you look on the Internet (forums, social networks, websites, etc.) for people's opinions on JavaScript . There are many long lists of WATs and WTFs about JavaScript that you will not find for any other language except PHP . What we know for sure is that the web is very popular, and not JavaScript .

Most major language rating indexes do not indicate that JavaScript is the most popular programming language. Not even the second, nor the third, nor the fourth position. According to IEEE Spectrum, the American Journal is # 8 , PYPL # 5 , TIOBE # 7 , CodeEval # 6 . Redmonk (analytic company) uses Github statistics, which shows a very high number for JavaScript , precisely because web applications written in any language must have at least some JavaScript to work in a browser; here without options. Therefore, Redmonk is not able to give an objective JavaScript anomaly rating; otherwise, the most popular language is Java .

User polls, for example, from StackOverflow, also contain a similar bias in the selection. How can we say that JavaScript is a popular language when we have no choice but to use it only? (Fortunately, translators are available to us).

We should remember that for other areas (for example, network servers, games and graphics, mobile, desktop, etc.). There is a wide variety in the choice of programming language. Web applications are extremely unique. (At least until the release of WebAssembly finally takes place.)

true


Let me be very clear: JavaScript is not a good programming language for software development . JavaScript was designed to be an easy, fresh scripting language for a web browser. As such, it was made to be flexible and extremely forgiving, with weak typing. It does not even have the correct integer type or the correct array type. What language is this!?

Weak typing is the Achilles heel of the programming language with which the software is developed. Although this makes writing quick, simple scripts for a web browser very easy, it also works against you when you write large applications that require security and reliability. That is why most of the major languages ​​are usually strongly typed (not to be confused with statically typed). And this is very, very important!

Weak typing and arbitrary coercion arising from it demonstrate the complete absence of language discipline. This explains most of the list of WATs and WTFs.

spawned by javascript. (further, the author provides links to online resources, where a list of "warts" JavaScripta ).

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


All Articles