To The Other Noob Programmers Out There...


Foxblock, Butterman: Yes to both of you :D

I'll merge those two comments into: specify, prototype, design, implement.

First, know what you are doing, and what you want it to do.
Second, if the project involves any components or functionality you are not familiar with, prototype them to gain hold of the concepts.
Third, design the actual project using best practices, diagrams and all that.
Fourth, implement the actual software.

Sound good? That's how I progressed in my current project (I'm in implementation phase).
 
Hi, I'm a complete novice to game programming; the only thing I've ever made was a crappy Pacman clone with pygame. I'm pretty comfortable with C/C++ and Java, Python, Lua, and have been messing around with Haskell for a couple of months on and off. I guess my main problem is that I get these grandiose ideas, but don't have the experience to execute them.
 
Lunatic said:
Hi, I'm a complete novice to game programming; the only thing I've ever made was a crappy Pacman clone with pygame. I'm pretty comfortable with C/C++ and Java, Python, Lua, and have been messing around with Haskell for a couple of months on and off. I guess my main problem is that I get these grandiose ideas, but don't have the experience to execute them.

That is a huge setback for me right now ^^ I have four ideas for complete, shelf quality games (though all my private work will be in 16 or 32 bit graphics, love the old stuff!). I am pushing myself every day with these in mind when I should relax and have a knowledge of the langauges in mind 0.o You definitely have some languages under your belt though ^^ I am still trying to gain C++, don't know what I will hit next... -Magi
 
Last edited by a moderator:
Lunatic said:
Hi, I'm a complete novice to game programming; the only thing I've ever made was a crappy Pacman clone with pygame. I'm pretty comfortable with C/C++ and Java, Python, Lua, and have been messing around with Haskell for a couple of months on and off. I guess my main problem is that I get these grandiose ideas, but don't have the experience to execute them.

Well you probably can't do anything else than start coding (maybe not start with the most complex one first) and you will pick up most stuff on the way.
Or you spend some weeks going through tutorials, but we all know how dry and dull that can be...

I personally, gained most of my knowledge by just doing stuff, trial-and-error coding. I set myself a goal and then tried to code that, while I had to read on topics I did not know (for example, Singletons, file access, etc.). I guess you learn best by just practicing (like in music).

foxbock out
 
Last edited by a moderator:
Kurupted_Magi said:
Lunatic said:
Hi, I'm a complete novice to game programming; the only thing I've ever made was a crappy Pacman clone with pygame. I'm pretty comfortable with C/C++ and Java, Python, Lua, and have been messing around with Haskell for a couple of months on and off. I guess my main problem is that I get these grandiose ideas, but don't have the experience to execute them.

That is a huge setback for me right now ^^ I have four ideas for complete, shelf quality games (though all my private work will be in 16 or 32 bit graphics, love the old stuff!). I am pushing myself every day with these in mind when I should relax and have a knowledge of the langauges in mind 0.o You definitely have some languages under your belt though ^^ I am still trying to gain C++, don't know what I will hit next... -Magi

It helps if you can break your ideas into much smaller milestones. Think about what your game needs to be complete, what the subsystems are and how you will interact with the hardware. Then start out with little demos of the smallest of those pieces, and work your way up. The little assignments in tutorials are nice, but it's important to experiment away from them, to be creative. That's where you learn the most.
 
Last edited by a moderator:
Hi everyone! I've made a few posts in some other threads about wanted to learn to program, and now I'm ready to start. Before, I had decided to learn C++, since I took a class in it last summer, but I've heard a lot of good things about Python recently. I've forgotten most, if not all, of what I learned at the class, so I'm thinking about started fresh with Python. Most of you seem to like C++, but say it can be confusing and unintuitive at times. I want to start out making simple programs at first, and then maybe make some games for the Pandora. What do you guys think?
 
amf66 said:
Hi everyone! I've made a few posts in some other threads about wanted to learn to program, and now I'm ready to start. Before, I had decided to learn C++, since I took a class in it last summer, but I've heard a lot of good things about Python recently. I've forgotten most, if not all, of what I learned at the class, so I'm thinking about started fresh with Python. Most of you seem to like C++, but say it can be confusing and unintuitive at times. I want to start out making simple programs at first, and then maybe make some games for the Pandora. What do you guys think?

Sounds like a good idea to me. :)

C++ is the language of choice for some performance-critical applications (like games) for a number of reasons:
  1. It is object-oriented, which tends to be the more intuitive paradigm for games.
  2. It's a mature language with much development done in compilers. This allows object code to be better optimized.
  3. It is a compiled language that gives the programmer significant control over the object code.

There are some tradeoffs:
  1. The OOP paradigm tends to produce slower code than the procedural paradigm (C++ is slower than C, if you know what you're doing).
  2. It's a very complex language, making it easier to make mistakes and introduce bugs.
  3. Managing memory can be very tough to get right.
  4. The more direct access to memory must be treated with care. It's easy to introduce security holes that give up half the battle to crackers.

Haha, someone else can verify those. I actually have never used C++, but... I know there have been papers detailing the performance deficits of OOP, my professor in the compilers course echoed what Senor Quack said about C++'s commplexity, and I'm familiar with smashing the stack and other simple methods of exploitation. From what I understand of C++, the above holds true. ;)
 
Last edited by a moderator:
proflogic said:
amf66 said:
Hi everyone! I've made a few posts in some other threads about wanted to learn to program, and now I'm ready to start. Before, I had decided to learn C++, since I took a class in it last summer, but I've heard a lot of good things about Python recently. I've forgotten most, if not all, of what I learned at the class, so I'm thinking about started fresh with Python. Most of you seem to like C++, but say it can be confusing and unintuitive at times. I want to start out making simple programs at first, and then maybe make some games for the Pandora. What do you guys think?

Sounds like a good idea to me. :)

C++ is the language of choice for some performance-critical applications (like games) for a number of reasons:
  1. It is object-oriented, which tends to be the more intuitive paradigm for games.
  2. It's a mature language with much development done in compilers. This allows object code to be better optimized.
  3. It is a compiled language that gives the programmer significant control over the object code.

There are some tradeoffs:
  1. The OOP paradigm tends to produce slower code than the procedural paradigm (C++ is slower than C, if you know what you're doing).
  2. It's a very complex language, making it easier to make mistakes and introduce bugs.
  3. Managing memory can be very tough to get right.
  4. The more direct access to memory must be treated with care. It's easy to introduce security holes that give up half the battle to crackers.

Haha, someone else can verify those. I actually have never used C++, but... I know there have been papers detailing the performance deficits of OOP, my professor in the compilers course echoed what Senor Quack said about C++'s commplexity, and I'm familiar with smashing the stack and other simple methods of exploitation. From what I understand of C++, the above holds true. ;)

Thanks for your input! B)

Anyone else?
 
Last edited by a moderator:
amf66 said:
Anyone else?
I would say no to C++. Sure, it's fast, and it has its advantages, but it is a really difficult language to start programming "for real" in.

The biggest problem with C++, and sometimes C as well, is that they are inconsistent languages. E.g., you have to *know* that:
Code:
const float (*GameObject::distanceGetter)(const GameObject &) = &myObject.distanceTo;
...creates a constant function pointer with the name "distanceGetter", and you can only know this by learning how function pointers work (compare this to Python where you simply would do "distanceGetter = myObject.distanceTo"). There's no "rule" that makes it possible to figure it out on your own (e.g. that "*" always means "pointer to", because that's not the case); it seems to me, and it's probably even true, that the language was designed by throwing together a gigantic heap of concepts and sewing them together with a rusty nail and wire from a shredded chain mail.

Then there's the issue of different styles. C++ is chaotic. Some libraries will be really C-inspired and always use "char *" for strings and pointers to objects for everything (If you use proper C++, you will *never* need pointers, except for arrays!). Some will use proper C++ features such as references, templates, etc. And there's not a consistent naming rule for things in C++ either; some call their classes e.g. "game_object" while others call them "GameObject" (btw, the latter is preferred, always, according to the "standard"). It's really frustrating.

Finally, and I'm really not happy about this since it's bitten me very often: There's no standardized way of handling source code and dependencies in C/C++. All other languages have a centralized code management system: Python uses Eggs/easy_install, Java uses Maven/Ivy, Ruby uses Gems, Haskell uses Hackage/Cabal; even languages like OCaml, Google Go and so on have centralized build systems.
No such thing for C++; some use Makefiles, some use e.g. CMake, Jam or other make utilities, some just compile their executables using the command line. So, you have to track down everything you need on your own, with often only header files to guide you, and you have to make sure that you get the right libraries for the right OS and arch and compiler and version and dynamic/static libs and the right optimizations and...


Python is a good example of a more well-designed language. Everything works like you expect it to work, code is mostly cross-platform and so are libraries, so you can get hold of them easily, and there's a standard naming convention. If you don't like Python, try Java (Java Applets are great for small, fast games; you can release them for the Pandora, Win, Lin, Mac, and on web pages without having to make *any* changes at all) or, if you want to have *fun* and also *learn* while programming, try something like OCaml or Haskell, which are languages that make you design your application well whatever you do (e.g., in C++ you can make mistakes that make your application segfault. In OCaml, this is impossible to do. You simply cannot make certain mistakes in your program because of how the language was constructed).
I would recommend starting with a language that uses static typing (e.g. where you can't do "x = 2" and later "x = 'hello'") because having the compiler correct your errors can be a real help in the beginning, so Python would not be at the top of my list.


*If* you still choose to use C++, here are some things to think about:
  • Memory management can be a real bitch to get right. However, it *is* possible to simplify memory management in C++; here are some alternatives:
    • Never, ever use "new" or "delete" or pointers in your programs. It *is* possible and often very efficient. You create an object on the stack by storing it as a private variable somewhere and then passing around what you need by reference. The only downside to this is that you won't be able to dynamically add memory, ever, so you'll have to enforce some limitations in your program (e.g. never more than 64 objects on screen at once) but you choose those limitations yourself.
    • Use reference-counting pointers. They are often called "smart pointers" or "ref_ptr" and you'll find them around the web (there are many different implementations). They basically give you garbage collection (more or less) for C++ while retaining the same performance. You can just say e.g.:
      Code:
      void MyObject::doSomething()
      {
        ref_ptr<MyOtherObject> obj = new MyOtherObject;
        obj.doStuff();
        //You don't have to say "delete obj;" here; the ref_ptr deletes its
        //contents automatically!
      }
    • Learn to do memory management in C++. You have to make every object you create have an "owner" that then deletes the object once you're done with it. It can become really complicated but there have literally been books written on the subject, so it's possible to learn.
  • Never ever use globals ever in your code. Everything you do must belong to some class (except for the main method of course). This includes harmless things such as:
    Code:
    //MyCounter.cpp:
    
    int i = 0; //← not in a class
    int MyCounter::getNextInt()
    {
      return ++i;
    }
    If you want that behavior, add a static variable to MyCounter. Even enums and similar should be stored in classes or at the very least name spaces.
  • Learn how to use templates. They are really useful and can be used to emulate type parameters that you find in other languages.
  • Never use implicit conversions for anything if you can avoid it. Make yourself aware of when implicit conversions happen (e.g. "float x = 1;" casts int to float; harmless example)
  • Never cast anything using "reinterpret_cast" or via e.g. "(ClassB *)((void *)&myObject)". You then often lose track of which type an object has. Try to stick to the C++ type system as much as possible, and if you need a weird cast, it's probably a sign that you're doing something wrong.
  • Try to always use constants and immutable data when you can. Getters and setters can be useful sometimes, but mostly they aren't.

That's all I had to say...
 
Last edited by a moderator:
I can agree to most of the stuff dflemstr said - listen to that guy, he knows what he is talking about :)

Also some useful information on smart pointers:
http://ootips.org/yonat/4dev/smart-pointers.html

foxblock out
 
dflemstr: Your post was very informative, and now I don't think I'll learn C++ first. However, you say that Python is well-designed in the fifth paragraph, but you also say it wouldn't be at the top of your list, because it doesn't use static typing. So would you recommend Java? I took a class in Java two years ago, but I've lost all my work since my flash drive disappeared. (I now keep backups) I think I could relearn the basics quickly because of this, so maybe Java is the best for me. But, for Java you have to have a virtual machine to run the programs. Do you know if there are any JVM's for arm-linux and the Pandora? I found one called JamVM, which says it works with Linux using the ARM architecture. Have you heard of this?


Everyone, thank you for your responses and patience with me!
 
amf66 said:
dflemstr: Your post was very informative, and now I don't think I'll learn C++ first. However, you say that Python is well-designed in the fifth paragraph, but you also say it wouldn't be at the top of your list, because it doesn't use static typing. So would you recommend Java? I took a class in Java two years ago, but I've lost all my work since my flash drive disappeared. (I now keep backups) I think I could relearn the basics quickly because of this, so maybe Java is the best for me. But, for Java you have to have a virtual machine to run the programs. Do you know if there are any JVM's for arm-linux and the Pandora? I found one called JamVM, which says it works with Linux using the ARM architecture. Have you heard of this?


Everyone, thank you for your responses and patience with me!

Haha, well I hope you didn't take my post as positive for learning C++ first. I was explaining that C++ might be overwhelming for the beginner--It's easier to shoot yourself in the foot. Don't get me wrong, though: you can do it in any language.

As far as support for Java goes, Debian has arm packages for the OpenJDK JVM too, so there's stuff around. Personally, I thought it was a great language for learning the principles of OOP. It was the first language I picked up in any serious class, though, so I'm a bit biased. ;)
 
Last edited by a moderator:
amf66 said:
However, you say that Python is well-designed in the fifth paragraph, but you also say it wouldn't be at the top of your list, because it doesn't use static typing. So would you recommend Java?
A small comparison thingy for those two languages:
  • Java
    • "Policy": To be able to create one program that runs on *any* computer without changes (compile once, use everywhere). This means that if a feature can't be supported on all platforms, it isn't included in the language (but most platforms support most things so it's not a problem)
    • Uses: Server applications, applets (like flash), desktop applications, mobile games
    • Platforms: Win/Lin/Mac, Mobile, Solaris
    • Features:
      • Everything is an object, except for primitives (ints, booleans, chars, etc), types, methods/functions and statics. So, it's a very object-oriented language.
      • Because of the object oriented nature, classes are used everywhere. So, instead of saying e.g.
        Code:
        //This isn't actually valid Java:
        Function<Void> x = System.out.println("Hello World!");
        x();
        you have to say:
        Code:
        Runnable x = new Runnable {
          @override
          void run() {
            System.out.println("Hello World!");
          }
        }
        x.run();
        ...because the method "println" isn't an object (as stated above). So, Java sometimes forces you to type more than you'd want to. BTW, the use of Runnable there is actually nonsensical; you usually only need it for more complex applications.
      • Java is really fast. According to this benchmark, only Ada (a procedural programming language), C, C++ (you know these) and Scala (a language that runs on the JVM like Java; my favorite language btw) are faster than Java. People make you believe that Java is slow, and well, it *is* slow: about 2x as slow as C, but Python is 346x slower than C (in that fannkuch benchmark) so it's all relative.
      • Java has support for "everything" built-in. You don't have to go look for libraries if you want to draw pretty graphics or do networking; Java already does that in the standard libraries. This is all the code that's needed to make an applet that draws a square:
        Code:
        import java.awt.*;
        import java.applet.*;
        
        public class MyApplet extends Applet {
          public void init() {} //Empty because we don't need to do any initialization
          public void stop() {} //Empty because we don't have to clean anything up at the end
          public void paint(Graphics tmp) { //This is called every time the applet wants to be redrawn (e.g. when a window moves over it)
        
            //"Graphics" is an old object that was used in Java 1.0.
            //Since then, Sun has added a Graphics2D interface that
            //supports more things, such as anti-aliasing, faster
            //drawing, better font support, more options etc.
            //However, so as not to break old code, you still have
            //to use "Graphics" in the "paint()" method declaration
            //We cast our "Graphics" object to a "Graphics2D" object here:
            Graphics2D g = (Graphics2D) tmp;
        
            //"g", our Graphics2D object, is now the object we use to draw things:
        
            //Pick a color
            g.setColor(Color.red);
            
            //Fill one quarter of the screen with the color:
            g.fillRect(0, 0, this.getWidth / 2, this.getHeight / 2);
          }
        }
        And that's it! It's the whole application!
        This is just a very simple example; there are tutorials around the web on how to do more.
      • Java is a very popular language. It's actually the most used language in the world if you count all kinds of applications (not just games) because it's used on servers and for databases etc. This means that there are millions who can help you with it, that there are thousands of libraries out there for you to use, and that the language has some serious backing so you won't see it break or something like that.
      • Java is a very old language. There aren't that many "nice features" that you'd expect from a modern programming language. Fortunately, there's Scala for that (a language that probably will replace Java in the future) but I don't recommend you learn Scala because it's a very experimental language (it has some unique features you don't find anywhere else but that are ... experimental)
  • Python
    • "Policy": Programming should be *easy*, and programming code should look nice and be easy and concise to read. Also, applications should be runnable everywhere and with relative ease (e.g. you don't have to compile Python code)
    • Uses: Server applications, administrative tools, desktop applications, helper scripts, and (increasingly more for) games
    • Platforms: Any platform that has a Python interpreter
    • Features:
      • Everything is an object except for types. This means that Python is "more" object-oriented than Java.
      • Dynamic typing. What this means is that you don't write (Java):
        Code:
        int sum(int[] numbers) {
          int result = 0;
          for(int x : numbers)
            result += x;
          return result;
        }
        ...but instead (Python):
        Code:
        def sum(numbers):
            result = 0
            for x in numbers:
                result += x
            return result
        AKA, you omit type annotations, and variables don't have static types. This gives you more freedom, since (in this example) you are able to only pass arrays of integers to the Java method, while you can pass different things (e.g. lists, stacks, etc) to the Python method. However, this also gives you less safety, because you can also pass e.g. a float by mistake to the python method, and you'll only spot the mistake once your application crashes at runtime.
      • Python has some really well-designed core libraries. There's support for collections, algorithms, a lot of helper functions etc. And there's of course also support for networking and file handling etc. Python does not have built-in GUI toolkits, however, so you have to use external ones like Qt or GTK.
      • Python is really popular in the open source world (which is understandable since you basically have to release the sources for every Python app you make, since it's the source files that *are* the program). So, you'll find support for it everywhere.
      • Python is really slow. There are projects that attempt to solve this (psycho, pypy, etc), but none of them are *standard* yet.
      • Python is an actively developed language. It gets new features all the time, and it grows to suit its users. This means that sometimes, old code breaks, but it also means that the language won't be stuck forever with a fixed feature set and slowly become obsolete.

amf66 said:
I took a class in Java two years ago, but I've lost all my work since my flash drive disappeared. (I now keep backups) I think I could relearn the basics quickly because of this, so maybe Java is the best for me. But, for Java you have to have a virtual machine to run the programs. Do you know if there are any JVM's for arm-linux and the Pandora? I found one called JamVM, which says it works with Linux using the ARM architecture. Have you heard of this?
Well, for Python you need a Python interpreter to run the programs, so it's not really that much of a difference!
There are JVMs for the Pandora, but I don't know if one will be included by default. I hope that one will, and it'll probably be JamVM (a *really fast* interpreter for Java) or the OpenJDK DaVinci JVM (a JVM that compiles Java code to native code on the fly via JIT, so it'll run faster but use more memory)
 
Last edited by a moderator:
dflemstr said:
Java is really fast. According to this benchmark, only Ada (a procedural programming language), C, C++ (you know these) and Scala (a language that runs on the JVM like Java; my favorite language btw) are faster than Java. People make you believe that Java is slow, and well, it *is* slow: about 2x as slow as C, but Python is 346x slower than C (in that fannkuch benchmark) so it's all relative.

Whoa, the fastest scala implementation uses an order of magnitude more memory than Java. In most of the benchmarks, they seem comparable, but there are a few crazy ones.
 
Last edited by a moderator:
proflogic said:
dflemstr said:
Java is really fast. According to this benchmark, only Ada (a procedural programming language), C, C++ (you know these) and Scala (a language that runs on the JVM like Java; my favorite language btw) are faster than Java. People make you believe that Java is slow, and well, it *is* slow: about 2x as slow as C, but Python is 346x slower than C (in that fannkuch benchmark) so it's all relative.

Whoa, the fastest scala implementation uses an order of magnitude more memory than Java. In most of the benchmarks, they seem comparable, but there are a few crazy ones.
Yeah, well, they obviously use all kinds of hacks to squeeze out every last bit of performance in those benchmarks... You should see the source code o_O
 
Last edited by a moderator:
Back
Top