views:

182

answers:

7

I'm building an educational game which, through it's modularity, allows for teaching students how to program. It's essentially a generic card game which can easily be modified.

The backbone of the game is supposed to be totally uneditable (at least in theory), so I need to build a "Card" type that allows for an anonymous function as it's action (even worse, or perhaps even more interesting, it needs an anonymous function that can have an arbitrary number of arguments).

I also need a strong GUI library, and it needs to be portable, and if at all possible it should be potentially be a web language. It should have extensive support for modularity, be object oriented, and hopefully be clear enough that it doesn't require an experienced programmer to understand the syntax. That's a lot of requirements, but I'm supposed to be detailed and I want a specific answer and why it'd be a good choice, so I should put as much information as possible I think. I have no real need for efficiency of the language, so low level languages are not necessary in this case, very high level languages will easily be fast enough.

Python isn't strong enough. Ruby may be but I'm not familiar enough with its features. Haskell and Scheme have the strongest support but aren't web languages and, so far as I know, don't have GUI libraries for the most part. C# may be reasonable, I'm not terribly familiar with its features, but I'm particularly worried about portability. If at all possible I'd like to avoid javascript, but if that really is the best option, I'll probably have to go in that direction.

A: 

python + wxpython

foxhop
If I were using python I'd use the tk interface to python, but as I said, python has issues regarding anonymous functions
Michael
what issues? :D
CrazyJugglerDrummer
Are you familiar with python's lambdas? you always have to phrase it such that no statements are made, which makes for incredibly long lines, also executing several things is particularly difficult (I forget how to get around it, though it is possible)... idk, I would bet that you're a better python-er than I :P, so perhaps I just am missing some important issues
Michael
no, you're right, python's lambdas are rather difficult to use. My memory's just failing me :P
CrazyJugglerDrummer
+6  A: 

Javascript seems like a perfect choice for you - first class functions, portable, web-based, clear syntax, good library support. I know you're trying to avoid it, but I hope that once you've evaluated and rejected all other choices, that you'll give Javascript another chance.

Mark Byers
Will try it. Thanks for the advice, I definitely appreciate it! I've been thinking that Javascript is going to be a necessity for a while, but have been trying to avoid it religiously... but it's pretty much a necessity in web programming these days, so I should learn it. Thanks again!
Michael
I would avoid JavaScript. It certainly doesn't have anything close to a "strong GUI library," as requested in the OP. Even worse, it's interpreted and not strongly typed, which makes for code that tends to be slow and buggy.
RickNZ
Hrm... the speed, as I mentioned, is not a big issue, but I will take that into consideration. Thanks for your input!
Michael
I haven't encountered a gui library any stronger than html+css. It's got it's problems, but it sure isn't anywhere near as ugly as win32/swing/cocoa/next/qt/wx/ etc. It's the worst possible gui library except for all the others. Re: slow and buggy; there may be buggy programs, and interpreters that are slow- But there are also well written programs, and fast interpreters. Buggyness and slowness don't have nearly as much to do with types and interpretation as implied. On buggyness and slowness, javascript is not much different from python, ruby, or java. In fact I think it's faster than ruby.
Breton
Javascript has one very strong advantage over all the other options though: Everyone has an interpreter already installed on their machine. This is a lot more important than most programmers seem to realise.
Breton
@Breton, I'm experience in HTML-CSS, but building an "Web 2.0" interface requires more than simply HTML and CSS. I definitely agree with your final sentiment though!
Michael
@Breton: no GUI library stronger than HTML+CSS? You're joking, right? Can you name a single modern video game with a GUI written in HTML and CSS? No 3-D support, no textures, no transforms, no timelining, etc
RickNZ
@RickNZ games don't use gui libraries for their menuing system. I think you're making a mistake conflating "graphics" with "guis". They are not the same thing.
Breton
As for "No 3-D support, no textures, no transforms, no timelining" all of those assertions are incorrect.
Breton
+2  A: 

I would go with C# or perhaps F#, in the form of Silverlight. C# and F# both support anonymous functions (including lambda functions), and a variable number of arguments.

Silverlight apps can be delivered over the web, support a rich graphics library, and will run in most browsers, on both the PC and the Mac. Support for Linux should be available "soon" (Microsoft and Intel are apparently working on it). In the mean time, there's Mono and Moonlight.

From a game application perspective, Silverlight is nice because it supports things like timelines and animation. Plus, being able to separate markup from code helps keep the design clean and manageable.

RickNZ
interesting, a vote for C#... thanks for the advice! I don't know much about the language, but there's no time like the present to learn!
Michael
Another possibility would be F#. It's still a .NET language, so you can still leverage the full depth of the .NET Framework (libraries) and associated tools.
RickNZ
why F#? What do I gain from using this language?
Michael
F# is Microsoft's entry in the functional language arena (derived from ML and OCaml). Compared to C#, you gain easier representation of data flow, parallelism and async operations, as well as strong typing that's based on deep type inference. Compared to non-.NET languages, you gain access to the .NET Framework and the Silverlight deploy-and-run mechanisms (which include being able to store data on disk on the client side; something JavaScript doesn't have), and full support in Visual Studio.
RickNZ
+4  A: 

If you are familiar with Scheme, check out DrScheme programming environment.
It has GUI support and it's ported to Windows, Linux and Macintosh.

Nick D
I am quite familiar with Scheme, I am quite interested that someone would bring it up! Is there any way to make it webbased at the moment?
Michael
@Michael, in the documentation they mention how to build web applications, but I haven't tried it. See http://docs.plt-scheme.org/web-server/index.html
Nick D
For educational games and GUI support. DrScheme is unbeatable! +1
Norman Ramsey
Interesting, another vote for Scheme... I must consider this more carefully.
Michael
+3  A: 

Have you considered scala? It runs on the JVM, so you can leverage the Java swing libraries, and still have a strong functional language to code in.

Tim Howland
Yes! I've actually considered Scala for a number of reasons in my education research. Thanks for the input!
Michael
+1  A: 

FWIW, if you're teaching programming, you may also want to make sure the language has a good development environment -- a context sensitive editor and a powerful, easy-to-use debugger are very helpful. Chances are that first time programmers are going to make lots of little mistakes and being able to easily step through lines of code and view variables and debug is as important in learning how to really program as all the theoretical parts such as using lambda functions.

Adisak
hrm... "nice" debuggers always seemed to make things more difficult for me. I'm not entirely convinced by your development environment argument... but I'm most assuredly not a skilled pedagogue. Personally I'd rather go for a language that is very high level, to keep syntax issues to a minimum, but I will definitely think hard about your suggestion!
Michael
Even though this answer doesn't address the question in the OP, I agree with what Adisak is saying. I think you will find that having a strong development environment is an invaluable teaching (and learning) aid.
RickNZ
Hrm... two votes, I must consider this more carefully. I myself never used a very strong development environment, I just had syntax highlighting and a rather standard debugger... thank you for the suggestions!
Michael
I just mention this because if the game playing code is not trivial, a beginner programmer may spend more time fixing syntax errors and trying to debug their code than they spend on the initial design. Even if the code "functions" (runs with valid outputs), they may want to spend time analyzing and tweaking the algorithm to more optimally play the game.
Adisak
+1  A: 

Have you considered C++, it keeps it simple. You could have a 'CORE' thats a binary and then just get your students to compile libraries that the C++ file calls, that way each student can submit a folder with all the different library and all you would have to do is move the binary to the folder and run it. The binary would use their libraries to execute the different aspects of the code you wanted to make modular.

This approach has the added effect of teaching them how to work in teams too, you could have one person write the render subsystem, another the input subsystem, etc. And all you would have to define in your binary is a set of skeleton functions that you call to do the logic for those sections.

Zyris Development Team
C++ unfortunately is a poor pedagogical language, though I like your approach. Also I'd have to do function pointers which would make things remarkably difficult. I think your team idea is of great pedagogical value though!
Michael
The concepts can be ported to any OOP language that support libraries of any kind. If you need to do function pointers, just do it within the libraries. The binary core should just be a system initiator and loader, so no real _work_ should be done within it. Out of curiosity, what grade is this for?
Zyris Development Team
Good question! Forgot to mention that. It's directed at high school, but I would hope to extend it eventually to middle school level. Here's my issue with function pointers though, I need to allow the user to create functions for the cards, and functions for the rules of the game. So I'm curious, is it possible to create objects which can accept functions declared in a library? So, if I was playing a game such that when a card was played it must take account of the cards in play and performs an action with regards to them, could that action be stated as a function and attached?
Michael
Im not 100% sure i understand your question completely; if your asking if its possible to declare your card structure in one library and to utilize it in another, i don't believe so. You may have to define it within your binary, however you can call methods of that object from within your classes. For example, you can have the CARD class in a library accessed from within another library, the only issue is that library (2) would need to reference library (1) within itself.
Zyris Development Team
No problem, I'm not phrasing the question well. I'll try again. The simplest way to state it is, can an object take a function as a value? So, could Card.function = aFunctionPointer work?
Michael
Yes in theory it should work, im 99.9% sure it will work.
Zyris Development Team