Friday, October 23, 2009

Picking a scripting language

We are planning to make the BitSquid engine largely scripting language agnostic. We will expose a generic scripting interface from the engine and it should be relatively easy to bind that to whatever scripting language you desire.

Still, we have to pick some language to use for our own internal projects and recommend to others. I'm currently considering three candidates:

C/C++

  • Use regular C/C++ for scripting.
  • Run it dynamically either by recompiling and relinking DLLs or by running an x86 interpreter in the game engine and loading compiled libs directly.
  • + Static typing
  • + Syntax checking & compiling can be done with an ordinary compiler
  • + When releasing the game we can compile to machine code and get full native speed
  • - C is not that nice for scripting
  • - Huge performance differences between "fully compiled" and "interactive" code makes it difficult for the gameplay programmers to do performance estimates.
Lua
  • Lua has the same feature set as Python and Ruby, but is smaller, more elegant and faster.
  • Other scripting langues such as Squirrel, AngelScript offer reference counting and static typing, but are not as well known / used
  • + Dynamic, elegant, small
  • + Something of a standard as a game scripting language
  • + LuaJIT is very fast
  • - Non-native objects are forced to live on the heap
  • - Garbage collection can be costly for a realtime app
  • - Speed can be an issue compared to native code
  • - Cannot use LuaJIT on consoles
Mono
  • Use the Mono runtime and write scripts in C#, Boo, etc.
  • + Static typing
  • + Popular, fast
  • - Huge, scary runtime
  • - Garbage collection
  • - Requires license to run on console
  • - Can probably not JIT on console

70 comments:

  1. Lua all the way! We're about to ship a game using it on Xbox 360; by using it I mean 95% of the game code, including UI, is written entirely in Lua.

    We had some garbage collection issues - we had to add a touch of "manual garbage collection" here and there, which took a day or two of the final stretch - but that was all that it took memory-wise, after months and months of a room full of gameplay programmers banging away at code blissfully oblivious of the existence of such a thing as "memory". The speed of development is orders of magnitude higher than C++, and the code is considerably smaller.

    Performance is the main issue - we dedicated a full Xenon core to it, and got away with it - but on the PS3 that won't be possible. You either have to design around it - avoid game designs requiring lots of logic - or go to C++, where you lose the productivity gain.

    Our game is VERY simulation-heavy, IMHO higher than the vast majority of games on the market - so it was kind of a worst case; on the other hand, I understand how you, thinking only about an "engine", wouldn't want to limit potential customers. But the limit is very high - and the alternative is C++.

    What's especially great about Lua is the native support for coroutines, which allow you to implement what's called "latent functions" in UnrealScript - which make game logic code much more straightforward than the alternatives (e.g. state machines).

    ReplyDelete
  2. You can also make your own scripting language that is job-centric and state-machine aware.

    ReplyDelete
  3. Yes, I'm leaning towards Lua myself. It is what we used in the Grin engine and overall it did great things for us.

    The main problem we had with Lua at Grin was performance, especially in Terminator Salvation. We didn't run Lua on a separate core, and since we were shipping for PS3, that wouldn't really have helped. I think the performance problems might be a result of trying to do "too much" in Lua and that it might be mediated by moving more of the heavy-duty stuff to C++ and being a bit smarter about the C/Lua interface. But it is scary to end up in that situation late in a project. On the other hand, I guess you always end up with performance problems in gameplay code, no matter what the situation is.

    What is slightly scary is that when optimizing C++ code it usually boils down to a few bottleneck operations. You rewrite them and get a quick performance boost. With Lua, there weren't any real such choke points. It was just a matter of a slow (compared to C, not to other scripting languages) virtual machine running lots and lots of code, so there was no single place to do quick and easy optimizations.

    Memory might also be an issue, since we want a separate lua state per core (to allow fully multithreaded gameplay), that will multiply the lua runtime size by the number of cores. But I think we can solve that by keeping all the state data in C and just doing operations on it in Lua. (That also saves the trouble of synchronizing the Lua states.)

    ReplyDelete
  4. At Unity we have very good experience with Mono. It gives us excelent programming languages and very good performance over interpreted languages.
    So if you get over the admittedly high startup costs, in terms of integration and understanding the code, there are many benefits.
    Also we get very good support from the Novell guys.

    You are velcome to contact us if yo need more info.

    ReplyDelete
  5. Mix it C++ + javascript ..
    http://code.google.com/p/libjspp/

    ReplyDelete
  6. We all apprehend that Epson printer is a relatively relaxed and compactable printing tool canon printers are help you discover your paintings productiveness thru its wireless networking competencies. If you're searching Customer Care Support Services on your printer then you can visit our web websites. Thanks
    canon printer offline to online

    ReplyDelete
  7. Follow the easy steps for HP LaserJet P1102W Setup. Reach the printer setup experts for HP LaserJet P1102w setup, if you face issues with setup.

    ReplyDelete

  8. your post is very interesting to read.
    Thank you very much.This website has everything I need.
    www-trendmicro-com/bestbuypc

    ReplyDelete
  9. Thank you for your article that is useful for me, and I will save the name of your blog, I will definitely return to read your new article. www.trendmicro.com/bestbuypc

    ReplyDelete
  10. WOW! I Love it...
    and i thing thats good for you >>

    รีวิว BLACKPINK Light Up the Sky
    Thank you!

    ReplyDelete
  11. If you want to make every moment special in your life, then you just have to call us at +91-9574671995 for hot Call Girls in Jalandhar.
    Jalandhar Escorts | Jalandhar Call Girls | Escorts in Jalandhar

    ReplyDelete
  12. Thanks for this valuable blog. It was very informative and interesting. Keep sharing this kind of Information.
    Web Designing Templates In HTML
    Web Designing Templates

    ReplyDelete
  13. Thank you for the great information that you provided in your article. I hope you will continue to have such articles to share with everyone! Here are some articles about How to Get Better at Using a Mouse. Check out my latest post laptops Mouse Tips related to this.

    ReplyDelete
  14. Really awesome blog. And thank you for sharing amazing information. This is a very useful post for me. This will absolutely be going to help me with my project. Thank you again . Know more about free ads post click the link and visit.post free ads in india

    ReplyDelete
  15. How to change ink in a Canon printer? These types of questions come into your mind and you are also not an expert in it then

    ReplyDelete



  16. You might come across an error message reading “Printer not responding” while trying to print something and connect with wifi. Multiple reasons cause this problem such as improper configuration, bad hardware status, faulty drivers, etc. how to change ink in canon printer will give you the quick and easy way to fix the not responding error of canon printer.

    ReplyDelete

  17. A printer may require regular maintenance so that it can work properly. Updating drivers, cleaning nozzle head, changing ink are crucial parts of the care of your printer. In this post, we have talked about how to change ink in the Canon printer. How to change ink in canon printer would be best to change the link to print appropriately without any missing letters or discoloration.

    ReplyDelete
  18. I really appreciate this wonderful post that you have provided for us. I assure this would be beneficial for most of the people. Isicelo seCanada Visa Online

    ReplyDelete
  19. Nice to be visiting your blog again, it has been months for me. Well this article that i've been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share. 꽁머니사이트

    ReplyDelete
  20. Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. న్యూజిలాండ్ ETA

    ReplyDelete
  21. I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. http://www.oaihdk.com

    ReplyDelete
  22. Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. http://laksjfl.com

    ReplyDelete
  23. I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post. https://usdhnfu.com

    ReplyDelete
  24. I have read all the comments and suggestions posted by the visitors for this article are very fine,We will wait for your next article so only.Thanks! natures only cbd gummies

    ReplyDelete
  25. I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. glucotrust reviews

    ReplyDelete
  26. Great article Lot's of information to Read...Great Man Keep Posting and update to People..Thanks pg slot 666

    ReplyDelete
  27. Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me. เกมสล็อต xo

    ReplyDelete
  28. Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained! EVISA INDIA

    ReplyDelete
  29. Wow, this is really interesting reading. I am glad I found this and got to read it. Great job on this content. I like it. https://www.jokerauto999.com

    ReplyDelete
  30. Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me. เกมยิงปลา

    ReplyDelete
  31. This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article. jili slot ทางเข้าเล่น

    ReplyDelete
  32. beach houses are really nice and it would always be a warm and relaxing place’ 꽁머니사이트

    ReplyDelete
  33. Most of the time I don’t make comments on websites, but I'd like to say that this article really forced me to do so. Really nice post! www.luciaslot365.com

    ReplyDelete
  34. Pretty nice post. I just stumbled upon your weblog and wanted to say that I have really enjoyed browsing your blog posts. After all I’ll be subscribing to your feed and I hope you write again soon! บาคาร่า

    ReplyDelete
  35. I exactly got what you mean, thanks for posting. And, I am too much happy to find this website on the world of Google. รูปแบบไฮโล

    ReplyDelete
  36. Wow, this is really interesting reading. I am glad I found this and got to read it. Great job on this content. I like it. fullslot

    ReplyDelete
  37. Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. 토토사이트

    ReplyDelete
  38. Positive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include. Turkey Visa Help Desk

    ReplyDelete
  39. Amazing, this is great as you want to learn more, I invite you to This is my page. interlining fabric

    ReplyDelete
  40. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info. 먹튀검증

    ReplyDelete
  41. These websites are really needed, you can learn a lot. 토토커뮤니티

    ReplyDelete
  42. This comment has been removed by the author.

    ReplyDelete
  43. This comment has been removed by the author.

    ReplyDelete
  44. If all blogs were as brilliant as yours. That online world will make a lot of sense! Have a nice day. Thank you 線上家教



    ReplyDelete
  45. ARB eastern bearings is one of the eminent engineering companies of India, known for manufacturing bearings of supreme quality at lower costs.
    top bearing company in india

    ReplyDelete
  46. A Complete Ecommerce Business is waiting for you. Online Stores For Sale are ready to start selling. Be a store owner and start earning money. Online Stores For Sale

    ReplyDelete
  47. Lorsqu'il s'agit de créer une entreprise, il y a beaucoup de choses à prendre en compte. Qu'il s'agisse de trouver le bon emplacement ou de recruter les bons employés, la liste des tâches peut sembler interminable. Pour de nombreux entrepreneurs, l'un des défis les plus redoutables est simplement de savoir par où commencer. Si vous envisagez de créer une entreprise de nettoyage, le forum startupo est l'endroit idéal pour obtenir des conseils et des idées de professionnels. Avec plus de 566 questions et réponses, c'est une véritable mine d'informations. Que vous cherchiez des astuces de marketing ou des conseils pour choisir le bon équipement, vous êtes sûr de trouver ce que vous cherchez. Si vous êtes prêt à vous lancer dans l'entrepreneuriat, n'hésitez pas à consulter le forum startupo. https://startupo.fr/question/614/comment_lancer_son_entreprise_sans_argent/

    ReplyDelete
  48. Luxury property for sale in France is becoming increasingly popular as investors look for ways to diversify their portfolios. Luxury houses for rent near Marseille offer a number of advantages, including proximity to one of Europe's busiest airports and some of the best schools in the country. In addition, France has a strong economy and a stable political system, making it an attractive destination for luxury property buyers. Luxury properties in France also tend to appreciate at a higher rate than properties in other parts of Europe, providing investors with the potential for significant capital gains. As the global economy continues to rebound, luxury property in France is likely to become even more popular with investors looking for a safe and profitable place to park their money. https://frenchchateauforsale.co.uk/luxury-properties-for-sale-near-nantes/

    ReplyDelete
  49. Superbly written article, if only all bloggers offered the same content as you, the internet would be a far better place.. sex doll

    ReplyDelete
  50. Recently, I have commenced a blog the info you give on this site has encouraged and benefited me hugely. Thanks for all of your time & work. test bank nursing

    ReplyDelete
  51. I was looking at some of your posts on this website and I conceive this web site is really instructive! Keep putting up.. Ice Cream Cup Cakes In Washington

    ReplyDelete
  52. I was able to find good info from your blog posts. anime sexdoll

    ReplyDelete

  53. Precisely what I was searching for, thankyou for putting up.
    sightseeing tour packages Andaman

    ReplyDelete
  54. I was looking at some of your posts on this website and I conceive this web site is really instructive! https://www.mymasturbators.com/

    ReplyDelete
  55. This comment has been removed by the author.

    ReplyDelete
  56. Just wanted to drop by and say how much I enjoy your blog! It's such a welcoming space filled with warmth and wisdom. Keep doing what you do best! Turkey visa requirements for egyptian citizens
    To apply for a Turkey e-Visa from Egypt, visit the official website, fill out the application form, upload required documents passport copy and pay the fee online. Processing usually takes 24-72 hours. Once approved, download and print the e-Visa to present upon arrival in Turkey.


    ReplyDelete

  57. Hi there! I stumbled upon your site through a Google search for a similar topic. Your site appeared and it looks great. I’ve bookmarked it in my Google bookmarks. The blog layout is impressive! How long have you been blogging? You make it look effortless. The overall design and content are wonderful! Madagascar visa requirements include a valid passport, a completed application form, and payment of the visa fee. Visitors can apply for an e-visa online, making it easier to obtain a visa before traveling to Madagascar.

    ReplyDelete
  58. Looking forward to reading more of your work and seeing what other valuable information you share in future posts! Keep it up. Now, allow me to share information about Bahrain online visa application, complete application in no time, eliminating the need for office visits. This efficient system greatly simplifies travel to Bahrain.

    ReplyDelete