天天看點

Python、Lua和Ruby——腳本大P.K.

  譯者按:Python、lua和ruby在C/C++是日漸式微的情況下,在java/.net的圍殲中努力抗争的三個當紅小生。在Tom Gutschmidt的著作《Game Programmng with Python, Lua and Ruby》一書中,介紹了三種語言在遊戲中的應用,其中尤為了不起的是在書中最後一章中比較了三種腳本,作者沒有說孰優孰劣,但是讀者你認為呢?歡迎留言讨論。 本文最初發表于戀花蝶的部落格http://blog.csdn.net/lanphaday,歡迎轉載,但敬請保持全文完整。 Python versus Lua Versus Ruby Python、Lua和Ruby——腳本大P.K. Tom Gutschmidt 著 賴勇浩( http://blog.csdn.net/lanphaday ) 譯 So which of the three languages is the best to use on your project? That depends a great deal on what you want to accomplish. To wrap up the book, I've outlined some of the pros and cons of each language in this section. 這三種語言中的哪一種更合适你的項目?很大程度取決于你想達到什麼樣的目标。作為一書的結尾,在這一節裡,我會描述一下它們各自的優點和不足。 Python Pros and Cons Python的優點和不足 The pros of Python are as follows: Python的優點如下: ·         Python has more extension modules than the other languages. ·         Python比其它語言有更多擴充子產品。 ·         Many online Python tutorials exist. There are also plenty of English books and reference materials, many sample scripts exist online, and there is a wealth of introductory material. The Python.org Website is a good place to start looking for these because it has sections for beginners, tutorials, guides organized by topic, and lists of links and references. ·         在網上可以找到很多Python教程。不僅如此,還有大量的英文書籍和資料。Python.org有很多為初學者準備的依主題組織的資料、教程和程式設計指南,此外還有很多連結和參考。 ·         Most folks really enjoy the syntax of the Python language because it appears clean and is easy to read. ·         很多人都喜歡Python語言的文法,因為它清晰易讀。 ·         Python has an edge where libraries are concerned. There are many libraries, and, for the most part, they are well documented. ·         Python在支援庫上大占優勢,因為它有很多庫,而且大部分都有完善的文檔支援。 ·         Lots of tools that tie into Python are available, and they are often easier to find than the tools for Lua and Ruby. ·         很多工具可以用于Python,但難以找到适用于Lua和Ruby的。 The cons of Python are as follows: Python的不足: ·         Existing Python debuggers are considered quirky and slow. Debugging support on Macintosh and consoles is even weaker. ·         現有的Python調試器詭異而且效率低下。在Macintosh(蘋果計算機)和控制台下進行調試是一個夢魇。 ·         It can be difficult to bundle Python with other languages. There are lots of binary DLLs, and Python has (compared to the other languages) a large standard distribution. ·         Python難以與其它語言內建,它有太多的二進制DLL,而且Python帶了巨大的标準釋出包。 ·         Lots of folks really dislike the white space sensitivity of Python syntax. ·         同樣的,也有很多人不喜歡Python對空白符敏感的文法。 ·         Python can be quite slow at times, as everything is an object on the heap. ·         因為堆上的任何東西都是對象,是以Python有時候會慢得難以忍受。 Lua Pros and Cons Lua的優點和不足 The pros of Lua are as follows: Lua的優點: ·         Lua is probably the fastest of the three languages and usually uses the least amount of runtime memory. ·         Lua在這三種語言中是運作時速度最快而且占内在最少的。 ·         Lau has the smallest memory footprint for bundling. ·         內建Lua隻會增加極少的記憶體占用率。 ·         The Lau C API is very well documented and has good examples for integrating with C. ·         Lua的C API有着完備着文檔和很好的例子,可以容易地通過C內建在軟體裡。 The cons of Lua are as follows: Lua的不足: ·         The documentation has improved but is still a bit sketchy overall. Of the three languages, Lua it is probably the least documented (the API being the exception), with the least amount of code comments. This makes for the largest ramp-up time to learn, and there isn't much in the way of introductory Lua material. ·         盡管Lua的文檔已經增進不少,但仍然有所不足。三種語言中,Lua可能是文檔最少的(API方面是個例外),因為代碼中極少注釋,這也增加了學習的難度。另外,對Lua的本質也沒有什麼介紹。 ·         There isn't a lot of built-in functionality for Lua. There is little support if you need to create a large, complex application. ·         Lua内建的功能很少,并沒有對建立大型的複雜應用程式提供足夠支援。 ·         Lua could use a better garbage collectorthe current development is moving towards that now. Right now, Lua GC uses a very simple and traditional simple mark and sweep. ·         Lua應該使用更好的垃圾收集機制,Lua現在的GC仍然使用非常簡單而且傳統的“标記和清除”方式。 Pros and Cons of Ruby Ruby的優點和不足 The pros of Ruby are as follows: Ruby的優點: ·         Ruby possesses fairly good advanced debuggers. ·         Ruby有極好的進階調試器。 ·         Ruby is object oriented from the ground up, and programmers who are OOP enthusiasts or who are used to the OOP paradigm will find the language extremely comfortable. ·         Ruby是最徹底的面向對象語言,對于OOP狂熱者和慣于使用OOP範式的程式員,他們将會發現Ruby是最适合他們的語言。 ·         Ruby has arguably the simplest syntax, with no real rules exceptions. Especially true for OOP enthusiasts. ·         Ruby的文法極為簡單,沒有讓人出乎意料規則,特别适合OOP行家的習慣。 The cons of Ruby are as follows: Ruby的不足: ·         Lack of English documentation. ·         英文文檔極度缺乏。 ·         Fewer existing works and samples for games than with the other languages. ·         與其它語言相比,在遊戲方面所作的工作和執行個體都少得多。