Page 1 of 1

Programming language of choice

Posted: Tue Sep 18, 2012 11:26 pm
by Trilarion
Although I was more or less decided on Java and as many standard/well used libraries as possible I recently had some doubts again about the important question:
What is the programming platform of choice for such a project?
Here the critical requirements as far as I see them:
  • Free to use, no royalties, compatible with open source
  • OS independent, supports Win, Mac, Lin, Mobile(?)
  • Standard/well used libraries for network communication and graphics display
  • One or a set of languages that we understand or that we want to learn and that makes development easy (by nice design patterns)
  • Used tools should be modern but widely utilized so the chances to attract talented programmers are high
Possible platforms I could think of:

1. Java
Combined with Swing (graphics) and Netty or Kryonet (network) we would get pretty much of the above. Creating installers is a hassle, the OpenJDK might have some incompatibilities with the OracleJRE and the language is said to be missing some features, being overly complex with Swing and being overly verbose. But I know it well (my best language currently) and it's OO allows some nice design patterns and it's common enough to attract other programmers. More or less I was decided on Java in the past time.

2. Python
With a graphics library (wxPython, pygame, PyQT, ...) and some network support (Twisted, ..). Python is a nice language, development is easy and I am getting better and better in it, although I am still much less professional than in Java. It runs on many OS and has sufficiently many libraries. Performance is probably not better or worse than Java. However I fear the libraries aren't that mature and my limited experience with it.

Extra: With PyjamasDesktop/PyWebKit one could develop desktop and browser applications simultaneously.

3. C++
C++ and a graphics library (SDL, wxWidgets, QT, ...) and some network support. Well for me it's too low level. I don't want to programme in a compiled low level language anymore unless I need to optimize a single task for performance. It's certainly possible but increases programming time considerably while giving enhanced performance which is probably not needed.

4. Browser of your choice/Server
With Javascript and HTML 5 as frontend compatibility is no problem anymore. Graphics and network come for free. The backend would have to be some sort of server in a language of your choice (either Java or Python). However I would only have access to standard webspace offering php and php is extremely cumbersome to programme.

5. Browser add-on
Probably Firefox and Chrome only. One could develop and add-on so graphics and network come for free probably but compatibility is limited and we would be dependent on the future development of the browsers.

So from all this the best choices are either Java or Python or a Browser/Server combination. Until recently I was convinced that Java is what I want (what I can), but since I learned more and more Python ... the matter is more open again.

Alternatives and comments are greatly welcome. :)

Re: Programming platform of choice

Posted: Wed Sep 19, 2012 9:19 pm
by Veneteaou
I suggest you code in whatever language you feel comfortable coding an entire game by yourself in. The reality is that we may be the only 3 people who work on this, so pick a language that won't get you confused or bored, and something you can bugfix easily. I'm months away from being able to code competently in JS, and we still would be without a PHP person to code server-side. You are the only programmer we've got right now, no sense in waiting for someone else to come along. It sounds like you are good in Java and you like Python, so I would narrow it down to those.

Also, you might be interested in taking a look at Nostalia if you choose to code in Java. It's an open source 2D game engine, so you might be able to harvest a bit of code and save some time. I'm sure more of the same exist if you choose Python.

Re: Programming platform of choice

Posted: Wed Sep 19, 2012 10:15 pm
by Trilarion
Thanks for the good advice. I am more or less back on Java where I am confident that I can finish the whole project (given enough time). Python will be reserved for the next project and the browser solution while offering high compatibilitiy is not flexible enough. I don't want to limit myself to expressing everything in html (for example no child windows, refreshing needs (partial) reloading...).

So Java it will be until something extraordinary happens. :)

Re: Programming platform of choice

Posted: Fri Apr 04, 2014 4:15 pm
by Trilarion
And now, almost 1.5 years later and with a substantial part (version 0.1.4) already in Java but in the last months also quite some knowledge in Python I again put that question in front of me!

1. Java

Pros
  • Nicely designed, allows a lot of nice patterns
  • Plattform independent
  • Java 8 is just come out and brings some new toys to play with
Cons
  • Packaging cannot include JRE, often people do not fully understand this, Java runtime must be installed additionally
  • Concurrency is (in my eyes) solved quite difficult
  • Static typing requires a bit more explicit coding which might be overkill sometimes
2. Python

Pros
  • Concise, well thought out standard libraries
  • Duck typing, anything goes as long as you know what you are doing
  • Easy packaging including a Python runtime
  • With PySide/Qt a superb GUI framework (although Swing for Java isn't that bad either)
Cons
  • Might be considerably slower due to runtime interpretation (although time critical sections could be outsorced to C++)
  • Overhead in packaging is quite large (full PySide/Qt is 80 MB raw, 20 MB compressed)
  • Context help is sometimes out of order because of dynamic typing (although IDEs are quite good at guessing, still ..)
  • Larger projects might become unmanageable
Otherwise there are excellent communities, libraries, documentation and IDEs for both languages. Also both are amongst the most popular languages which maximizes chances for finding interested programmers.

Alternatives might be C#/F# with Qt binding on Mono, which would be the third popular alternative in my eyes, but due to lack of experience I would not consider it here. (Although I would like to try out F# at some point.)

My current estimation is that Python might be a bit more appropriate because development goes a bit faster (and speed is crucial if we ever want to finish the project) while at the same time delivery of binaries is a bit easier for our windows users (and according to my exprience at least 80% of users will run it on Windows). This would mean that I have to write the current version again in Python and I make myself no illusions about that: some things will be better, but other things will be worse (for example there is nothing as good as MigLayout regarding layout managers in Qt).

The risks of going over to Python are that the game might run slower or that some large scale application effects kill us.

For the savegame structure we will certainly move away from XML to JSON which is less mighty but also more simple to understand.

Re: Programming platform of choice

Posted: Sat Apr 05, 2014 3:13 am
by Veneteaou
I think the biggest Pro of either language is the following:

Python is a popular learning language, and is one of the most popular scripting languages. That means we have a far better chance of finding game-oriented programmers that want to get their feet wet with Python over Java. Java IMO doesn't get love as an entry level language anymore, not near the level of scripting languages like Python, JS, and Lua.

Re: Programming platform of choice

Posted: Sat Apr 05, 2014 11:26 pm
by Trilarion
That's a good point I was missing. Although it still is a gamble. I estimate that a single professional programmer is worth quite many beginners, but then professionals seldom have time for open source projects and the number of potentially interested beginners is much higher.

Now after some days of sleeping over it I still feel quite good about switching to Python. One thing I value especially currently is that a scripting language is ideal for quick prototypes of parts of the game (like trading, battles, ...) and using the same language also for production should decrease the transition costs quite a lot.

One thing though: With PySide/Qt, PyAudio (for sound) and Numpy (for calculations) and potentially other libraries the download of the binary (for Windows) will be at least 40-50 MB (even without large game assets and even with best possible compression of the installers). Would this be a problem nowadays?

Re: Programming platform of choice

Posted: Sun Apr 06, 2014 5:38 pm
by Veneteaou
I don't think so. The .15 alpha of 0 A.D. is 501MB, and it's not even close to being finished. Without serious animations or videos, we are going to have a small game. At this point, our only real concern should be how to finish a game with a small handful of regular contributors.

Re: Programming platform of choice

Posted: Mon Apr 07, 2014 10:56 am
by Trilarion
So it is decided, in the next weeks I will rewrite some of the code of version 0.1.4 in Python. Shouldn't take too long. I will write about it in the Dev Blog here in this forum.

alternatives

Posted: Wed Oct 15, 2014 11:37 pm
by Trilarion
Just as an afterthought. What would be competing (as platform independent as possible) alternatives.

- Java with libgdx (just recently discovered it is used quite often) runs on Win, Linux, Mac and Android and also with robovm kind of convertable to iOS
- C# with monogame/XNA supports mobile plattforms as well
- Webapp with HTML5/JS and serverside anything one likes
- Unity (mobiles supported?)
- C++ and Qt (not on mobiles?)
- Python and Python-Qt (not on mobiles?)

We choose the latter and for the other solutions I simply do not feel competent enough but for another project later on I might try out one of the other solutions.

Posted: Mon Oct 20, 2014 10:32 pm
by Trilarion
And an after-afterthough. The current programming language Python allows us to quickly develop. Once we have explored all the algorithms and the gameplay switching to another language is considerable less effort. Many parts of the code are actually very similar in whatever language. What this means is that for now the question which programming language/platform to use is answered but in the long run after version 1.0 one could think again about a different language especially if the interest to bring this game on mobiles is strong enough.

I estimate that I'm at least 50% programming faster in Python than in Java.