与操作系统一样,在办公室软件套装和计算机中也具有各种计算机语言。存在这种多样性的原因与其它地方的多样性一样—-因为没有单一的解决方法能够解决所有的问题。有些语言在原始速度上更出色。有些语言能够帮助你更轻松地编写防止崩溃的代码。有些语言非常擅于剖析文本并有效作用于服务器上。有些语言具有强大的公司投资。也有些语言之所以存在是因为它们与大量不适合重新编写的现有代码相兼容。
你的语言选择将影响着你的项目,并且你不可能在项目中途突然改变语言,所以这是你必须重视的一个选择。这也不是一个你能够根据自己的个人喜好或朋友的提议而做出的选择。你关于项目的计算机语言的选择应该是经过仔细研究且务实的。最重要的是你的结果的质量而不是语言是否配得上你个人的编程技巧。
本文将分析一些游戏程序员经常使用的语言。这并不是一个完整或深入的列表。本文倾向于呈现给你最受欢迎的游戏开发语言,同时还会提供一些简短的介绍以及它们在哪种情境下是有利于项目或不利于项目。
如果你还是一位新手,那么这一列表可能会包含一些你并不熟悉的术语,并且也没有足够的空间对这些术语进行详细解释。所以我建议你可以在*上进行相关搜索。
C
C程序设计语言可以说是父辈一般的存在,或者对于本文提到的其它语言具有非常重要的影响。尽管C是源自一些已经被淘汰的其它语言,但是现在它也成为了计算机“根植”语言之一。虽然今天还存在一些比C先诞生的语言存在(如COBOL,FORTRAN,Lisp,Smalltalk)并且与C没有多大关系,但是20世纪80年代以来所诞生的每一种语言至少在某种程度上具有与C语言类似的语法。
C是经典的“支柱语言”,也就是使用开放和关闭的花括号将一些表述组合在一起的有结构的goto-less语言。这是之后许多语言中所呈现的方式(包括C++, Java, C#, ActionScript, PHP)。C语言的无尽结构的一个优势便是一旦你理解了如何基于C语言完成某事,你便能够将其带到其它语言中(并且几乎没有任何改变)。例如C和PHP中的if(), while(), and for()表述都是相同的。也就是说如果你熟悉了C语法,它将在之后带给你非常大的帮助。
优点:C适用于编写简短且快速的程序。这是我们很容易与之互动的语言。该语言本身与库子程序一样都是标准化的,所以讲程序移向其它平台将会是一个直接的过程(如果你事先计划好的话)。
缺点:快速编写小程序的能力对于C来说也是不利的,因为通常情况下C并不是用于对象导向型编程,这是构建更加适合于基于分散式开发的大型程序的方法,而大型C程序很容易变得杂乱无章。尽管许多大型项目是基于C语言Unix,Windows,Oracle进行编写,但是管理一个基于C语言的大型项目要求比围绕着更加模块性所创造的语言更多纪律。
可移植性:尽管语言本身以及ISO功能调用是可移植的,但是这些调用却受限于控制流,简单的内存管理以及文件处理方面。现代用户界面设计,如菜单,按键,对话框等等都是不可移植的,所以你需要编写对第三方UI工具箱是有效的代码或计划再次编写你的用户界面。
尽管这并不是最早出现的语言,但是C程序库却呈现出了它的年龄。像内存管理和附带条件等许多较有意义的程序库功能都拥有一个简单的语法,能够在后续语言中进行有效调整。
尽管为了与时俱进C语言进行过多次的重新设计与调整,但是仍有些语法却是违反直觉的。为了与现有的代码保持兼容仍保留了一些较为奇怪的语言结构。
是否适合新手:并没有很好。尽管C语言非常简洁且容易掌握,但是许多C程序库调用却很陈旧,且很容易用于一些后续语言中。
资源:尽管Kernighan和Ritchie的《The C Programming Language》是该主题的“经典”著作,但是该书只是快速地提及该主题,甚至未能让编程新手们好好理解。不过还有其它值得推荐的相关书籍,如《C How to Program》,《C Programming: A Modern Approach》和《C Primer Plus》。
C++
C++是C语言最早建立的“子”语言。它诞生于20世纪80年代,是作为C语言的延伸版本并支持“类”,这是将原始数据类型和算法聚集到更容易创建现实世界(或者游戏中的模拟世界)对象模型的内容中的抽象数据结构。C++类同样也支持“隐藏数据”概念,在这里你可以将一个对象的根本执行隐藏起来。尽管这一方法看似有点难理解,但在基于团队环境编程时这却非常有帮助。这让你们能够在对象界面如何运行且无需考虑其内部运行方面达成一致意见。这就像是在说“我将给你一份工作,但我不关心你是如何做的,只要你能够完成它,并且结果是我想要的便可。”
优点:完全支持面向对象(OO)的范式,这比支持大型项目的C语言好多了。与C不同的是,它包含了一个带有常见数据结构和算法的设计精巧的程序库。
缺点:随着每一次迭代,C++的算法变得更大且更复杂,现在这一预言完全变成是拜占庭风格了。该算法本身很容易被滥用,虽然C++支持团队变成,但是且巨大且深层次的算法会让代码变得更难读。
可移植性:尽管是源于C语言,C++却拥有比前者更棒的可移植性。引导大多数现代移植工具箱都是执行于C++对象程序库而不受早前的C功能程序库。此外,C++的标准程序库以及非常有用的Boost程序库非常标准化且是跨平台的,尽管这两者都很复杂。
是否适合新手:尽管在C++中内存管理和I/O操作都比C语言好理解,从规模来看C++拥有非常高的学习曲线。他们并不需要为此学习整个语言。
资源:关于C++的一本完美的新手书籍是Steve Heller的《C++: A Dialog》。这是一本节奏适度且容易理解的书,非常适合编程新手。
还有更加全面的方法,即Bruce Eckel的《Thinking in C++》系列将通过1600页内容告诉你所有你需要知道的C++。
你都可以免费下载到这些书籍。或者在谷歌上进行搜索,你便能够找到它们的官网。
C或C++:除“DirectX或OpenGLad”以外,这是在准备学习语言时最常被问到的问题。除了一些较小的例外外,C++可以说是C语言的超集。这意味着所有C语言所做的都与C++一样。每一个C++编译器都将编译C语言,而在今天我们很难找到唯独支持C语言的编译器。尽管这些事实让选择从C语言开始然后再学习剩下的语言更具逻辑性,但是尽早学习类和OO编程将会更有帮助。
Objective-C
Objective-C是带有动态执行时间的对象导向型编程语言。就其本质来看,它就是C语言的一个超集。它集成了来自C语言的基本语法规则,同时也拥有一些构造上的变化。例如它将包含一些方法调用,整体的定义规则等等。
Objective-C是MAC OS X和ioS编程的主要语言,也是专属于苹果的语言。它支持各种开发技巧,功能,程序库以及许多能够凸显该语言的额外功能。该语言支持处理2D和3D图像(基于OpenGL)的广泛嵌入式程序库,这能够帮助许多小型游戏开发者通过使用强大且原生的解决方法创建自己的第一款游戏。其它程序库也能够帮助游戏开发,特别是手机游戏开发。还有一个突出的功能便是引用计数垃圾收集器,与非常复杂的内存管理系统相互协作。
优点:Objective-C是C语言的一个强大超级,能够创造并允许强大且灵活的应用。它能够利用C/C++代码并轻松移植全新项目,扩展现有的能力等等。该语言能够拥有各种有帮助的程序库以及Xcode最佳的开发环境之一。这是一直能够基于多种方式进行使用的强大OOP语言。
缺点:Objective-C是专属于苹果的语言,因此你需要拥有一台苹果计算机,运行最新的Mac OS X版本才能开发你的应用。另外一件需要注意的事是该语言的有些语法规则可能会让新手感到困惑。方法调用远未达到标准,类定义也会引起没有C/C++经验的新手的困惑。此外,如果你计划面向iOS开发应用的话,你便需要掌握基于较高层次的内存管理知识。
可移植性:没有。任何基于Objective-C进行编写的内容都必须属于苹果的产品。如果未基于其它语言重新编写,你便不能移植Objective-C项目到任何平台上。也就是说Objective-C只适用于Mac OS X和iOS开发。
是否适合新手:Objective-C并不是最适合新手的语言,尽管它也不是最复杂的。如果学习C#或Java的话你会更轻松,然而相对于C++,精通Objective-C会更简单。新手通常需要阅读许多关于内存管理等理念,如果你刚刚起步,这有可能是一个较为困难的过程,但是将带给你长期的帮助。
资源,除了官方的苹果向导,在onlineprogrammingbooks.com上还有许多有帮助的免费电子书—-http://www.onlineprogrammingbooks.com/objective-c/
参考:
Objective-C基础:
http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html
http://www.otierney.net/objective-c.html
http://mobile.tutsplus.com/tutorials/iphone/learn-objective-c-day-1/
Objective-C内存管理:
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/MemoryMgmt.html
http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html
基于Objective-C的游戏开发:
http://people.oregonstate.edu/~doneb/downloads/iPhone%20Game%20Development%20Developing%202D%20%26%203D%20games%20in%20Objective-C~tqw~_darksiderg.pdf
http://www.idevgames.com/articles/for-beginners/2
Objective-C与Java的比较:
http://assoc.tumblr.com/post/28261068461/objective-c-versus-java
Objective-C与C++的比较:
http://www.mactech.com/articles/mactech/Vol.13/13.03/CandObjectiveCCompared/index.html
一般的iOS开发与Android开发的比较:
http://java.dzone.com/articles/android-vs-iphone-development
Java
从实用性来讲,Java可以说是第一种“网页”语言。尽管像Perl等语言会突然发现它们处理字符串的能力在恢复价值和发送HTML到网页浏览器上是天生的,但是Java是最早发现自己是根植于浏览器中,最初是在一个有趣但却非常古怪的HotJava浏览器(基于Java本身进行编写),而之后又以现有浏览器的扩展形式呈现出来。
尽管从表面上看其结构与C和C++类似,但是Java的后端表现却与这两种语言不同。比起编译Java源代码到原生及其代码中,Java编译器将编译由Virtual Machine或VM所运行的“字节码”。Java字节码是一种汇编语言,但却不是与特定处理器有关系的汇编语言。Java VM是字节码的运行时解释器,将为你的机器目标处理器解释字节码。这一方法的优点在于,如果目标及其拥有可兼容的Java VM或Java所承诺的“编写一次就能够在任何地方运行”,你便可以在不同机器间移动Java字节码,并且可以无需做出任何改变而运行。这一方法的缺点在于Java字节码并不是原生机器代码,尽管像“及时”编译器能够完善VM性能,但实际上你是在运行时间做一些解释,这将引起较小但却可衡量的性能打击。
还有其它缺点便是,Java的现实性并不符合语言的早期承诺。尽管在网页中执行游戏的理念几乎能够马上让所有人动心,但现实是Java VM并不能与所有内容兼容,使用特定VM而编写的Java应用或支程序可能不能运行于带有其它VM版本的机器上。“编写一次就能够在任何地方运行”被改为“编写一次便能够移植到任何地方”,也就是说一旦你完成你的Java代码的编写,它便能够有效地运行于一个平台上,然后你所面临的重要任务便是确保你的应用能够有效运行于所有系统上。
Java的第三个缺点便是源自其GUI。尽管首次“传递”促使Java GUI使用原生的OS控制(按键,滚动条等等),较小且较快,但却没有深度。下一次传递Swing虽然看起来好多了,但是表现仍然很早,并且完全不同于最初的控制。最糟糕的是Sun(Java之父),太慢了,难以添加现有的OS功能,就像关于ClearType字体渲染的支持。因此,Java应用总是着眼于一些与现代化不着边的版本。
但是在服务器编程方面,Java便扬眉吐气了。VM的一大优势便是,它并非真正的处理器,只是一个模拟,所以销毁VM并不是多大的问题。如果你对于Java VM感到困惑,这并不会真正影响基本的操作系统,你大可以选择关闭并重新开始,并且不需要重启整个机器。再加上Java的内存管理模式是源自C++和C语言,所以像分配内存(无需将其带回之前的系统)这样的问题便不再是多大的问题了。像这样的系统非常适合服务器环境。服务器可以突然出现并在必要的时候消灭VM且不会对潜在OS造成任何影响。同样地,GUI问题也并不适用,如果你的服务器软件看起来并不壮观,它便一点都不重要,除非你想要给服务器管理员留下深刻印象。今天你将会发现许多商业大型多人游戏在服务器端使用了Java。Three Rings的多人游戏便是个很好的例子,他们不仅在客户端,同时也在服务器端使用了Java语言。
Java发挥重要作用的另一个领域便是手机市场。J2ME(Java 2,Micro Edition)是带有删节类程序库(游戏包注:专门为在手机和其它较小的设备上运行而设计的)的Java VM的微小版本。实际上,如果你包含了手机目标群体,Java可以说是现在最受欢迎的平台之一。
优点:Java的Virtual Machine加上其内存管理和不再需要的内存的自动收集让你能够创造非常诱惑力且足以避免被摧毁的软件。它同样也带有强大的扩展文件传统。
缺点:Java的“编写一次便能够在任何地方运行”的承诺未能兑现。Java类程序库已经经过多次重新编写且未删除早前的调用,所以即使程序库与早前的代码是反向兼容,似乎还有三种方法能够做到一切,除了因为“过时”而被拒绝。
可移植性:非常不错,但却不像想象中那么棒。基于Java创造一款可移植且能够使用潜在的OS最新功能的应用与在C++上这么做一样困难。
是否适合新手:非常适合。尽管在不遭遇弃用对象的前提识别执行某项任务的“正确”方式对于那些还在摸索语言的新手来说有点困难,但是语言本身的核心是很容易理解的。同样地,Java也是许多大学课程的标准语言。
资源:Oracle Inc.拥有许多对Java程序员有帮助的优秀资源。
.NET Languages(特别是C#何Visual Basic)
.NET是微软对于Java VM的基本答案。实际上,.NET是以整体技术命名的。真正的VM名字是CLR(公共语言运行时),之前所谈论的关于Java VM的一切内容都适用于CLR,但也有一个例外:CLR从一开始便不是用来“匹配”单一语言,就是Java那样。因为这样,有许多语言使用了CLR去执行后端处理。不管是像COBOL和FORTRAN这样的早前语言还是像Python这样的现代语言都能够瞄准CLR。需要提醒你们的是,有些CLR项目是小型的单人项目,所以如果你在CLR版本中找到你最喜欢的语言也不要太过兴奋,因为在这里有些编译器还不够成熟。
微软所开发的C#和Visual Basic都是最受欢迎的CLR语言。C#是源自Java的语言,它带有90%的Java语法,尽管从表面看它更像是源自C或C++。C#拥有一些很棒的语言扩展,即基于Java慢慢添加的内容,并重新编写了类程序库。
简称VB.NET的Visual Basic是CLR执行以及对于微软已建立且受欢迎的Visual Basic环境的替换。尽管它仍被称为“Basic”,但却不再是全部大写,它与早前的BASIC解释器(贯穿于20世纪80年代所出售的所有计算机的ROM中)只带有少量的相似处。现在,它的语法与本列表中的其它语言非常相似,尽管它仍然未使用括号去整合某些内容。它同样也使用了更具对象导向型“点记法”去调用功能而不受语言的前CLR版本的更大的功能程序库。
优点:尽管Java并未投入太多努力面向Java VM编译语言,但是CLR从一开始便是为了支持这一点。因此存在许多基于CLR的语言,并且它们很容易进行互通。
.NET技术获得微软的Visual Studio环境的大力支持,而这也是一个非常成熟且具有丰富的功能的开发环境。
C#对于微软的XNA技术来说应该算是首要的编程语言,这是创造在Windows和XBox 360游戏主机间可移植游戏的一种方法。
缺点:与Java不同的是,CLR应用不能像网页中小程序那样运行。尽管“Silverlight”技术允许这点,但是对于游戏来说这却太迟了,并且不能像Java和Flash那样根植于浏览器中。
基于CLR的应用比想象中更难移植。
可移植性:尽管存在第三方将CLR移植到到除Windows外的其它操作系统,但是基于这一方向的努力却远小于面向Windows的努力。所以尽管你可能面向Windows创造一个非常有活力的.NET应用,但是你在Mac和Linux上的执行却不会多么顺畅。
是否适合新手:都适合。这两种语言都是很直接且容易理解的。此外,它们与Visual Studio环境的紧密关系也让设置变得更加简单。
资源:Microsoft.com
Flash和ActionScript
Flash在这一列表中算是一个不寻常分子,因为它并不是源自语言本身,而是伴随着一个动画工具诞生。在20世纪90年代,一些开发者对在网页上呈现动画图像所要求的规格以及它们所呈现的方法感到震惊,所以他们便创造了一个名为“FutureSplash”的浏览器插件以及一个能够创造紧凑的向量式动画的绘制和动画工具。互动网页业务巨头Macromedia(已经拥有能够通过自己的Director动画工具播放内容的Shockwave插件)购买了FutureSplash,并将其重命名为“Flash”。
在经历了几个版本后,Macromedia添加了一个JavaScript子集,将“ActionScript”整合到插件中,于是Flash便成为了一个完整的编程环境,尽管它经历了几个语言版本,并且开发工具也发展成对除简单网页游戏之外的内容有帮助的优秀环境。今天,属于Adobe的Flash是基于ActionScript 3,这是完全执行了ECMAScript标准并且与本列表的其它语言一样具有重要作用。
几年前,Adobe公开了一个名为“Flex”的工具,即尝试着将Flash发展成更加适合创造基于浏览器的用户界面和RIA内容,而不再只是针对于动画和游戏。尽管并不是Flash的替代品,但是Flex比前者更适合创造用户界面,因为它是带有丰富UI支持而不是只伴随着固定变成语言的动画工具的XML编程语言。
基于最近的Flex版本,Adobe公开了一个名为AIR的产品,它能够从浏览器中分离Flash内容。使用AIR和一些新创造的对象(游戏邦注:致力于帮助Flash内容使用更多机器资源而不只是浏览器插件),你将能够从Flash中创造优秀的可执行内容,并运行于各种平台上。
优点:Flash完整的绘制和编程工具让编写基于网页的游戏变得更加简单。尽管没有Visual Studio血统,Flash环境仍具有非常丰富的功能。
缺点:尽管对于一个人来说是个很棒的环境,但是Flash却不能有效支持团队编程。
尽管Flex编译器是免费的,但是FlexBuilder Flex内容创造工具却不是。
与这一列表中的其它语言不同的是,ActionScript是针对于客户端的技术。尽管有些服务器端的ActionScript解释器可能会阻碍你学习单独的服务器语言,但事实上却不存在这样的情况。
可移植性:Flash执行时间播放器可以允许于Windows,Mac,Linux多种手机以及一些游戏主机上。但并非所有设备都支持同样本本的Flash,所以你需要学习每周版本的能力,并在开始前决定好目标平台。
是否适合新手:非常适合,特别是结合其绘制和动画工具。尽管容易在Flash环境中创造内容,但却不适用于其它语言。例如,C++使用的一种技巧或创造工具可能在Java中拥有等价内容,反之亦然。但是Flash的开发环境却与其它语言不同。
资源:就像微软是能够满足你的所有.NET需求的万能商店一样,Adobe对于Flash也是这样的存在。
Python
与之前提到的语言不同的是,Python并不是始于一家大型公司或大学项目。它更接近于大学学生的基层工作,并且在之后变成产业中喜欢语言结构以及缺少就功能的人的选择。该语言本身非常紧凑且很容易使用。我们同样也能够轻松地将Python语言解释器整合到现有的项目中,这也是为何你会发现Python作为许多游戏的内涵脚本语言的原因。
呈现了许多Java的服务器友好型属性的Python也是非常棒的服务器语言。实际上,Python编译器能够棉鞋Java VM和微软的CLR编译Python代码。你会发现许多服务器(游戏邦注:如YouTube,谷歌和雅虎)都使用了Python进行后端处理。
基于用户支持的PyGame程序库,Python在游戏社区越来越受欢迎。PyGame是一个能够将已建立的SDL跨平台图像程序库抽象化为一些容易使用的Python内容的对象程序库。一些让人印象深刻的游戏都是使用Python进行编写。
优点:是一种免费的开放源。专注于用户社区。能够完全整合到谷歌的AppEngine—-这是谷歌的“付费”处理服务器。
缺点:事实上,几乎所有处理都不是经过一家大型公司而是通过其用户社区,所以这可能是为了让公司签订一个Python项目的强行推销方式,尽管一些巨头已经在Python做出了巨大投资,所以现在的Python不再像过去那样作为一种“业余语言”了。
可移植性:非常好。大多数适合Python的第三方程序库都是围绕着像SDL和OpenGL等可移植技术进行创造,所以我们能够基于Python轻松编写一些可运行于任何平台的内容。
是否适合新手:Python语言拥有能够轻松上手的语法并且很容易学医。此外,还存在一些很棒的社区编写教程。
资源:Python.org拥有所有与Python相关的内容。这同样也是许多活跃社区论坛的*,在此你能够获得各种问题的答案。
汇编语言
关于汇编语言你必须了解两件事。
语言的名字是“汇编”。将汇编语言转换成低级别的机器编码的工具名字是“汇编程序”。这是一个很常见的错误,甚至连有经验的程序员也会犯这样的错误,即将语言称为“汇编程序”。所以请先叫对它们彼此的名字。
默认情况下,汇编语言是本文中最小且最快的语言。因为它并非高级语言,但却是你的CPU指令系统助记码代表,任何基于高级语言所编写的内容都能够快速用汇编语言呈现出来。
鉴于以上事实,你可能会认为你的研究就此结束了。毕竟,如果一种语言是最小且最快的,又有什么不使用它的理由呢?实际上,为什么其他人会在你能够基于汇编语言编写代码并获得最佳结果的时候还费心去研究C或C++呢?
那是因为“最佳代码”这一词并不是指代你的程序的原始速度和规模。存在可读性,就像你可能需要递交部分代码给同事让他能够基于这些内容完成自己的任务。存在可移植性,即你可能需要将代码移植到其它操作系统或硬件体系结构中。存在可维护性,即需要能在项目快结束时轻松解决问题。存在抽象性,即你可以基于向下移动角色而不是操控内存中的数字去编写代码。
基于所有的这些元素,汇编语言绝对是最后一位。汇编语言很难读也难以维护。除非经过仔细评述,否则很少有人能够传承其代码。修改漏洞以及延伸现有的代码很复杂。你必须不断专注于可移植性,以防你最终编写出不能运行于来自同一制造商的不同处理器模型。
实际上,汇编语言从未被用于完成游戏。汇编语言通常是作为程序的一部分将执行计算并会经过多次调用。有时候修改功能中的一些机器指令将帮助你创造一些额外且有价值的内容。但却不是在项目已开始便能够执行的过程。这是在早前测试所执行的,即在决定变成瓶颈到底出现在哪里时。
汇编语言并非最热门的选择,如果你阅读了这篇文章并尝试着明确该选择怎样的语言,你便可能会转向其它语言。
优点:如果你知道自己在做什么的话这可能会是最快且最有影响的方法。
缺点:如果你正在阅读这一内容,你可能就不知道自己在做什么。所以请准备好花较长时间去学习无数能够推动处理器棒的技巧。
可移植性:糟糕透顶。除非你正在面向基本处理器编写代码,否则你的程序可能不能运行于其它“可兼容的”处理器上。例如,AMD处理器上一些特殊的指令在Intel上便不可行,反之亦然。
是否适合新手:一点都不。
资源:如果你想要面向Intel处理器编写代码的话,面向基于Intel的计算机的汇编语言便是个很好的推荐。但如果不是的话,你应该着眼于目标CPU的制造商。
服务器语言
尽管上述提到的许多语言都能够有效作用于服务器上,但是它们所围绕的许多技术都较为陈旧,而现在也存在更容易使用的解决方法。关于为网页编写一个定制后端的最初标准是所谓的CGI,这是在服务器端运行一个定制的可执行文件的一个定制后端,将在网页上传输数据,并收集文本输出内容然后将其回传给用户。尽管这在服务器端很容易执行,但这却并未按照今天网页的使用方式去创建互动体验模型,最好的情况便是面向互动网页应用的CGI解决方法会很笨拙。
PHP
PHP是最早的网页“嵌入式”脚本语言之一,并且它将给予多种方式改变所编写的网页。尽管PHP可以作为一种脚本语言,基于网页形式获得输入内容,处理它并返回输出内容,但是其真正优势是在于作为超文本预处理器的作用。一旦被设置为服务器的预处理器,PHP便能够处理嵌入页面中的代码。所以比起编写一个独立代码,在一个页面上打出当前日期,你可以选择直接将PHP代码嵌入印有日期的网页中,如此代码将被最终文本所取代。PHP同样也能够添加本机命令程序库与强大的MySQL数据库进行交流,从而是保存和检索持久数据变得更简单。
推动PHP瞬间倍受欢迎的另一点是价格。它是免费的,因此帮它基金了名为LAMP(Linux,Apache,MySQL和PHP)的服务器配置中。这4个技术的结合为刚起步或低预算的网页设计师提供了免费切容易使用,的强大网页设置。作为奖励,它还能够基于低成本的硬件而运行。这对于网页开发者并没有影响。在今天存在许多待执行的免费货低价PHP脚本,不管是简单的用户数据库还是完整的网站设置。
ASP.NET
不甘示弱的微软很快便基于微软的技术,也就是Windows,Internet Information Server(微软的网页服务器),CLR和SQL Server,组合了自己的PHP式的配置。尽管并不是免费的也不属于PHP联盟,ASP.NET却拥有所有技术支持费用能够买到的优势,且能够支持除PHP外的语言。如果你非常熟悉客户端的Visual Basic,你便能够基于ASP.NET在服务器端使用它。
但如果你的预算非常有限,LAMP设置可能会是更好的选择。
Ruby on Rails (通常简称为Rails)本身并不是一种编程语言,但却是伴随着Ruby编程语言的一个类程序库架构。尽管Ruby本身是一种不具有重大改革性的对象导向型脚本语言,同时集成了Python和Perl,但是其Rails程序库却创造了系统改革。Rails程序库完全整合了MVC(Model View Controller)范式并致力于防止技术的重复。这让你能够基于较小的代码创造一个相对丰富的服务器系统。Rails使用者将能够自豪地炫耀基于少量代码所编写的网页论坛和社交网站。
与PHP一样,Ruby on Rails也是免费的。
值得一提的其它语言
上面全部是关于在游戏开发世界拥有自己一席之地的语言,不管是在客户端还是服务器端。也就是说大规模或受欢迎的游戏都是使用这些语言进行编写。但是仍有一些并非游戏一流语言,但却呈现了许多希望的有趣的技术存在。我们将会在未来的一些重要项目中看到这些语言的出现。
JavaScript
我们已经在关于Flash和ActionScript的部分中简要提及了JavaScript。JavaScript拥有与ActionScript同样的根源,这两种语言可以有效地组合在一起。JavaScript最早获得关注是因为作为编写网页脚本的语言,而今天它却是作为推动,延伸并说服网络浏览器按照你想要的方式去呈现网页内容的语言。如果你曾经因为为了适应页面内容而调整自身规格的网页而烦恼,你便可以选择JavaScript。
但JavaScript的作用不只是解决让人烦恼的网页问题,它也成为了编写台式机上所有有趣但却无用的小工具的语言。此外,该语言非常完善,足以用于编写一款完整的游戏,如果是基于小工具框架的话,便能够在浏览器或单机中运行。
还存在两个主要问题阻碍着JavaScript成为网页游戏中更受欢迎的语言。第一个问题便是,与Flash插件不同的是,JavaScript的解释器是依赖于浏览器制造者。尽管语言是基于非常完整的ECMA标准,但是浏览器所使用的JavaScript执行在语言功能和性能中却是不同的。因此我们很难编写一个能够运行于所有浏览器上的强大的JavaScript应用。
第二个问题便是关于你的知识产权的保护。JavaScript并不是作为源代码进行编译,然后再由浏览器本身进行解释。尽管存在一些有效的工具能够向你的用户隐藏代码,但是你的游戏的源代码却从未能逃离你的浏览器的“查看源代码”指令。如果你并不想你的游戏被模仿/改变/偷走,你就应该仔细着眼于一些有效的安全性解决方法。
D
D是C,C++和Java的“非官方”子孙。这是Walter Bright(游戏邦注:作为PC上C和C++编译程序构造的先驱之一)脑力劳动的产物。随着不断发展的类程序库以及对于反向兼容性的需求所带来的各种压力,Bright决定从头开始创造某些内容,汲取C,C++和Java的最佳功能,同时舍弃任何不具有存在下去的正当理由的内容。结果便创造了一种比其前辈更紧凑且更容易学习的语言,且无需牺牲任何重要的功能或运行速度。D是当你将语言设计带离整体领域的产物。
尽管D以简洁的名义舍弃了反向兼容性,但是它却拥有与C代码交流的有效方法,所以如果你拥有第三方程序库或一些你不愿意重新编写的C源代码,你便可以轻松地与之进行沟通。
也就是说如果D能够获得更多支持,它便可能成为世界上最棒的语言。它只是还未拥有巨大的代码程序库,丰富的工具,以及其它语言的用户支持基础罢了。希望关于该语言的支持能够不断发展,并且它也能够获得更多关注,即使这还需要花费一些时间。
结论
一开始我便清楚在关于到底该使用怎样的语言,本文是不可能达到一个让人满意的结论。实际上,并不存在能够解决所有问题的单一解决方法。希望这一列表至少能够帮助你预留出2至3个不错的候选对象。而剩下的研究便取决于你自己。
幸亏上述所提到的几乎每一个解决方法都拥有免费的执行过程,所以你可以尝试这些语言并选择最适合你自己项目的对象。
(本文为游戏邦/gamerboom.com编译,拒绝任何不保留版权的转功,如需转载请联系:游戏邦)
What Language Do I Use?
By John Hattan
Like operating systems, software office suites, and computers themselves, there exist a large variety of computer languages. And the reason for such variety is the same as the reason for variety anywhere else — because there is not a single solution that solves all problems. Some languages are better at raw speed. Some languages make it easier to write crash-resistant code. Some languages are very good at parsing strings of text and work effectively on a server. Some languages have very large corporate investment. And some languages still exist because they are compatible with large amounts of existing code that is impractical to rewrite.
Your choice of language will affect the rest of your project, and it’s impossible to change languages in the middle of a project without a complete (or at least very extensive) rewrite, so it is not a choice you should make lightly. It is also not a choice that you should allow to be colored by your own personal preferences or the urging of friends. Your choice of computer language for your project should be well-researched and pragmatic. What counts most is the quality of your results and not that the language be worthy of your programming skills.
This article will cover some of the languages that are popular with game programmers. This list is neither complete nor deep. This article is intended to give you a bird’s eye view of the most popular game development languages out there along with a short overview and a few situations where they would be a good or a poor choice for a project.
One final note before you read the list. This list does include plenty of terminology that might not be familiar to you as a beginner, and there simply isn’t enough space to define everything. It is recommended that you keep Wikipedia handy for the terminology with which you are not yet familiar.
C
The C Programming Language is either the direct parent or a heavy influence to every other language discussed in this article. While it was itself derived from a couple of other languages that have fallen into disuse, C is now considered to be one of the “root” languages of computer science. Some other languages that predate C (COBOL, FORTRAN, Lisp, Smalltalk) are still in use today and owe nothing to C, but just about every language that’s been produced since the 1980′s owes at least some of its syntax to C.
C is a classic “brace language”, which is to say that it’s a structured goto-less language that uses the open and closed curly-braces to group statements together. It’s a structure that’s repeated in many of the languages that follow (C++, Java, C#, ActionScript, PHP). One advantage of the endlessly-imitated structure of C, braces and otherwise, is that once you understand how things are done in C, you can carry them over to the other languages with almost no changes. The if(), while(), and for() statements in C and PHP, for example, are basically identical. For that very fact alone, it is recommend that you familiarize yourself with C syntax, as it is something that you can keep with you.
Advantages: C is good for writing small fast programs. It is easy to interface with assembly language. The language itself as well as the library routines are standardized, so moving programs to other platforms can be a straightforward process if you plan ahead.
Disadvantages: The ability to write small programs quickly also works against C, as C is not normally used for object oriented programming[note], which is a method of structuring your code that’s better suited to large programs with distributed development, and large C programs can grow disorganized easily. While many very large projects have been written in C (Unix, Windows, Oracle), managing a large C-based project requires more discipline than in languages that are built around more modularity.
Portability: While the core of the language itself and the ISO function calls are very portable, these calls are limited to control flow, simple memory management and simple file handling. Modern user-interface constructs, like menus, buttons, dialog boxes, etc., are not portable between platforms, so you will need to either write your code to work with a third-party UI toolkit or plan to write your user-interface twice.
While the language was ahead of its time when it was created, the C library is showing its age. Many non-trivial library functions, like memory management and strings, have a simplistic syntax that has been significantly tuned up in the language’s successors.
While C has been redesigned and re-standardized several times to keep up with the times, some of the syntax is counterintuitive by necessity. Some of the quirkier language constructs remain for the sake of compatibility with existing code.
Suitability for Beginners: Not very good. While the core of C is fairly compact and easy to grasp, many of C’s library calls are antiquated and are easier handled in some of its successor languages.
Resources: While Kernighan and Ritchie’s The C Programming Language is the “classic” book on the subject, the book does cover topics fairly quickly, and it might be too quick for a rank beginner at programming. Other well-recommended books include C How to Program, C Programming: A Modern Approach, and C Primer Plus
C++
C++ is C’s most established “child” language. It was designed in the 1980′s as an extended version of C with support for “classes”[note], which are abstract data structures that aggregate primitive data types and algorithms into something that is better able to model real-world (or in the case of games, simulated-world) objects. C++ classes also support the concept of “data hiding” in which you can hide the underlying implementation of an object from the rest of your program. While this method seems a bit inscrutable, it is extremely useful when programming in a team environment. It allows you to agree on how the object’s interface is intended to work without regard as to how the object works internally. It’s a bit like saying “I’m giving you a job, and I don’t care how you do it as long as it gets done, and the result looks the way I want”.
Advantages: Supports the object-oriented (OO) paradigm very completely, which is much better than C for supporting large projects. Unlike C, it contains a very well-designed library of common data structures and algorithms.
Disadvantages: The syntax of C++ has grown larger and more complicated with each iteration, and the language is absolutely byzantine now. The syntax lends itself very easily to abuse and, while the language does support team programming very well, its huge and deep syntax can make code difficult to read.
Portability: Despite its roots in C, C++ has better portability than C[note]. This is because most modern portability toolkits are implemented as C++ object libraries rather than the old-style C function libraries. In addition, C++’s standard library and very useful Boost library is very standardized and cross-platform despite the complexity of both.
Suitability for Beginners: While the memory management and I/O operations in C++ are significantly easier to understand than C, C++ has a pretty high learning curve just from its sheer size. Thankfully, one doesn’t have to learn the entire language to be productive with it.
Resources: A perfect beginner’s book for C++ is C++: A Dialog by Steve Heller. It’s very well-paced and approachable, and it’s perfect for beginning programmers.
For a more comprehensive approach, Bruce Eckel’s monumental two-volume Thinking in C++ series will tell you all you need to know about C++ in only 1,600 pages.
As an added bonus, these books are available for free download. Google for them, and you should have no trouble finding the official sites.
C or C++: Short of “DirectX or OpenGL”, this is one of the most-asked questions when getting ready to learn the language. C++ is, with a couple of very minor exceptions, a proper superset of C. That means that all that C does, C++ does the same. Every C++ compiler will also compile C, and C-only compilers are very hard to find nowadays. While those facts might make it seem logical to start with C and then learn the “rest” of the language later, it is a better idea to learn classes and OO programming early on rather than having to “unlearn” techniques that don’t model the environment (real or simulated) very well.
Objective-C
Objective-C is an object orientated, strongly typed programming language with a dynamic runtime. In it’s nature, it is a superset of C. It inherits the majority of it’s basic syntax rules from C, while having some more major changes to the structure as well. That for instance would include method calls, overall definition rules and so on.
Objective-C is the primary language for MAC OS X and iOS programming and is an Apple exclusive. It supports a wide variety of development techniques, functionalities, libraries and many other bonus features that make this language stand out (for more information, see reference). The language supports a really wide range of built-in libraries for handling 2D and 3D graphics (OpenGL based) which can help a junior game developer in building his/her first game bu using a powerful, yet native solutions. Other libraries help game development as well, especially for mobile. Another standout feature is the reference counting garbage collector, working in a close collaboration with the very sophisticated memory management system (see reference).
Advantages: Objective-C is a powerful superset of C and can produce and run very powerful and flexible applications. It can utilize C/C++ code and through that it is easy to port new projects and extend the power of already existing such. The language possesses a really wide variety of helpful libraries and one of the best development environments in the face of Xcode. This is a powerful OOP language that can be used in many ways.
Disadvantages: Objective-C is an Apple exclusive, thus you need an Apple computer, running the latest version of Mac OS X in order to develop your applications. Another thing to note is that some of the syntax rules of the language can end up being confusing for the beginner to intermediate programmer. The method calls are far from the standard, the class definitions are also going to cause some confusion for beginners that have no experience in C/C++. Something else to note – knowledge of memory management on a higher level is absolutely required if you plan to develop apps for iOS.
Portability: There is none. What ever is written in Objective-C stays within the Apple products. You cannot port an Objective-C project to another platform without completely re-writing it in another language. The bottom line here is – Objective-C is only suitable for Mac OS X and iOS development.
Suitability for Beginners: Objective-C is not the most beginner friendly language, though it’s not the hardest one as well. You’ll have an easier time learning C# or Java, yet getting proficient in Objective-C is relatively easier then C++. A beginner will most certainly need to put in a lot of reading into concepts such as memory management, so on and so forth and that can be a painful process to go by if you are just starting out, however it will pay out in the long run.
Resources: Aside from the official Apple guides, there are a lot of free e-books on onlineprogrammingbooks.com – http://www.onlineprogrammingbooks.com/objective-c/
References:
Objective-C basics:
http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html
http://www.otierney.net/objective-c.html
http://mobile.tutsplus.com/tutorials/iphone/learn-objective-c-day-1/
Objective-C memory management:
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/MemoryMgmt.html
http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html
Objective-C for game development:
http://people.oregonstate.edu/~doneb/downloads/iPhone%20Game%20Development%20Developing%202D%20%26%203D%20games%20in%20Objective-C~tqw~_darksiderg.pdf
http://www.idevgames.com/articles/for-beginners/2
Objective-C compared to Java:
http://assoc.tumblr.com/post/28261068461/objective-c-versus-java
Objective-C compared to C++:
http://www.mactech.com/articles/mactech/Vol.13/13.03/CandObjectiveCCompared/index.html
General iOS development compared to Android development:
http://java.dzone.com/articles/android-vs-iphone-development
Java
Java is, for practical purposes, the first “post web” language. While some languages like Perl suddenly found their string-handling capabilities to be a natural for retrieving values and sending display-able HTML to web browsers, Java initially found its footing in the browser itself, first in the very interesting but monumentally quirky HotJava browser (written in Java itself), and later in the form of extensions for existing browsers.
Java, while on its face structured similarly to C and C++, behaves very differently on the “back end”. The Java compiler, rather than compiling Java source code to native machine-code, compiles to “bytecode” that is run by a Virtual Machine or VM. The Java bytecode is an assembly language of sorts, but it is not an assembly language that is married to a particular processor. The Java VM, which is actually a runtime interpreter of bytecode, will then interpret the bytecode for your machine’s target processor. The advantage of this approach is that Java bytecode can be moved from machine to machine and executed without changes provided that the target machine has a compatible Java VM or, as Java promised, “write once, run everywhere”. The disadvantage of this approach is that Java bytecode is not native machine code, and while technologies such as “just in time” compilers can improve VM performance, the fact is that you’re doing some level of interpretation at runtime, and that does entail a minor, but measurable performance hit.
The other disadvantage is that realities of Java have not lived up to the language’s early promises. While the idea of executing games inside web-pages captured everyone’s hearts almost immediately, the reality quickly set in that Java VM’s aren’t as compatible with each other as they should be, and a Java application or applet written on one machine using a particular VM may or may not run nicely on another machine with another VM version. “Write once, run everywhere” was snarkily renamed “write once, port everywhere”, which is to say that once you finished writing your Java code and it’s running beautifully on one platform, you then had the non-trivial task of making sure the application will actually run well and look nice on all systems.
The third disadvantage of Java came with its GUI. While the first “pass” at making a Java GUI used native OS controls (buttons, scroll bars, etc) and was reasonably small and fast, it wasn’t very deep. The next pass, Swing, looked better but performed worse and was entirely different from the original controls. And, worst of all, Sun (Java’s parent) was slow to add OS features that had been in existence in the underlying OS for years, like support for ClearType font rendering. Hence, Java applications always seemed to look a few versions away from state-of-the-art.
There is one place, though, where Java took a good hold and Java’s advantages outweighed its disadvantages, and that was in server programming. One big advantage of a VM is that since it’s not an actual processor but just a simulation of one, crashing the VM isn’t much of an issue. If you do manage to completely confuse the Java VM, that doesn’t really affect the parent operating system, and you can close and restart a session without having to reboot the entire machine. Couple that with the fact that Java’s memory management scheme is a generation evolved from that in C++ and C, and suddenly problems like allocating memory without releasing it back to the system became much less of a problem. And a system like this is perfect for a server environment. A server can pop up and kill VM’s as necessary without affecting the underlying OS. Also, the GUI problems don’t really apply, as it doesn’t matter if your server software doesn’t look spectacular unless you just want to impress server-admins. Today you’ll find many commercial Massively Multiplayer games that use Java on the server side. A good example would be the multiplayer games by Three Rings that are fully Java on the client as well as the server-side.
Another place where Java has very strongly caught on is in the mobile phone market. J2ME[note] (Java 2, Micro Edition) is a “miniature” version of the Java VM with a significantly truncated class library which is designed to run on mobile phones and other small devices. In fact, if you include the mobile phone demographic, Java is one of the most popular platforms in existence.
Advantages: Java’s Virtual Machine coupled with its memory management and automatic collection of no-longer-needed memory allows you to make software that is very robust and crash-resistant. It also has a strong tradition of extensive documentation[note].
Disadvantages: Java’s “write once, run everywhere” promise wasn’t fulfilled. The Java class libraries have been rewritten multiple times without removing old calls, so while the libraries are very backward-compatible with old code, there seems to be three ways of doing everything, all but one of which are discouraged as being “obsolete”.
Portability: Fairly good, but not as good as it should have been. Making an application in Java that is portable and uses the underlying OS’s latest features is almost as difficult to do in Java as in C++.
Suitability for Beginners: Reasonably good. While figuring out the “right” way to do things without bumping into a deprecated object is a bit of a pain for beginners wading through the language, the core of the language itself is well-designed and easy to understand. Also Java is a standard language for many university courses.
Resources: Oracle Inc., the Java authority, has plenty of great resources for Java programmers.
.NET Languages (specifically C# and Visual Basic)
.NET (pronounced “dot net”) is basically Microsoft’s answer to the Java VM. Actually, .NET is the name for the overarching technology. The actual VM’s name is CLR (common language runtime), and everything that was said earlier about the Java VM also applies to the CLR with one significant exception: the CLR was designed from the ground up to not be “married” to a single language, as Java was. And because of this, there are a whole host of languages that use the CLR to do the back-end processing. Everything from ancient legacy languages like COBOL and FORTRAN to modern languages like Python can target the CLR. Mind you, some of the CLR projects out there are little one-man projects, so don’t get too excited if you find your favorite language in a CLR version, as some of the compilers are far from mature.
C# and Visual Basic, both developed by Microsoft, are the most popular CLR-based languages. C# is a language clearly derived from Java, and it shares about 90% of Java’s syntax despite sounding more like something derived from C or C++. C# does have several nice language extensions that Java has been slow to add as well as a completely rewritten class library.
Visual Basic, which was briefly renamed VB.NET, is a CLR implementation and replacement for Microsoft’s established and popular Visual Basic environment. While it is still called “Basic” and is no longer in all-caps, it bears very little resemblance to the old BASIC interpreters that were burned into the ROM of just about every computer sold in the 1980′s. The syntax is now structured similarly to the other languages in this list, although it still doesn’t use braces to group statements. It also uses the more object-oriented “dot notation” to call functions rather than the large function library of the pre-CLR versions of the language.
Advantages: While Java does have a couple of minor efforts to compile languages to the Java VM, the CLR is designed from the ground-up to support this. Hence, there are several CLR-based languages, and it’s relatively easy to get them to communicate with each other.
The .NET technologies are very well-supported by Microsoft’s Visual Studio environment, which is a very mature and feature-rich development environment.
C# is the premier programming language for Microsoft’s XNA technology, which is a method of making games that are portable between Windows and the XBox 360 game console.
Disadvantages: Unlike Java, CLR applications can’t run as applets within web pages. While the “Silverlight” technology does allow this, it’s fairly late to the game and is not entrenched in browsers the way that Java and Flash are. Silverlight has also been discontinued after release 5.
CLR-based applications are much less portable than they should be.
Portability: While there are third-party efforts to port the CLR to operating systems other than Windows, the efforts in that direction are significantly smaller than the work being done in Windows. So while you might be able to create a very robust .NET application for Windows, your Mac and Linux efforts won’t be nearly as smooth.
Suitability for Beginners: Good on both counts (C# and Visual Basic). Both languages are straightforward and easy to understand. In addition, their tight integration with the Visual Studio environment makes setup fairly easy.
Resources: Microsoft.com
Flash and ActionScript
Flash is a bit of an unusual member of this list, as its roots do not exist with the language itself but with an animation tool. In the 1990′s, a couple of developers were dismayed at the size required to display animated graphics on web pages and the method by which they were displayed, so they developed a browser plug-in called “FutureSplash” as well as a drawing and animation tool that could create very compact vector-based animations. Macromedia, already a player in the interactive web-business with their Shockwave plug-in that could play content from their Director animation tool, purchased FutureSplash, renamed it “Flash”, and proceeded to take the browser animation market by storm.
A few versions later, Macromedia added a subset of JavaScript (discussed later), dubbed “ActionScript” to the plug-in, and Flash became a fully fledged programming environment, although it did take a few versions for the language as well as the development tool to “grow up” into a first-class environment useful for content other than simple web-based games. Today, Flash, now owned by Adobe, is based on ActionScript 3, which is a full implementation of the ECMAScript standard and is as capable as anything on this list.
A few years ago, Adobe introduced a tool called “Flex” which was an attempt to “grow up” Flash into something more suitable for building browser-based user interfaces and RIA (Rich Internet Application) content rather than just animations and games. While not a replacement for Flash, Flex is better suited for building user interfaces, as it is an XML-based programming language with rich UI support rather than an animation tool with a built-in programming language.
Along with the most recent version of Flex, Adobe introduced a product called AIR which decoupled Flash content from the browser. Using AIR and some newly-created objects intended to give Flash content access to more machine resources than the browser plug-in, you can now create first-class executables out of Flash (as well as JavaScript, HTML, and PDF) that run cross-platform.
Advantages: Flash’s integrated drawing and programming tools make programming web-based games absurdly easy. The Flash environment, while not having the pedigree of Visual Studio, is extremely feature-rich.
Disadvantages: Flash, while a great environment for one person, does not support team programming very well.
While the Flex compiler is free, the very nice FlexBuilder Flex content-creation tool is not.
Unlike the other languages on this list, ActionScript is a client-only technology. While some kind of server-side ActionScript interpreter might prevent you from having to learn a separate server language, such a thing does not exist.
Portability: Flash runtime players are available on Windows, Mac, Linux, several breeds of mobile phone, and some game consoles. Not all devices support the same version of Flash, though, so you will need to learn the capabilities of each version and what you want to target before you get started.
Suitability for Beginners: Excellent, especially with its aggregation of drawing and animation tools. Although such ease of building in the Flash environment will not apply to other languages. A technique or build tool used in C++, for example, will likely have an equivalent in Java and vice-versa. The Flash development environment is unlike all others.
Resources: Just like Microsoft is one-stop-shopping for all of your .NET needs, Adobe is the place to go for Flash.
Python
Python, unlike the previously-mentioned languages, did not start out as a large corporate or university project. It was much more of a grassroots effort among university students and, later, among people in the industry who liked the language’s structure as well as its lack of legacy features. The language itself is fairly compact and is easy to use. It is also easy to embed a Python language interpreter into existing projects, which is why you’ll see Python as an embedded scripting language in many games.
Python also functions well as a server language as it features many of the server-friendly attributes of Java. In fact, Python compilers exist that can compile Python code to both the Java VM and Microsoft’s CLR. Many services that you would recognize (YouTube, Google, and Yahoo) use Python extensively for back-end processing.
Python is also becoming quite popular in the gaming community with the user-supported PyGame library. PyGame is an object library that abstracts the well-established SDL cross-platform graphics library into something friendly and easy-to-use from Python. Several impressive arcade games have been written entirely in Python.
Advantages: Free and open-source. Very dedicated user community. Integrated fully into Google AppEngine, which is Google’s “pay to play” processing server.
Disadvantages: Virtually everything is handled not by a large corporation but by its user-community, so it might be a hard-sell to get a company to sign off on a Python-based project, although some very big players are now invested heavily in Python so Python now looks like much less of a “hobby language” than it used to be.
Portability: Pretty good. Most of the third-party libraries made for Python are built around portable technologies like SDL and OpenGL, so it’s not too difficult to write something in Python that will run on several platforms.
Suitability for Beginners: The Python language has an easy-to-follow syntax and is easy to learn. In addition, there are several good community-written tutorials out there.
Resources: Python.org is a well-organized home for all things Python. It is also the home of many active community forums where you can get your questions answered.
Assembly Language
There are two things that you must know about assembly language.
The name of the language is “assembly”. The name of the tool that converts assembly language into low-level machine code is called an “assembler”. It’s a common mistake, even among experienced programmers, to call the language “assembler”. So please start out on the right foot by calling the language by its proper name.
Assembly language is, by default, the smallest and fastest language in this article. Since it is not a high-level language but is actually a mnemonic representation of your CPU’s instruction set, there is nothing written in a higher level language that can’t be done faster in assembly
And given fact number two above, you might think your search is over. After all, if a language is necessarily the smallest and fastest of the bunch, why not use it? In fact, why do other people bother with C or C++ or anything else when you can write your code in assembly and get the best results by definition?
That’s because the term “best code” doesn’t just refer to the raw speed and size of your program. There is the quality of readability, as you might need to hand some of your code over to a colleague so he can work on it. There is the quality of portability, as you might need to move your code to another operating system or hardware architecture. There is the quality of maintainability, which is the need to easily fix problems at the close of the project. There is the quality of abstraction, in which you can write code in terms of moving a character down a hallway rather than manipulating numbers in locations in memory.
And in all of those factors, assembly language comes in dead last. Assembly language is very difficult to read and maintain. Unless meticulously commented, it is of little use to anyone else inheriting the code. Fixing bugs and extending the existing code is difficult at best. You have to keep a constant eye on portability, lest you end up writing code that won’t even run on different processor models by the same manufacturer. And the closest you’ll get to “move the alien ten pixels to the left” are some register updates followed by several instructions to call the bitmap-display function.
In practice, assembly is almost never used for complete games. Assembly, when it is used, is used in parts of programs that do a lot of calculations and are called a lot of times. Sometimes whittling a few machine-instructions out of a function that is called millions of times can provide enough of a benefit to make the extra work worthwhile. But this is a process that isn’t undertaken from the beginning of a project. It is something done in early testing, after determining where the programming bottlenecks actually are.
Assembly language is not for the faint of heart, and if you’re reading an article to try to figure out what language to use, then you should probably look elsewhere.
Advantages: Is the fastest and most compact way to go if you know what you are doing.
Disadvantages: If you are reading this, you probably don’t know what you are doing. Prepare to spend a long time learning a million little tricks to shave off processor ticks here and there.
Portability: Worse than bad. Unless you are programming for the baseline processor, your programs might not even run on other “compatible” processors. For example, some special instructions on AMD processors are not available on Intel and vice versa.
Suitability for Beginners: Run away.
Resources: Assembly Language for Intel-Based Computers is well-recommended if you intend to write for Intel processors. If not Intel, check out the makers of your target CPU for technical resources.
Server languages
While many of the languages mentioned above will work nicely on the server, some of the technologies around which they were built are rather archaic, and much smoother easier-to-use solutions are now available. The original standard for writing a custom back-end for web-pages was called CGI, and it was a simple standard for running a customized executable on the server-side, passing it data from the page that called it, and collecting text output and returning it to the user. And while it was simple to implement on the server-side, it really doesn’t model the interactive experience as the web is used today, and CGI-based solutions for interactive web-applications can be clunky at best.
PHP
PHP was one of the first true “embedded” scripting languages for the web, and in many ways it revolutionized the way that pages are scripted. While PHP can operate as a scripting language that takes input from a web form, processes it, and returns output, its real strength is its usage as a hypertext preprocessor. PHP, once configured to work as a preprocessor for a server, can process code that’s embedded the page itself. So rather than writing a piece of standalone code that will, for example, print out the current date in a page, you can just embed the PHP code directly into your web page that prints the date, and the code will be quietly replaced with the resulting text as it is sent to a browser. PHP also added a library of native commands to communicate with the free and powerful MySQL database, making storing and retrieving persistent data easy.
Another thing that made PHP instantly popular was the price. It was free, thus cementing it in the popular server configuration known as LAMP (Linux, Apache, MySQL, and PHP). The combination of these four technologies gave beginning or low-budget web designers an easy-to-use, scalable, and very powerful web setup for free. And as a bonus, it could run on low-cost hardware. And this fact was not lost on web developers. Today there are a large number of free or low price PHP scripts to perform just about any task, from simple user databases to complete “website in a box” setups.
ASP.NET
Not to be outdone, Microsoft quickly put together their own PHP-esque configuration based entirely on Microsoft’s technologies, namely Windows, Internet Information Server (Microsoft’s web server), CLR, and SQL Server. While far from free and not in PHP’s league in the breadth of third-party scripts available, ASP.NET does have the advantage of all the tech support money can buy as well as support for languages other than PHP. If you’re familiar with Visual Basic on the client side, for example, you can use it on the server-side with ASP.NET.
But if you’re working within a budget, a LAMP setup will likely be a better fit.
Ruby on Rails
Ruby on Rails (often just called “Rails”) is not itself a programming language but is a class library built with the Ruby programming language. While Ruby itself is a not-very-revolutionary object-oriented scripting language that owes its heritage to both Python and Perl, it is the Rails library that makes the system revolutionary. The Rails library fully integrates the MVC (Model View Controller) paradigm and is designed to prevent as little repetition of technique as possible. And this does allow you to build a fairly rich server-based system with a minimum of code. And the Rails folks will proudly show off web-forums and social networking sites that have been written in an absurdly small amount of code.
Like PHP, Ruby on Rails is free.
Other Languages That Are Worth Mention
The sections above cover most of the languages that have a pedigree in the game development world, both on the client and server. That is to say that large scale or popular games have been written using these languages. There are, however, a couple of interesting technologies out there that, while not yet established as first-class languages for games, show lots of promise. It would not be surprising to see these languages score some major projects in the future.
JavaScript
JavaScript received brief mention in the section about Flash and ActionScript. JavaScript has the same root as ActionScript, the ECMAScript standard, and the languages resemble each other quite a bit. JavaScript first gained popularity as a language for scripting web pages, and today it’s ubiquitous as the language used to nudge and squeeze and stretch and convince web browsers to display web content exactly the way you want. If you’ve ever been annoyed by a web page that resizes itself to fit the page’s content, you can rest assured that JavaScript was behind that.
But JavaScript is useful for more than just web annoyances. It’s becoming a popular language for writing all of those interesting and mostly-useless widgets that are sticking on desktops everywhere. Even better, the language is robust enough to write complete games, running inside the browser or standalone if used with a widget framework.
There are two primary problems that are preventing JavaScript from becoming more popular as a language for web games (compared to Flash, for example). One is that, unlike the Flash plug-in, JavaScript’s interpreter is dependent on the maker of the browser. And while the language is based on the very complete ECMA standard, the JavaScript implementations used by browsers differ both in language features and performance. Hence it is difficult to write a truly large and robust JavaScript application that works in all browsers.
The second problem is one of protecting your intellectual property. JavaScript is not compiled and is streamed to browsers as source code, which is then interpreted by the browser itself. And while there are some clever tools that attempt to obfuscate and hide your code from a user, the source code to your game is never very far away from the “View Source” command of your browser. If you don’t want your game to be borrowed/improved/stolen, you should first take a hard look at the security solutions available.
D
D is a sort of “unofficial” grandchild of C, C++, and Java. It is the brainchild of Walter Bright, who is one of the pioneers of C and C++ compiler construction on PCs. Growing frustrated with the ever-growing class libraries as well as the fanatical need for backward compatibility, Mr. Bright decided to build something from the ground-up that took the best features of C, C++, and Java while jettisoning anything that didn’t have a very good reason for existing. And the result was a language that was tighter and easier to learn than its “parents” without sacrificing important features or runtime speed. D is what happens when you take language design away from the realms of the committee.
While D does jettison backward compatibility in the name of simplicity, it does have excellent methods for communicating with C code, so if you have a third-party library or some C source code that you are loath to rewrite, you can still talk to it without much difficulty.
That is to say that D would be the best of all worlds if it gained more support. It simply doesn’t yet have the huge libraries of code, wealth of tools, and base of user support of the other languages. Hopefully its support will grow and it will receive the attention it deserves, but that will take some time.
Conclusion
Early on it was clear that this article would not reach a satisfactory conclusion as to what language to use. Fact is, there’s very rarely a single solution that will solve all problems. Hopefully this list will at least whittle your choices down to two or three good candidates. The rest of the research is up to you.
Thankfully, virtually every solution mentioned above has a free implementation, so you can try out these languages and choose the one that you think will best suit your project.(source:gamedev)