With the beginning of the HTML5 era, the market needed a large number of JavaScript programmers. Many specialists in other languages have begun to massively reorient themselves to JavaScript. Many times I have seen how programmers with a lot of experience scolded this, one of the most flexible and powerful, language, not understanding its principles. In this article I will try to tell the essence and philosophy of JavaScript. There will be only 4 lines of code and a lot of things that will not be written in textbooks. I promise that you will love this language, or at least become more effective in it. So let's go!
I will consider in turn the main features of the language and the consequences of them. For example, JavaScript has a
very low entry threshold . If you are familiar with C ++ or Java, you can begin to program it quite tolerably within 15 minutes after meeting. However, in order to do professional things, you need to read the documentation, books on JavaScript patterns, communicate with more experienced colleagues. Most of the "big-bellied and venerable Jedi of programming," of course, do not do this and curse
themselves with language. Maybe it would be better if the entry threshold was higher? I think not (although there would be less criticism). Agree, it is much easier to comprehend the nuances when you can already write workable code.
JavaScript
multiparadigm language . It combines object-oriented and functional approaches. Structured programming and more are also available. This is due to the highest flexibility of the language. Functions are objects of the first kind, variables can change type, objects can get new properties on the fly. Is it good or bad? On the one hand, it creates problems with understanding programmers who are used to the definition of languages such as Java or C #. But this is a small price to pay for efficiency. JavaScript, in most cases, allows you to create applications much faster than its strictly typing comrades. Let me give you just one example: I worked for a company developing an exchange terminal. It was necessary to create a desktop application on .Net C # and its exact copy on the web in JavaScript. C # application was developed by a team of 12 programmers for two years, JavaScript is a team of 3 programmers for a year. You can talk about the difference in qualification, that may have been influenced by other factors, but one way or another, the difference 8 times is indicative.
How did you achieve such a speed of development? Most languages put restrictions, supposedly for our own good.
JavaScript does not recognize the limitations , you can change the code anywhere, anytime, including the flexibility to patch someone else's code. If you compare programming languages with political systems, then, let's say VBA is totalitarianism, you are put in a rigid framework and cannot even see all the sources. C ++ is a democracy, your freedom to wave your hands ends where your companion’s nose begins. It is a good, powerful programming language that limits individual freedom for the common good. JavaScript is anarchy, you can change anything and no one will interfere with you, do not limit your freedom. The problem is that not everyone can live in complete freedom. You need a high internal culture in order not to steal a tractor from a neighbor, even if you don’t have anything for it. The same is true in code, for example, a common practice in JavaScript, not to make private properties truly private. Normal (public) properties are created and an underscore is simply added to their name. It is believed that other programmers will see this and will not use this property without special need. There are situations when laying on the values of a private property or even modifying it is the most direct and correct way. Yes, there are exceptions everywhere, and JavaScript allows us to do them. In such cases, the programmer understands someone else's code and takes responsibility for the consequences. "He can break everything !?" - resent adherents of other languages. About this next item.
')
There is
no fool protection in JavaScript. We believe that all who work on the code are professionals and we trust them. (pause) In a good JavaScript team, all programmers are of the same level. It can be low or high, but should not be too different. Just as in a country where everyone steals, it is difficult for an honest person, or in a society of decent people, a scoundrel immediately gets what he deserves, and in anarchic and uncontrolled JavaScript, juniors will break the Jedi code, and the Jedi will use absolutely incomprehensible for junior (but understandable for any professional) architectural moves, unwittingly reducing their productivity. So is it necessary to reinsure through the language, or is it better to just recruit the right people? Some blamed javascript for what they called "bugs" and "irrationality." For example:
'3' - 2 === 1;
'3' + 2 === '32';
, - . , JavaScript, . 10 . , :
Math.max(2, []);
Math.max(2, {});
, 2, NaN (Not a Number). ? , JavaScript , — . C++ . , , .
— JavaScript . , — . , , , JavaScript Infinity , , , . ? ,
. . , NaN undefined, , , Windows ( ). ,
. - — , . , , NaN, null, undefined, .
JavaScript —
. , , , . , - , , - — , , .… , , , , , . , , . , . , enterprise- — 20 . — , C++ . JavaScript, .
, JavaScript
, , . , , . , . , JavaScript , . , , . , .
, JavaScript,
. , : ? : , , , . ? , . , — . JavaScript, — , , . , , , . JavaScript
.
, JavaScript: , Java C#. , , JavaScript . , .
. , — , .