It is an error to replace Lua.

Source: Internet
Author: User

To support a scripting language, JavaScript is undoubtedly a good choice. The biggest advantage is that most people on the internet know what Javascript is, and many people can write one or two lines. Although JavaScript also has some WTF (worse than failure) areas, it does not affect it to become a very successful dynamic scripting language.

After discovering the jint open-source project, I want to finally have a JavaScript engine that can be used on. NET. Do not mention JScript. net. It is already in Microsoft's elimination process, and it is not real JavaScript, not dynamic. I think I can finally get rid of a bunch of Lua problems.

The main problem with Lua is that its syntax is so strange that I will continue to write syntax errors when writing scripts. It's not equal ~ = (How to see if it is equal to or equal to), the separator for calling a method is: rather than a vertex, and else if is elseif ...... Maybe people who have never learned programming will not make these mistakes. But the key to the problem is that its basic syntax is very different from all mainstream languages. No matter what language you have learned before, you have to spend time learning this new language, though it is very simple. Don't forget to have a standard function library.

The second problem is that it does not support Unicode strings. This not only results in relatively time-consuming encoding conversion when passing strings with scripts, in addition, the script lacks a routine that can correctly operate non-English strings.

So I transplanted it to the jint and found many jint bugs. I think it's okay. It's still in Beta. So I took the time to debug and applied several patches to the jint. However, the error message returned by the syntax check during compilation is very bad. In many cases, it may be a riddle and cannot be used to provide the correct information. I think it's okay. It's still in Beta. I reported the bug and patch to their website, and then continued the development of other parts.

Five months have passed, and no new version of jint has been available yet. In addition, there is a feeling that people can leave the building empty. This is one of the problems with open-source projects. Developers may not know where to go on that day. If it is a mature project, it will be okay, and it is very difficult for others to take over.

In addition, when I started the stress test, the script overhead began to appear, and it was too slow. I once thought that it was a script, and the speed difference was several times better. However, when the number of entities is large, the total time is considerable, so that I have to go back to the Performance-first idea. At this time, Lua's lightweight and high-performance features are overwhelming.

Javascript is not a poor language, but a lack of high-quality implementations suitable for game embedding. It is not easy to implement it. It is not only necessary to implement the cumbersome ecmascript specification, but also the various quirks that have been accumulated over the years for Web compatibility. Google's V8 seems to be a good implementation, but it is aimed at web optimization and changes the speed with memory. Lua is almost completely designed for games. It is simple, extremely small, and extremely fast. This also contributed to the importance of Lua in the entire game industry, and wow and farcry used Lua. No way. If you want its advantages, you must accept its disadvantages at the same time. Due to the popularity of Lua, there are many open-source projects related to Lua, there are other alternatives, and there are constantly new projects emerging to promote it to keep up with the trend of technological development. Even if all these resources disappear, it doesn't matter. Lua is very simple and it is not impossible to maintain it by yourself.

 

Note: Some examples of JavaScript WTF are not good, but interesting. Today, as one of the foundations of web, these historical issues can only be solved.

 

"5" + 3 the result is "53"

"5"-3, the result is 2.

 

List of truth in the Javascript world:

''        ==   '0'           //false
0 == '' //true
0 == '0' //true
false == 'false' //false
false == '0' //true
false == undefined //false
false == null //false
null == undefined //true
" /t/r/n" == 0 //true

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.