VBScript with JScript who is afraid who (6)

Source: Internet
Author: User
Tags array
Turn from: chinabyte

Obviously, we can get a conclusion from the test results: in a performance-oriented context, mixing multiple scripting languages is generally meaningless. If you want to consider the difference in the results of a two-time pattern-matching test, you should also see that each iteration creates an instance of the RegExp object.

There are two other important conclusions we can draw from these test results. First, if a language itself supports a feature, it is always quicker to use it directly than to borrow another language. Second, if a language implements some function (such as the RegExp object of VBScript, the array of JScript, and the string object) in an object form, and the second language has a more basic implementation, the second language is faster in this respect. Obviously, the cost of creating an object instance is quite high.

Other test results also show this. However, does this prove that JScript is necessarily slower than VBScript as a more widely used object and a language that supports inheritance?

does not necessarily. If we are implementing an N-tier system where complex business logic is always encapsulated into components, the script for ASP pages is more primarily to provide "glue" support for integrating business objects and front-end interfaces. In other words, we are not too much dependent on the script itself or the objects provided by the script.

On some occasions, however, we cannot afford to use objects. As an example of an array, in both VBScript and JScript, a complete array is copied in memory as long as a reference to the element is present. For JScript, this means copying all the properties of an array object as well. Therefore, if the program refers to an array element in large numbers, the cost of using JScript is obviously higher.

Note

We should not forget the first round of testing. These cases are often not run thousands of times in one page, but are called thousands of times individually, and the difference in execution time is less obvious.

In this way, the following reasons may allow us to hastily discard the test results of this article: If performance is important, then we should take advantage of the pool of objects and binary code that COM + provides, and we will benefit far more than we can get from one scripting language to another scripting language. This is true if we consider the decision of the scheme system to be a choice between performance (COM +) and coding/maintenance convenience (scripting language).

But it is impossible to have countless developers with unlimited skills in the real world, which creates many trade-offs and balances between the two extremes, based on factors such as historical conditions, staff status, development time, and so on. However, excluding COM + on some occasions does not imply a complete focus on performance issues. If COM + does not apply for some reason, the test results provided in this article will certainly contribute to your decision.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.