Author Topic: Viability of Python  (Read 22529 times)

Pueo

  • Rogueliker
  • ***
  • Posts: 263
  • Karma: +0/-0
    • View Profile
    • Email
Viability of Python
« on: September 08, 2012, 03:53:12 AM »
My computer science class in school is teaching us Python, and I was wondering if it's viable to create a roguelike in said language.  I know that Python is a fully featured language, so it theoretically should be viable, but I wanted to know if it was good, specifically for roguelikes.  
Are there libraries to help with RL development? Is it (relatively) easy to get into? What's the portability like? Those kinds of things.
{O.o}
 |)__)
   ” ”   o RLY?

tuturto

  • Rogueliker
  • ***
  • Posts: 259
  • Karma: +0/-0
    • View Profile
    • pyherc
Re: Viability of Python
« Reply #1 on: September 08, 2012, 05:47:31 AM »
Python is good programming language and works well for creating a roguelike. It is easy to use, has good set of features and friendly community. Python is portable, unless you're doing something very system specific, same program will run on different platforms. Because Python is interpreted language, it will run somewhat slower than native applications written in C/C++ for example. But with roguelikes that usually isn't a problem (and you can always mix Python with C/C++ if you want speed at certain parts).

I'm writing a roguelike with Python and so far haven't had any problems because of the language, on the contrary. I'm using PyQt for user interface and bunch of libraries for testing. I'm not aware of any libraries that are specifically aimed at writing roguelikes, but those might exists.

Python is both strongly and dynamically typed. They'll most likely go through this at school much better than what I can explain, but http://en.wikipedia.org/wiki/Duck_typing gives short and nice explanation too. If you have been programming with statically typed languages like C/C++, Java or such, this feature might take some time to get used to (certainly took some time for me).

Another feature that sometimes confuses/annoys people is that white space matter for Python programs. There isn't special character or keyword to mark end of function for example. Instead of special keywords, indentation of code is used.

http://python.org/doc/ has huge amount of information available. That is usually the place where I turn when I don't know or understand something about how Python works. Of course, if you have specific questions, I can always try helping where I can.
Everyone you will ever meet knows something you don't.
 - Bill Nye

Pueo

  • Rogueliker
  • ***
  • Posts: 263
  • Karma: +0/-0
    • View Profile
    • Email
Re: Viability of Python
« Reply #2 on: September 08, 2012, 06:25:50 AM »
Thanks, that answered my question  :)
Follow up question: can Python run on iOS devices (iPad/iPhone)? I would like to write programs for those devices as well, but I don't want to have to learn another language just yet.
{O.o}
 |)__)
   ” ”   o RLY?

tuturto

  • Rogueliker
  • ***
  • Posts: 259
  • Karma: +0/-0
    • View Profile
    • pyherc
Re: Viability of Python
« Reply #3 on: September 08, 2012, 06:45:34 AM »
I don't develop anything for iOS, so I might not be the best person to answer. There is Python for iOS (http://pythonforios.com/), but that's not really suitable for writing games (no graphics output yet). It seems to me that using Python on iOS devices is currently pretty limited.
Everyone you will ever meet knows something you don't.
 - Bill Nye

guest509

  • Guest
Re: Viability of Python
« Reply #4 on: September 08, 2012, 07:18:28 AM »
  The good thing is if you learn one language, like Python, you can easily pick up others. Very very easily.

  Here is an article you might like, it's about programming Roguelikes in Python.

http://roguebasin.roguelikedevelopment.org/index.php/Python

  Here is a tutorial on how to make a roguelike using Python.

http://roguebasin.roguelikedevelopment.org/index.php/Complete_Roguelike_Tutorial,_using_python%2Blibtcod

  Have fun! Making a roguelike is a great way to learn a language.

TheCreator

  • Rogueliker
  • ***
  • Posts: 370
  • Karma: +0/-0
    • View Profile
    • Fame
    • Email
Re: Viability of Python
« Reply #5 on: September 08, 2012, 07:54:04 AM »
As said above, it is an interpreted language. Do not ignore that information. "Interpreted" means that someone has to interpret it and that in turn means nobody will be able to run your game unless they have installed the intepreter. And some people will not install it just to try out your game.
Fame (Untitled) - my game. Everything is a roguelike.

XLambda

  • Rogueliker
  • ***
  • Posts: 208
  • Karma: +0/-0
    • MSN Messenger - tau_iota@live.de
    • View Profile
    • The Weird Rogue
Re: Viability of Python
« Reply #6 on: September 08, 2012, 08:07:05 AM »
Also note that there might be version issues. The Python port of libtcod is affected by that - apparently there are problems when switching between x86/x64 versions and Python 2.x/3.x (though there's a workaround for the latter one iirc).

Darren Grey

  • Rogueliker
  • ***
  • Posts: 2027
  • Karma: +0/-0
  • It is pitch black. You are likely to eat someone.
    • View Profile
    • Games of Grey
Re: Viability of Python
« Reply #7 on: September 08, 2012, 10:25:30 AM »
Libtcod is a great set of roguelike libraries that works with Python, and there are lots of examples of python games out there you can copy source from. Using python is probably one of the quickest ways to get started in roguelike development. I would recommend looking into Py2exe before release though, as getting python games running on Windows can be a huge pain.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Viability of Python
« Reply #8 on: September 08, 2012, 03:47:40 PM »
Also note that there might be version issues.

True. Some programs simply come with entire python with it, like Blender. It's a problem when people need to be sure what version is the proper one and you may end up having several versions of python.

requerent

  • Rogueliker
  • ***
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: Viability of Python
« Reply #9 on: September 08, 2012, 05:03:36 PM »
Also note that there might be version issues.

True. Some programs simply come with entire python with it, like Blender. It's a problem when people need to be sure what version is the proper one and you may end up having several versions of python.

Of which the 2x and 3x versions of Python are not compatible!

I have a neutral stance toward Python's syntax. It's a nice try, but some very basic things are not very intuitive. The stock libraries and classes are quite powerful, though a loop with 10k+ iterations will slow down significantly as compared to Java or C++. I also don't like Python's politics. Their goals and their decisions don't always seem to line up.

I'm also being forced to learn it for university. It is very easy to learn and to use, and writing quick simple prototypes is a breeze. It's powerful, but my inner being despises it.

Leaf

  • Rogueliker
  • ***
  • Posts: 64
  • Karma: +0/-0
    • View Profile
    • Email
Re: Viability of Python
« Reply #10 on: September 08, 2012, 05:06:39 PM »
Python is a great language!  I have a little trouble intuiting Python code, because I think my brain has become hardwired to curlybrace languages over the years, but that's my fault, not Python's. :P

can Python run on iOS devices (iPad/iPhone)?

There is probably a roundabout way to get it to work, just like there is for Java and other stuff.  But unless you want to have aggrivating hacky stuff on your hands and/or too much work getting something running, I think you're still pretty much stuck with ObjC + XCode for any "real" work on iOS.  Apple recently relaxed their insane licensing terms a bit, but as of yet I haven't seen anything else that's really viable yet.

I stick to Android myself.  Maybe it's not as cool, but the platform is way, way more open than iOS, and that (in my opinion) makes it a lot easier to develop on.

hawk66

  • Newcomer
  • Posts: 23
  • Karma: +0/-0
    • View Profile
Re: Viability of Python
« Reply #11 on: September 09, 2012, 04:34:15 PM »
I think, you just should try out some languages and see in what you feel the most comfortable with. I've tried out Python by myself and I don't like it but that does not mean I claim it is a bad language or would not be suitable for your project.

If you want to support iOs in the longterm, you may check C#/Mono, which is available for every major platform (Windows/Mac/Android/Linux/iOS etc.). Just be aware of that for Mono on Android/iOs you have to pay a quite high license fee/year (but using Mono for Windows/Mac is free).

C# and its libraries is a cool language, much more superior than Java.
I've just started today my own roguelike project with C#/.NET


Just my thoughts.

AgingMinotaur

  • Rogueliker
  • ***
  • Posts: 805
  • Karma: +2/-0
  • Original Discriminating Buffalo Man
    • View Profile
    • Land of Strangers
Re: Viability of Python
« Reply #12 on: September 10, 2012, 07:24:39 AM »
Python is perfectly sufficient for writing a RL. Depending on your design, you may have to optimize stuff like map generation and AI a bit, but where's the harm in that? And although it is an interpreted language, there are tools to convert a Python project into binaries for Windows (py2exe works well enough) and OS X (py2app, amongst others, which I haven't tried out). So your users won't have to install Python as long as you put in half an hour worth of extra work.

As always,
Minotauros
This matir, as laborintus, Dedalus hous, hath many halkes and hurnes ... wyndynges and wrynkelynges.

yam655

  • Rogueliker
  • ***
  • Posts: 59
  • Karma: +0/-0
    • View Profile
Re: Viability of Python
« Reply #13 on: September 11, 2012, 01:04:43 AM »
I'm a huge Python fan.

Linux folks shouldn't have any issues with version differences. It's trivial for Linux users (using any reasonable Linux distro) to have multiple Python versions installed.

Before you pick the version of Python to use, make sure the extensions you want to use work with it. It can be non-trivial to recompile extensions for Python -- especially for Windows.

I'm specifically a Python 3 fan. The fixes put in place for Python 3 are useful and important for the growth of the language. More importantly, Python 3 is the future, and when folks use Python 2 impacts how quickly they can stop supporting two major versions.

If you use Python 2.x, expect everyone else to migrate to 3.x before you, and then the Python folks to drop support of 2.x, and then a major security issue happens and you're the last person effected by it. For a 7DRL you might not care about this. If you're trying to make a new major Roguelike, however, this could definitely be an issue.

Unfortunately, on Windows having Python 3 installed interferes with basically any other program that has features to use Python. (LibreOffice/OpenOffice fails to start if I have it include Python support, etc.)

Last time I looked at Python Roguelike development my requirement to use Python 3 meant I was writing my own UI code using TkInter. This was ~3 years ago, though.

My advice: Look in to py2exe (for Windows) and py2app (for Mac OS X). They'll allow you to make a first-class application using Python. Both py2exe and py2app work basically the same way, they create a ZIP file of the compiled Python code bundled with the Python interpreter.

To finish it off, on Windows you need to use a installer-creation program like the Nullsoft Installer. And on Mac OS X you'd create a "DMG" file. If you have access to Windows and Mac OS systems it is straight-forward to create packages for Windows, Mac OS X and DEB-based Linux distributions. (I've never created packages for other Linux package management systems so I can't say how easy it is.) At a university it should be possible to get access to both Mac OS X and Windows machines. Otherwise it's probably easiest to have a Mac and either dual-boot or have Windows in a VM. (Linux runs smoothly in a VM everywhere without license issues.)

By shipping your game as a standard installer for Windows and Mac OS X and source for everything else, you're basically completely covered in terms of making it easy for the folks that "need" it easy, and making it possible for the people using odd operating systems you've never heard of.

Cheers,
Steven Black

tuturto

  • Rogueliker
  • ***
  • Posts: 259
  • Karma: +0/-0
    • View Profile
    • pyherc
Re: Viability of Python
« Reply #14 on: September 13, 2012, 06:03:50 AM »
For fancy UI things and Python 3, there's always PyQt. If possible at all, using Python 3 would make sense. But as yam655 said, that depends on the libraries you want to use.

I wouldn't worry about installers and creating executables at this point. It pays to keep them in mind for the distant future, but that's probably something you would want to tackle after getting something together.
Everyone you will ever meet knows something you don't.
 - Bill Nye