>The JavaScript programming language is widely used for web programming and, increasingly, for general purpose computing. As such, improving the correctness, security, and performance of JavaScript applications has been the driving force for research in type systems, static analysis, and compiler techniques for this language.
Many of these techniques aim to reign in some of the most dynamic features of the language, yet little seems to be known about how programmers utilize the language or these features. This paper performs an empirical study of a corpus of widely-used JavaScript programs’ dynamic behavior and analyzes how and why the dynamic features are used. We report on the degree of dynamism that is exhibited by these JavaScript programs and compare that with assumptions commonly made in the literature and accepted industry benchmark suites.
What is Javascript?
Javascript (JS) is a scripting language, primarily used on the Web. It is used to enhance HTML pages and is commonly found embedded in HTML code. JavaScript is an interpreted language. Thus, it doesn't need to be compiled. JavaScript renders web pages in an interactive and dynamic fashion. This allowing the pages to react to events, exhibit special effects, accept variable text, validate data, create cookies, detect a user’s browser, etc.
The origins of JavaScrip
JavaScript was developed by Netscape, in collaboration with Sun Microsystems. Before JavaScript, web browsers were fairly basic pieces of software capable of displaying hypertext documents. JavaScript was later introduced to add some extra spice to web pages and to make them more interactive. The first version, JavaScript 1.0, debuted in Netscape Navigator 2 in 1995.
At the time of JavaScript 1.0’s release, Netscape Navigator dominated the browser market. Microsoft was struggling to catch up with its own browser, Internet Explorer, and was quick to follow Netscape’s lead by releasing its own VBScript language, along with a version of JavaScript called JScript, with the delivery of Internet Explorer 3.
As a response to this, Netscape and Sunset about standardizing the language, together with the European Computer Manufacturers Association (ECMA). The result was ECMAScript, yet another name for the same language. Though the name never really stuck, we should really be referring to JavaScript as ECMAScript.
JavaScript, ECMAScript, JScript—whatever you want to call it—was gaining ground by 1996. Version 3 browsers from Netscape and Microsoft both supported the JavaScript 1.1 language to varying degrees.
I should point out that JavaScript has nothing to do with Java, a programming language developed by Sun Microsystems. JavaScript was originally going to be called LiveScript. “JavaScript” was probably chosen to make the new language sound like it was in good company.
Unfortunately, the choice of this name really only had the effect of confusing the two languages in people’s minds—a confusion that was amplified by the fact that web browsers also supported a form of client-side Java. However, while Java’s strength lies in the fact that it can theoretically be deployed in almost any environment, JavaScript was always intended for the confines of the web browser.
the language. JavaScript is a scripting language. This means that, unlike a program that does everything itself, the JavaScript language simply tells the web browser what to do.
The web browser interprets the script and does all the work, which is why JavaScript is often compared unfavorably with compiled programming languages like Java and C++. But JavaScript’s relative simplicity is also its strength. Because it has a low barrier to entry, non-programmers who wanted to cut and paste scripts into their existing web pages quickly adopted the language.
JavaScript also offered developers the chance to manipulate aspects of the web browser. For example, the language could be used to manipulate the properties of a browser window, such as its height, width, and position. Addressing the browser’s own properties in this way can be thought of as a Browser Object Model (BOM). Early versions of JavaScript also provided a primitive sort of Document Object Model.
How does javascript work
The web runs on JavaScript and developers use it quite
heavily for different purposes to add different functionality to their web
apps. Imagine how would the web be with just those static pages involving only
HTML and CSS Markup. It would be horrible. To experience this, you can try
surfing the web by turning off JavaScript in your browser. I am sure most of
you will pull your hair out in about half an hour. But this post isn't about
the importance of JavaScript. It's about how it actually works under the hood
inside your browser to provide all that beautiful functionality that we all see
on different web apps we come across daily. This will be quite a short post but
very useful in my opinion and every developer should know this, it gives you a
better insight of how your browsers actually work.
Let's talk about the browser now. Basically, your browser has 3 main programs that do all the dirty work for you to provide you a decent web experience. They are :
1. DOM Interpreter :
All this does is take your Markup(HTML) and display it in the browser. As simple as that.
2. CSS Interpreter :
Yeah, all those beautiful styles that you see on your web page are taken care of by the CSS interpreter. It takes your CSS code, styles the page, and makes it look presentable.
Now comes the most important part.
3. JavaScript Engine :
Every browser has it's own JavaScript engine and they go by different names in different browsers but they all have the same task,i.e., taking up the JavaScript files from the server, interpret them and convert them to Bytecode that can be run on the client's computer. Here are the names of JavaScript engines for these famous browsers :
Chrome has the famous "V8 Engine"(Node.js was built on top of this)
Mozilla has the "Spider Monkey Engine"
Safari has "Nitro"(formerly known as "SquirrelFish")
Microsoft Edge has "Chakra"
Collectively you call all these 3 interpreters JITs(Just-in-time Compilers). This simply means that all the code that is downloaded from the server to the client's computer is compiled in real time on the client's computer itself.
So that's basically what happens behind the scenes. All the code, be it HTML, CSS and JavaScript are in Human readable format but yeah this is exactly what goes on behind the scenes.
>
0 comments:
Post a Comment