What language to use when prototyping a small game - prototyping

I am currently considering writing a small game. It is essentially a map where you can zoom out and in, and in certain places click on info boxes where, at some point, I hope to integrate minigames. Granted, game might be overstating it. Think of it as an interactive map. The theme is how mathematics can be applied in peoples every day life to raise awareness on the usefullness of mathematics.
The question is how I as fast as possible can make a reasonable prototype. If I recieve enough positive response on this I might try to code "the real thing" and use the prototype to obtain funding.
However, I am at a crossroad. I want something to work rather fast and have some C++ experience coding optimization problems, mainly in c-style. I am not convienced, though, that coding it in C++ is the fast way to obtain a prototype. Though I have some experience coding in C++, but have no experience in coding any sort of GUI.
As I see it there is a number of possibilites:
C++, possibly using some library, such as boost or ???.
Start out purely webbased, using e.g. HTML 5 and java.
Python
C#/.NET
Others, such as?
I have to admit I have little experience with anything besides C++ and the STL.
So my question to this wonderful forum is basically, is there a language that provides a significant advantage? Also, any additional insight or comments is more than welcome!

Python is a simpler language than C++, and for prototyping it will help you focus on the task at hand. You can use Pygame, a game library built on the excellent cross-platform SDL library. It provides 2D graphics, input, and audio mixing features. SDL is mainly a C library (and thus compatible with C++), and there are a number of very useful libraries that integrate with it:
SDL_image for loading images in various formats
SDL_ttf for rendering text using TrueType fonts
SDL_mixer for audio mixing
SDL_net for networking
SDL_gfx for graphics drawing primitives
So if you prototype in Python using Pygame, there is a reasonable chance you’ll be able to port what you make over to C++ with minimal hassle, if and when you choose to do so.

Possible options:
Go with what you know the best. Anything else will require a learning curve, which may be weeks to months long. If you're willing to take that road in order to make your prototype, then there are some really great tools available.
BlitzBasic is a good way to go, and is basically designed to be for games
I've done little games in Java using Slick2D - but you'll need good grounding in object-oriented coding to work effectively in Java. If you've got that from C++, then you can see a tech demo I built in Slick2D called Pedestrians. It's open source, and has demo videos here.
You might also ask your question on https://gamedev.stackexchange.com/ - a Q/A site dedicated to game programming

Related

Good QT or KDE program with source to use as a non-trivial example

The QT dev kit comes with some good examples of how to code features via trivial apps, but nothing comes close to showing how to structure a complex program in QT. What, if anything, should be global, etc? Pitfalls in designing your classes that would turn out to need a lot of eventual refactoring?
I'm sure there are plenty of open source KDE apps that would serve nicely, so I guess my question is what't the minimal amount of source code I'd need to download and set up in order to work with, say, Dolphin as a sample app? If the answer is 'all of KDE', then I guess this isn't practical (unless downloading and building all of KDE from source is easy enough to make that practical).
Any suggestions? Personally, I'm looking to build a browser-like app, but much simpler. So for an example to follow, something that handles sockets and multiple tabbed viewports would be nice.
Thanks,
Rob
The main advice regarding Qt itself is I would give is to try to spend as much effort as possible in learning to use Qt's Model View Delegate functionality. It can be a lot of work to wrap your head around, but once you get there, you can do very powerful things with it. Another relatively tricky topic you will want to invest learning resources in is memory management and how Qt facilitates (and doesn't facilitate) it.
One of the most confusing things to me was though that when your model is very complex, you might not want to have your core model class be a Qt model at all. Instead, I nowadays see Qt models as something that primarily provide data to views. If your model is very complex, you might want to use your actual, more complex model as a data source for the Qt model class (an QAbstractItemModel derivative), which in turn attaches to the UI view.
Also, Qt documentation is your friend. Qt is a wide framework and contains LOTS of useful functionality. I love the data structures in their ease of use, for example: QHash, QList, etc.
Project scaffolding features for beginners, for different project types in Qt Creator might indeed be useful. For now, the Qt Examples actually are quite good ones, and contain lots of good practices. You just need to pick and choose what you need.
I have been developing our Qt desktop app family for five years now. Our directory structure is quite unorthodox - the main thing is that we have lib/ under which we have grouped different related functionality in subdirectories. The thinking goes, if something is in lib, it is general-purpose and atomic enough to be used in several of the actual desktop applications in our software family.
Your question seems more general level than Qt. It is difficult to tell if you are looking for a more general level computer science education. Globals in general should be avoided, sure. OTOH, we do have a constants.h and other immutable configuration data that is global-like, since it is needed in many places. This adds state though, so it can have unpredictable consequences if you don't do it carefully.
You could look for directory structures in places like this, though I don't really follow this advice myself. http://hiltmon.com/blog/2013/07/03/a-simple-c-plus-plus-project-structure/
Unless you are planning to contribute directly to KDE, I would advice against learning KDE way of doing things. Not necessarily because they are doing things badly, but because it is a world of its own - the best practice for KDE development might not be the best practice for a stand-alone Qt app. (Disclaimer: I, as a UI developer, don't actually like KDE, so I do not know the project very well - aside from the fact that it indeed seems a bit monolithic to the outsider.)
So I wonder if something like Qupzilla would fit the bill for you? (Found via qt-apps.)
HTH.

Adding calculation power to flex application

I have been tasked with making several flex-driven visualizations of immense excel spreadsheets. The client wants the finished product to be as self-contained as possible. The problem being that flex doesn't offer as much computing horsepower as is needed. Is there an easy (or not easy) way to accomplish this. I am just trolling for pointers. Thanks in advance!
If you dont mind doing it the hard way, I have two options for you:
Pixel Bender: a tool originally designed for creating complex and CPU-intensive graphic filters and offload those calculations to the hardware. But it can be used for number crunching too. Here's an article that covers that topic: Using Pixel Bender with Flash Builder 4 as a number crunching engine. The language may not be like anything you're used to. I had a hard time wrapping my head around it.
Alchemy: a tool that compiles C or C++ code so it can be executed in the Flash VM. I am not certain how much performance can be gained for simple number crunching, but if you know C, this might be a path to investigate.
The first thing that comes into my mind - building a webservice that will do the hard work. But this is not a self-contained product though.
Apart from that - take a look at the apparat - http://code.google.com/p/apparat, it allows various optimizations, access to the low level AVM2 code - http://code.google.com/p/apparat/wiki/AsmExpansion and more. I do not think that as3 and flex compiler is so bad for math. Try to write the sample math function and test it using different languages.

What is a good language to develop in for simple, yet customizable math programs?

I'm writing to ask for some guidance on choosing a language and course of action in learning programming. I apologize if this type of question is inappropriate for Cross Validated, please advise me to another forum if that is the case.
I've seen thread after thread with questions from newbies, asking, "What is the best language to start with?" and then it always starts a flame war or someone just answers, "There's no best language, it's best to pick one and start learning it." My question is a little bit more focused than that.
First off, I've been programming my whole life, in very limited capacities. My deepest training was in C++. Whilst in my EECS degree program, I resolved to never be a software developer because I couldn't stand not interacting with people for such long periods of time. Instead I realized I wanted to be a math teacher, and so that is the path I have taken.
But now that I'm well down that path, I've started to realize that perhaps I could develop my own software to help me in the classroom. If I want to demonstrate the Euclidean algorithm, what better way than to have a piece of software that breaks down the process? Students could run that software as part of their studies, and the advanced students might even develop programs for themselves. Or, with an Ipad in hand, why not have an app that lets students take their own attendance? It would certainly streamline some of the needs of classroom management.
There's obviously a lot of great stuff already out there for math, and for education, but I want a way to more directly create things specific to my lectures. If I'm teaching a specific way of calculating a percent, I want to create an app that aligns with my teaching style, not just another calculator app that requires the student to learn twice.
The most I use in class right now is iWork Numbers/Microsoft Excel for my stats class. Students can learn the basic statistical functions, and turn some of their data into graphs.
I have dabbled a bit with R, and used Maple in college. I've started the basic tutorials for OS X/iOS development and have actually made good progress making an OS X app that takes a text string, converts it to numbers, and performs encryption using modular addition and multiplication. I sometimes use Wolfram|Alpha to save myself some time in getting quick solutions to equations or base conversions. I know of MatLab, Mathematica, and recently people have been telling me to check into Python or Ruby. I also know basic HTML, and while it's forgotten now, learned Javascript and PERL in college.
If I keep on the path of Obj-C/Cocoa, I think it will have great benefits. Unfortunately, anything I produced for Mac would only be usable on a Mac, so it wouldn't be universal for all of my students. Perhaps then learning a web language would be better. Second, I'm wondering if the primary use is mathematical, then perhaps my time would be better spent learning Mathematica Programming Language, or R, or something based less on GUI and more on simple coding of algorithms, maybe Python or Ruby?
It seems that Mathematica already has a lot of demos for different math concepts, so why reinvent the wheel is also a question I have. I think overall, it would be good to have more control and design things the way I need. And then, if I do want to make an "Attendance" app or something else, I would already have the programming experience to more easily design something for my iPad or MacBook.
The related question to this is what is a good language to teach to my students? In his TED talk, Conrad Wolfram says one of the best ways to check the understanding of a student is have them write a program. But if Mathematica does the math virtually automatically for them, then I'm not sure that will get the deeper experience of working out logic for themselves, like you do when you're writing C, or a traditional procedural language.
I know that programming takes time to learn, but I also know that at this point, my goal is not to be able to make an app like "Tiny Wings." With the app store ease, some of my work may be an extra revenue stream, but I see myself as more of a hobbyist, and now teacher looking to software development specifically for its ability to help me demonstrate mathematical concepts.
I think I will push ahead with Obj-C/Cocoa for OSX/iOS, but if anyone has some better guidance regarding all of the other available stuff, it would be much appreciated. I don't think I would want to go fully to the web (I like apps), but perhaps someone could suggest a nice way of bridging what I produce in XCode to a universal web version. For example, if you come up with an algorithm in obj-c is it easiest to transition that to ruby and run it online, or is there another approach that works better?
Mathematica is pretty awesome for the first part of your question. I've used the interactive mode (Manipulate[]) for explaining things to my colleges (and myself). It makes really nice dynamic figures and is fairly expressive (although your code can end up looking like line noise). It is very powerful, but it does far less for you than you might think. It's pretty intuitive, which is a good thing for teaching.
You could use Scala if you want an "easy" way to make a domain specific language for teaching. Python seems to confuse people as a first programming language. Objective C seems like a completely random choice to me.
Mathematica then. It's worth the price. But anything that is interpreted and has an interactive shell is probably better than a compiled language. BBC BASIC?
Nothing beats Haskell for general-purpose mathematical programming. The wiki's quite extensive and the IRC channel (#haskell on Freenode) is great for asking questions. If you statically link your binaries on compilation, you should be able to run your programs on just about any system (with a few exceptions, e.g., libgmp).
Haskell code reads (roughly) like mathematical notation once you get the hang of it, so it can really help to tie things together for your students who are motivated to write their own programs. The purely functional style can be beneficial, as well, since it focuses less on I/O and the marshalling of data (perfectly useful in applications, perhaps less so in pure math), and more on the actual creation and refinement of functions and algorithms. You can even compose functions just as you would on paper.
If you want to get really serious, you could also look into Coq or Agda, but those might be a bit much for most classes.
For a Haskell program idea for an educator, check out this link.
A nice list of arguments can also be found at:
Eleven Reasons to use Haskell as a Mathematician and the book The Haskell Road to Logic, Maths and Programming

Which language to learn for Qt development? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am new to programming. I have some Knowledge Of C++ and have learned Python.
Now i want to develop a Qt Gui Application. Which language should i use for Qt development C++ or Python with PyQt. I found Python to be easy language.
There is no definite answer to this question. With that said...
Pros and cons you often hear
Python is easy, C++ is hard (in
comparison to Python)
C++ is fast, Python is slow (so to
speak) performance wise.
In reality...
Both arguments can be true or false, you can make slow C++ program, but you can also make fast Python program, you could also say C++ is not that hard if you know it really good etc.
Qt is written in C++ so the documentation examples are in C++. This is not really a problem since it is easy to port this to Python. Although I've found that for example animations with state machine cause segmentation faults with PyQt and PySide is not all that stable yet.
So which one to pick?
Depends on your skill and assignment. If it is work you are doing go with what you know best and asses how much speed you actually need, not every app has a need for lower level code.
If you know Python, you could start building your prototype in Python, then port to C++ parts that you deemed slow and bind them back to the Python (using SIP for example) or even port the whole application to C++. This approach also makes good exercise.
But even if you wrote your whole app in Python I doubt you and your clients would ever notice the "slowness" or "fastness" if you go with C++. These things usually depend on skill of a programmer.
Conclusion
It's entirely up to you to choose what are you are most comfortable with and to understand what your app really needs, but both languages will do the job in most cases.
My subjective advice would be to go with Python and port to C++ if you really need to. Sole reason for this advice is that you do not need to type as much in Python as you do in C++ but this can also be seen as a silly reason.
I just finished a reasonably large project with PyQT... I think your choice should depend on three factors:
How big is your audience (less
than 100 installations? More?)
How much functionality do you need?
(Databases + graphics + plotting +
signal analysis + network access +
blah blah blah)?
How rapidly do
you need to develop, both now and in
the future?
C++/QT is great for 1) Big audience, 2) Low to medium functionality, and 3) Slow to medium development speed. Of course, you can do anything with C++ given enough time and money.
Python/PyQt is great for 1) Small Audience, 2) Any level (including high) functionality, and 3) Medium to fast development speed.
The benefits of Python/PyQt are that:
you needn't worry too much about datatypes, header files, and numerous other headaches that slow development, and you get to work in a world-class interpreted environment known for its ability to foster fast and robust development.
you can pull in massive 3rd party libraries like matplotlib, scipy, sqlalchemy, and configobj that can make complex tasks stupidly easy.
The downsides of Python/PyQt, IMHO, are that:
it may have slower performance in some applications (who cares? How often does that really matter?)
it may be substantially harder to deploy. Py2exe requires quite a bit of tweaking to get 3rd party libraries to work, and then you still need to build an installer and get that working. Then, every time someone installs your app you might have 10 to 100MB of unnecessary dependencies built into the thing.
Personally, I work in an engineering R&D environment where fast turnaround and extensive data analysis/visualization is key, and deployment is often to only a few dozen (tech-savvy) people. Python/Pyqt is the clear choice. But, if I were to be developing a simple, widely-deployed application like a bittorrent client or something, I'd go C++ all the way.
Other notes:
PySide (a free LGPL alternative to PyQt) is rapidly progressing and seems sure to blow PyQt out of the water; I'm planning to switch within the next few months but as of now some 3rd party libraries still aren't set up for it.
The documentation for Pyside is much better than for PyQt; if you need help on, say, "QListView", just search google for "Pyside QListView".
I'd recommend only using PyQt where you need to. E.g., don't mess with QtSQL (debugging is a nightmare) when you could just use SqlAlchemy, and don't screw with Qt's configuration system when you can use the awesome library ConfigObj.
The clear way to install Python/Pyqt/etc is using the distribution Python(x,y) ... it includes, among other things: Python, PyQt, Qt, Eclipse, PyDev, QtDesigner, Spyder, iPython, and many dozens of useful scientific and computing libraries. Compiling and installing this stuff on your own is not fun.
In addition to the arguments given by rebus, I would add that the development and maintenance time in Python is considered to be about 2-10 times faster than in C++ (in papers by Prechelt and Ousterhout). This is another significant advantage of Python, that you might want to consider.
My main reasons for choosing Python and PyQt4 are:
Readability: I can't think in C++. I truthfully cannot. Python, on the other hand, is pretty close to English, so I find it easier to skim and debug.
Speed: I find that Qt4 works almost identically in both C++ and Python when you're using it for simple applications that do little work on the inside. I coded a book binding application with Python, and since it is basically a frontend to bunch of CLI tools, there is no noticeable performance lag.
Rapid Development: If you can write it in words, you can probably write it in Python. When I had to implement a new feature in my program, I just opened up the source folder (which consists of only a few files. Compare that to C++'s header mayhem), and added it in. Sure I had to tweak it to work faster later on, but my main point is that because the language is readable, it is easy to code in, and hence increases productivity.
But just to weigh both sides equally, here's what I don't like about Python and Qt4:
Example Code: Good luck trying to find some sample PyQt4 applications. The community is pretty small compared to the C++ Qt community, so don't expect tons and tons of examples.
IDE: I code with Gedit, so this was not a big issue for me, but it did take some hacking while I was designing the GUI. You have to trick Qt Designer into promoting your widgets in Python-compatible ways (like proving fake header file names so that the modules import properly), and other things like that. Nothing to serious. My regret was the inability to use Qt Creator IDE. It's basically a GUI designer on steroids, but it looks nice and is like Visual Studio for Qt.
Speed: If your application does some serious heavy lifting, I'd stick with C++. Python is good for algorithmic things, but for raw number-crunching power, C++ is the winner.
Deployment: To compile Python applications into binaries, you need to do some magical stuff with PyInstaller, Py2exe, and Py2App. It's a pretty painful process (for me at least), but it's the price you pay for an interpreted language. C++ just compiles and is ready to go.
I hope this helps in your decision. Good luck!
Learn C++. C++ executes faster than Python, and the fact that Qt is not native to Python will also slow things down slightly. Also, there is at this point far more 3rd party software in C/C++ than in Python. You might not need it now but down the road you might want to link to some of this.
EDIT: Looking a little harder I see that EOL is right, there is a lot of Python support for major libraries, though not for everything as lunayorn points out. Nonetheless in all these cases the Python user is reliant on bindings, which by their nature may lag the library developments and add extra possibility for bugs.
And since I don't yet have the cred to respond to others' posts, let me say here that rebus' claim that it's all programmer relative and C++ or Python can be just as fast is completely (and dangerously, where speed is important!) wrong. Python's ease of use comes at an unavoidable performance cost, see the wikipedia entries on interpreted vs. directly executed languages. I know from direct experience that Matlab, which is interpreted in the way Python is, executes line for line 2 full orders of magnitude more slowly than C++. Python and Matlab are best considered as (and in the case of Matlab at least, originally intended as) interfaces to libraries coded in languages like C or Fortran. For serious, large programs where performance matters use C++.

Figuring out the right language for the job: branching out from C#

I work in a Microsoft environment, so I can use my C# hammer on any nails I come across. That being said, what languages (compiled, interpreted, scripting, functional, any types!) complement knowing C#, and for what purposes? For example, I've moved a lot of script functionality away from compiled console apps and into Powershell scripts. If you're an MS developer, have you found a niche in your world for other languages like F#, IronRuby, IronPython, or something similar, and what niche do they fill?
Note: this question is directed at the Microsoft dev people since I can't run off and start installing LAMP stacks around my company, and therefore having to support it forever. :) However, feel free to mention any other languages that you found interesting to fulfill a certain task/role in your world apart from your main language.
Python/Perl/Ruby/PowerShell are great supplements to C#/VB.NET. If your boss hands you a text file and says insert it into the database once or twice, then any of Perl/Python/Ruby (I'm not sure about powershell but I imagine it is not that much more difficult) should be fine to parse it. Either way, for your main applications you will probably be stuck in C#. You can use one of the more dynamic languages to do code generation in C#.
Since you are in a Microsoft Environment, probably your best chance at getting your solution accepted is PowerShell. Next to that I'd say IronPython or something else that integrates with the CLR. But main issue is that for someone else to maintain what you do, they would have to know whatever language you are using. MS in the future has plans to use PowerShell a lot more, so it is probably easier to justify PowerShell then say Python/Perl/Ruby.
If you are just processing a text file for one time use. Or creating a one time code generator to generate all the code and then intend to maintain the generated code, then it doesn't matter. You are the one who will consume the results and if you save time using Perl then more power to you. But if you are doing something that will be used over and over again (like an active code generator where you change the templates and run the generator instead of maintaining the generated code) then other developers working on what you did will need to know the language you used. It is much harder to argue learning Perl/Ruby/Python in a Microsoft Shop. But PowerShell seems like the easier argument. I think the MS grand plan is that eventually applications will expose more functionality for power shell through commandlets. Assuming this happens then PowerShell is even more of a no-brainer because it will expose tons of scriptable functionality that you won't get any other way.
A nice scripting language is always a good tool to have on you belt. See Ruby, or Python.
I use python for prototyping, since there's almost no turn around time between edits and actually running the new version of the code. I may even end up using it for a real project - the more I use it, the more I like it.
It will take some getting used to as a C# programmer, though - the indentation-defines-structure system it uses is a little weird at first.
Since you are in a MS shop, I would suggest PowerShell as a decent scripting language to learn. It plays well with C#.
I'm a big fan of Ruby too.
I'd like to second or third python. Specifically, IronPython (ttp://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython) lets you learn python but also gives you access to the .net framework goodies.
It's quite nice for scripting-related tasks so it'll probably be useful for your day-to-day coding life, and also a nice way to muck around in an experimental coding/prototyping way.
While it's a bit of a fringe language, I'm compelled to mention Erlang. Erlang is an excellent language to have in your toolbox since it's unusual strengths tend to compliment other programming platforms. Erlang is very useful for building distributed, concurrent, fault-tolerant systems. It's used a lot in the instant-messaging and telephony world where there's a need for distributed, yet interconnected architectures.
Maybe play around with Boo and see what you think.
Boo at Codehaus.org
Boo at Wikipedia
If your using the .Net framework the language is really not important as the compiler and interpreter create the same IL code in any case.
If you step away from the .Net world, I am of the opinion that development tools and languages are a tool box. I strive to use the right tools for the job at hand, taking into consideration what the skill base of the other developers are and what direction a company is seeking of course (I'm a consultant).
I'm with jjnguy. Try one of the scripting languages. Plus as a bonus, when you learn Ruby/PythonPearl, etc...it's a gateway drug...err language to developing for other environments.
Trying out languages outside of your normal toolbox will give you new ways of approaching things in your current favorite language. Even if you don't use them for serious projects languages like Perl (for data mangling), Lisp (functional programming), and Javascript (prototype based programming) will teach you new ways to think about problems in your current language.
As a web developer by trade, you might look into the XSLT/XPath family as for certain types of XML processing they can be very powerful tools.
Granted, in C# 3.x Linq2Xml exposes some similar functionality inline.
XSLT, however, can be a powerful way to separate data from presentation in your apps.
I am very interested in F# and some of the other new languages in the CLR/DLR. The DLR languages might be a lot better for your UI, because they don't make you cast a lot of stupid things.
However, I think that it is important to keep in mind tha learning a new language, especially in a new area, like functional programming, is always a good way to re-train your mind so that you are exposed to new concepts and you can code better in your language of choice, even if you never use those new languages.
Check out Boo - it runs on top of the .NET stack, but its syntax is more like Python.
To learn a new language that complements C#, I'd go with C++. You can use it in a 'way better than p/invoke' style to get access to unmanaged code from your C# apps. You can then start using it to write the memory-constrained apps, and/or performance-critical bits in, if you find some of your .NET applications start hogging all the RAM and/or CPU or just generally aren't as fast as you'd like.

Resources