Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is JavaScript's road to righting?

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

What I want to share with you in this article is about the road to righting JavaScript. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article. Let's take a look at it with the editor.

When it comes to popular programming languages, it's probably JavaScript,Java and Python. But looking back a few years, ten years, or even 20 years, you would never believe in 2000 that JavaScript will now become one of the most popular languages in the world. At that time, JavaScript was not only unable to accomplish all the functions that professional languages could do, nor was it even designed as a serious coding tool.

Overview

In 1995, Netscape Communications company Netscape realized that it was necessary to give browsers an easily available browser dynamic scripting program to facilitate Microsoft's IE to compete in the market. So before ending up with Sun Microsystems strategic partners, I used the last period of time to have Sun's Brendan Eich create a new language in less than 10 days and embed it in Netscape 2.

And at that time, in order to catch the heat of Java, they called the language JavaScript. But it actually has nothing to do with the Java language. The two similar names Java and JavaScript have caused many people's confusion for many years, but it is still a problem. (JavaScript is now the trademark name of Oracle, and casual use may have copyright problems.)

The beginning of Chapter 1: the era of Scroll Button

In the first five years of its birth, JavaScript was a whiteboard tool for people who could not easily program with Java (Applet). Its fans include amateurs and people eager to do simple tasks. There is also a new group of Web designers whose job is to make the web user interface look more stylish and graphical. What they want is more elaborate than the label and more modern than GIF's spinning globe.

In the area of expertise, this is JavaScript's main job, creating UI glue to glue overdesigned web pages together. You will use JavaScript when you need an interactive button, a pop-up menu, and an image to cross the dynamic effect.

Soon after, JavaScript began to be heavily used to create similar effects: every time the mouse passed over, one image was replaced with another.

While it may seem crazy to think that developers will use code to automatically execute glowing buttons and then distribute their code to web pages, this is what everyone does over and over again. (today, CSS provides this decoration, using styling and animation instead of pre-generated image files, to do this in a more maintainable way.) . Few expect JavaScript to go further. Moreover, many coders prefer to use server-side programming languages to provide correct JavaScript scripts on demand. The idea that JavaScript can support business logic in an application is as absurd as replacing database stored procedures with Excel macros.

Chapter II restrictions: the Prisoner of sandboxie

Today, when people criticize JavaScript, it is usually due to the limitations of its language itself: patching object-oriented functionality, weak type safety, clumsy DOM model, confusion between = and =, and so on. But JavaScript wasn't born that way. After all, there are many ugly programming languages that become important because they appear in the right field at the right time. (such as BASIC,COBOL,SQL and PHP) JavaScript was the only supported language in all Web browsers at the time, and while Web was taking over the world, it must have been in the right place at the right time.

The real limitation of JavaScript is sandboxie, a tightly controlled environment that holds the code in place. Sandboxing isolates JavaScript from the desktop world. For example, JavaScript code cannot directly access the file system, monitor, or any hardware. To make matters worse, it disconnects JavaScript from everything on the Web server, such as the database that stores user lists and product catalogs and the server-side code that runs the business logic. JavaScript is forced to fight alone, but he is also busy all day and has nothing to do but rotate the buttons on the Web page.

Chapter III Rebellion: Ajax and XMLHttpRequest

Fortunately, however, Microsoft did not have much hostility to JavaScript and retained it in IE. And it intends to consume competitors with the concept of "hugging, expanding and extinguishing".

At the time, a team at Microsoft was working on a way to make Outlook's Web front end more responsive. They are building a product called Outlook Web Access that looks like this:

The goal of the Microsoft team is relatively modest. They want to develop an efficient e-mail reader that runs in a browser. Most importantly, they don't want to refresh the entire page every few seconds. Instead, they use a technology that allows web pages to silently check for new emails in the background. This goal doesn't seem like a big deal right now, but keep in mind that Gmail didn't appear at that time, and Google was just there and didn't have much fame.

The Microsoft team created some pipes using an ActiveX component called XMLHttpRequest. The basic idea of XMLHttpRequest is simple: it provides a way for JavaScript code to make Web requests. Just like a browser can contact a web server and make a request (for example, "Hey, please give me a page!") Similarly, JavaScript code can use the XMLHttpRequest object to make its own request (for example, "Hey, please send me some more mail").

All of a sudden, Pandora's box opens, and the Web page starts to call all the resources of the Web server:

Do you need some data in the database? Call the server and query.

Does the server need to perform calculations, security tests, and super secret verification checks? Please also call the server. Most importantly, the display of the page will not be affected when the call is made in the background

But XMLHttpRequest also has a lot of problems. First of all, it has a strange name and inconsistent case, causing headaches for case-sensitive languages such as JavaScript.

Second, as its name suggests, request to send and receive messages using XML. The reality is that a message can be almost anything, plain text, HTML blocks, or JavaScript objects serialized into JSON. But the bigger problem is the supporting technology of XMLHttpRequest. It is built in ActiveX so that it only runs on Windows computers and only on Internet Explorer.

None of these eccentricities stopped it. In just a few years, other browsers have provided their own XMLHttpRequest implementations-the same objects in the code, but without ActiveX hassle.

Although Microsoft created XMLHttpRequest, it has not been fully utilized in its own Web development. It is not even used in their subsequent public Web email system, Hotmail.

Instead, it was Google that first used XMLHttpRequest technology to develop Web products that shocked the world. Google first used and developed a public Web email Gmail in 2004.

Then Google Maps was developed the following year.

These two great products began to make XMLHttpRequest and Ajax technology shine and popular in the world.

Chapter IV upright: the Road to Modern Times

XMLHttpRequest is a key element in changing the JavaScript process. However, there are many inflection points since then.

The JavaScript language has been frozen for years. Market-leading IE browsers are upgraded with operating system upgrades, and version iterations are very slow. Developers are forced to write a large number of scripts to check different IE browser versions to adapt.

In 2006, developers achieved a formal unified solution by using the jQuery framework. Although jQuery is out of date today, it was an essential tool 10 years ago if you spent real time building features rather than solving browser compatibility issues.

Google released a new JavaScript engine called V8 in 2008.

If the advent of jQuery provides wide compatibility for Web developers, V8 provides them with excellent performance. And because the V8 engine is a separate open source component, it can also be used by other projects. Later, as a result, great projects such as Node.js and Electron were born.

In the second half of 2008, the W3C released the first working draft of HTML5. HTML5 itself is not about JavaScript, but is paired with a new wave of JavaScript API. All of a sudden, developers have tools for storing local data, managing browser history, using audio, and running background tasks. The gap between web and desktop capabilities has narrowed again.

Chapter V Nirvana: modern JavaScript

Is JavaScript's success a corollary of its privileges in browsers? Or do you need luck and perfect timing?

I think many of them are for balance and balance. According to the economic theorem, in order to prevent a dominant company, the results of the trade-off between the major companies.

As a result, JavaScript was forced to win. In JavaScript's life, not many people like it. At first there was support for Java applet, followed by Flash and Microsoft's version of Silverlight. JavaScript faced these challengers and beat them all.

The future of JavaScript is a rapidly branching path. JavaScript now has both Node.js running on the Web server and desktop applications (Node.js and Electron). There are also more advanced dialects such as TypeScript, which can be compiled into JavaScript, providing developers with a comfortable way to develop without violating the specification. In the future, with WebAssembly, you may also be completely free of language restrictions, providing developers with a way to use any high-level language they want through the JavaScript engine.

Although JavaScript has many faults, he is indeed the chosen son. Brendan Eich puts JavaScript into Netscape Navigator, and we are trying to load the whole world into browsers. This is the modern Web and the Internet of things in the future.

The above is what JavaScript's road to upright is, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 254

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report