Python vs Lua

Source: Internet
Author: User
Tags comparable
Document directory
  • Comment

Lua and python are not comparable at all.

Source: http://blog.csdn.net/shgaol/article/details/3746477

We often see comparisons between Lua and python on the Internet. However, I think that Lua and Python are not comparable at all. The reasons are as follows:

1. the positioning of the two is different. The positioning of Python lies in its own independent development. That is to say, python is positioned to solve all problems by itself. Lua is positioned to compile with other code, especially C ++ code. A separate Lua has no meaning.

2. From the perspective of solving the problem. Python relies on its increasingly powerful libraries to enable programmers to implement more and more complex problems. Lua itself must be combined with other compilation languages to solve the problem. Take C ++ Lua as an example. C ++ alone, due to the complexity of C ++, provides convenience for solving problems while also causing a lot of trouble for programmers. These troubles mainly involve two aspects: 1. c ++ itself, especially C ++, is a high requirement for programmers. 2. When solving complex problems, the complexity of C ++ program structure and the complexity of logical implementation bring great trouble to programmers for Program Improvement and maintenance. The combination of C ++ and Lua allows c ++ to only provide various basic function libraries for Lua, and Lua calls these libraries to implement various logical functions. This division of labor allows programmers to separate the basic code library and logic implementation code in the program, greatly improving the efficiency and maintenance of the program. Therefore, if you really want to compare Python and Lua from the perspective of solving the problem. In fact, it is a comparison between C ++ and python, but it is not related to Lua.

3. Comparison between Python and C ++. I think the advantage of comparison between Python and C ++ lies in the basic library provided by python, which greatly reduces the requirements of programmers for Program Complexity and maintainability. For example, if C ++ is used for the same function, its programmers may have three years of experience. If python is used for the same function, if Python has a library required to solve the problem, a programmer with one year of program experience may be able to complete it. However, if C ++ and Lua are combined to solve the problem, it may only take half a Senior Programmer and a programmer with only one year of C language experience. Half of the senior programmers are responsible for providing Lua function libraries, and the other programmers only need to use these code libraries to implement logic.

To sum up, the C ++ Lua development mode is the same as the Python source code library development + Python script development mode. However, from the programmer's point of view, C ++ Lua is simpler, because C ++ can provide various function libraries for Lua dynamically, except for the basic Lua interpretation code. Python programmers must be subject to various functional libraries provided by python. Therefore, if you solve some universal and repetitive problems, python is advantageous, because there are a lot of code that can be rewritten, and C ++ Lua must be reconstructed. If it is to solve some non-general problems, if Python itself does not provide a library to solve these problems, the Python programmer must go back to the old path of C ++, haha.

Lua and Python are more suitable for embedding MMORPG?

Source: http://www.kuqin.com/language/20080506/8042.html

It is expected that the new project will select Lua or Python as the script language of the game. In the past, I had been familiar with these two languages, and I had a perceptual knowledge of syntaxes and embedding them into C/C ++ programs. It may be influenced by the KISS Principle in "Unix programming art". Now, I always like concise things. Therefore, I personally prefer Lua.

In the past two days, I have reviewed the documents on the Internet. On Lua's wiki, I saw an article comparing Lua and python:

Python:
1. There are a lot of extended libraries and a lot of Materials
2. the numeric computation is powerful and supports multi-dimensional arrays, while lua does not have the array type.
3. c type (?) Supports Processing dynamic link libraries without C encapsulation (C extension)
4. remote debugger, which seems to be supported by lua extension tool
5. Natural Language-like syntax
6. For string and list support, lua can be implemented through the extension Library
7. unicode support
8. Space-sensitive (do not ignore spaces in the Code), which makes the python code style look better.
9. built-in bit operations, which can be supported by the extension Library
10. The language itself is better at handling errors, which can effectively reduce program errors.
11. More preliminary documents than lua
12. Better support for Object-Oriented

Lua:
1. It is much smaller than python (including compiled runtime libraries)
2. Use less memory
3. Faster Interpreter
4. easier integration into C languages than python
5. Do not use reference count for objects (will reference count cause more problems ?)
6. lua was early positioned in a configuration language (as a configuration file), so it is easier to configure data than python.
7. The language is more nice, simple, and powerful ).
8. lua supports multithreading, and each thread can be configured with an independent interpreter. Therefore, lua is more suitable for integrating into multi-threaded programs.
9. not sensitive to spaces. Do not worry that the editor will replace the tab with spaces.

Useful Comments:
1. Everything is an object allocated on the heap in Python, including numbers. (So 123 + 456 creates a new heap object ).
2. lua's coroutine support is more suitable for Embedded games. Although python is also available, it is not included in core modules.

3. Python was a language better suited to Game AI

I wanted to find some positive information about python (embedded in the game), but I couldn't find it. Objectively speaking, if python is used separately, python is still advantageous. Now we have decided to recommend lua to leader.

Comment # Re: Lua and Python who are more suitable for embedding MMORPG? Jian Gu Han

We are playing games with lua. Let's say a few words:

2. the numeric computation is powerful and supports multi-dimensional arrays, while lua does not have the array type.
-> Tables in lua can be used as arrays.
6. For string and list support, lua can be implemented through the extension Library
-> Lua has a string
8. lua supports multithreading, and each thread can be configured with an independent interpreter. Therefore, lua is more suitable for integrating into multi-threaded programs.
-> Lua itself does not support multithreading. In lua, this stuff is called a collaborative program.

The biggest disadvantage of playing games with lua is that it is difficult to put classes in the Program (including various inheritance relationships and inherit classes in C ++ in scripts) export to the script (it took a lot of time to solve this problem at the beginning). If you can solve this problem, lua is definitely more suitable for games than python.

# Re: Lua and python. Who is more suitable for embedding MMORPG? Kevin lynx

@ Jian Gu Han
It seems that tolua ++ can easily solve this problem.

Comparison of script Efficiency

Source: http://www.timestretch.com/article/mandelbrot_fractal_benchmark

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.