To start learning programming, it's recommended to choose a language like C, C++, or Python, depending on your interests and goals. C and C++ provide a deeper understanding of how computers work, which can enhance programming skills, especially for game design. Online tutorials and introductory books are valuable resources for beginners, alongside community college courses for structured learning. While C may have a steeper learning curve, it can lead to better programming practices if you're willing to invest effort. Ultimately, the choice of language should align with your specific programming aspirations, such as game development or algorithm design.
#31
GreatEscapist
178
0
Well, yeah. I want to learn how to do the strategies and stuff. That's what I'm aiming for.
I think I'll look for those books. I like that stuff.
Wikipedia is pretty damn good. People check it to make sure it's good...
And, yeah, most people think I'm like, a 27 year old man. Oh well.
Girls can do crap. Especially girls like me.
So how long did it take you people to learn C/C++/C#?
Next step is to find an online tutorial that you like, for a basic introduction, or hit up your local book store or library for an intro to C++ book.
#33
NeoDevin
334
2
GreatEscapist said:
So how long did it take you people to learn C/C++/C#?
As long as you're still using it, you never really stop learning it.
I still learn new ways of doing things in C++ on a regular basis.
#34
GreatEscapist
178
0
NeoDevin said:
Next step is to find an online tutorial that you like, for a basic introduction, or hit up your local book store or library for an intro to C++ book.
Yay Barnes and Noble. Thanks for all of the helpful (or not) stuff.
NeoDevin said:
As long as you're still using it, you never really stop learning it.
I still learn new ways of doing things in C++ on a regular basis.
I suppose that would make sense. :D
#35
Kajahtava
106
1
GreatEscapist said:
Well, yeah. I want to learn how to do the strategies and stuff. That's what I'm aiming for.
Since I'm in a paedagogic mood and I can't sleep and I promised my sister I would try to sleep and I gave up and she would not like me to not sleep and destroy my life without at least helping some-one. I might as well introduce you to some 'paradigms' of programming. In descending order of best performance:
1: unstructured programming. DON'T use this. There is no advantage to unstructured programming, it's obsolete, it's so called 'write-only' programming as the program itself makes it impossible to infer for a human reader what the program is supposed to do. A reader may understand the individual statements, but has no idea what the result of all those together is supposed to be, maybe if the reader compiles and tries it. A simple example, say we want to find the first n prime numbers. In a hypothetical unstructured language this would go as so:
Code:
1: l = empty list
2: a = 2; //first number that is prime
3: b = 4; //first number that is not prime
4: c = b % a; // c is now the remainder of b divided by a
5: if c == 0 then jump to line 6 else to line 7
6: if c == a then add b to list and jump to line 7
5: b = b + 1; increase the value of b by one
6: jump to line 4 //try again for a higher number
7: if a == n then output list, else jump to line 8
8: a = a +1
9: jump to line 2
Don't try to comprehend this code, because I don't any more, I lost track while I made it, I don't even know if it's correct, it probably isn't, it's just to show you that unstructured programming is a really bad idea. You may understand the individual lines, but the entire program is obscure. Examples of unstructured programming are the old Fortran dialects, older COBOL, older BASIC, Assembly, yap, it all has 'old' because it has been abolished, thankfully.
2: structured programming, well, that's already different, maybe the biggest innovation in programming ever, we don't 'jump' to lines any more. We have a loop. So we get:
Code:
l = empty list; // no line numbers, line numbers no longer matter
a = 2;
while (a < n) {
b = 2;
while (a % b != 0 and a < b) {
b = b + 1;
} if (a != b) then add a to l;
a + 1;
}
output l;
That's already a bit simpler to see where we jump to. Probably a thing you coded yourself at some point, I still can't guarantee that this is correct and it probably isn't either. But an important part of structured programming is that we can divide a program into smaller maintainable blocks. Examples of structured programming languages are Java, C, C++, C#, Python, Perl, Scheme, Common Lisp
Then we have object-oriented programming. This is again dividing it in more maintainable blocks. We introduce objects, encapsulated pieces of code whose internal workings aren't relevant to the people that use them, but only to the people that created them. These objects can interact but the important part is encapsulation, we don't know how they work on the inside and that's none of our concern, only that they work, so:
Code:
l = new List(2,3); //we make l a new 'list object', and its no longer empty, its only element is are two and three
while (l.last < n) {//a list of course has a 'method' or 'message' depending on your flavour called 'last', that just gives us the last element of the list.
a = new Int(l.last+2) ; //I make a new integer 'a' who is 2 higher than the last element in the list. Do you know why two? and do you know also know why I specified (2,3) for the list?
if not (l.divides(a)) l.append(a);
} //lists in our language have a method called 'divide' and 'append', it just tests if a number can be divided by an element of the list, if it cannot, it adds it to the list and starts at the top of while loop again. This is because every number that is not a prime number can be divided by at least one lower prime number.
output list;
This is the first point where I'm confident that my code will work regardless of testing for bugs, because it's quite structured, of course, this language doesn't exist, but it should give you an idea of how this helps you. Examples of Object Oriented languages are Common Lisp, C#, Smalltalk, Ruby, Java, Scheme, Python, Ocaml
Next on, higher order programming, in C or Java, functions cannot take functions as argument, this might sound 'obvious', but in a lot of languages that's not a problem. Observe this puppy:
Code:
filter(list(2,n),prime?)
That's it! the function 'prime?' simply returns TRUE if its argument is a prime and FALSE otherwise. The function list simply returns a list, one argument its lowest element, another argument its highest. And 'filter' is a function that takes a list and another function, and simply only keeps the elements for which the other function returns 'true'. 'filter' is thus a 'higher order function' it can take arguments as functions, or return them.
Higher order programming comes at a significant cost though, it's performance is drastically slower than most other paradigms up to now. Object oriented is just a little bit slower than structured. But higher order programming makes up for it at various points. As you've noticed here, I never changed the value of a variable, I never even declared a variable to start with. A lot of higher order programs don't need to change values of variables at all, in fact, some higher order languages don't even allow it. So you don't ever need to copy or alter memory which gains some, but far from all, of the performance back. Examples of higher order programming languages are Scheme, Haskell, Python, C#, JavaScript, Smalltalk
Next on is 'declarative programming', this is even clearer but at a significant performance cost. In declarative programming we are mainly concerned with what we want to do, and not how to do it. Simply said:
Code:
def prime n : 2 or n > 1 and n % m > 0 : prime m
give all prime x : x < n.
We first just said 'a prime number is a number which is either 2, or a number greater than one which cannot be divided by another prime' and then said 'give all primes smaller than n'.
Examples of declarative languages are Haskell, Prolog, OCaml.
If you've paid attention you've noticed that a lot of languages are 'multi paradigm', they allow for more than one paradigm to be used. Common Lisp and Scheme are 'sister languages' in a way, their syntax is indistinguishable and they are often compared, though, Common Lisp is more used for Object Oriented and Structural Programming, and Scheme more for higher order, and a little bit of object oriented programming, even though both are effectively a different interpretation to the same syntax, and elementary programs are generally valid as either.
It also needn't be mutually exclusive, higher order programming is at some point also called 'functional programming', while prolog is 'logically declarative', Haskell is 'functionally declarative', and Scheme is often called 'functionally imperative' to contrast that.
Though these examples aren't symmetric, it does show to some degree the different flavours in programming style, for instance, we would want a 'prime?' function which we still have to code. And all algorithms used there are extremely inefficient. But it's just an illustration.
And, yeah, most people think I'm like, a 27 year old man. Oh well.
Girls can do crap. Especially girls like me.
Oh well, people think I'm a 27 year old man on the internet, and a 14 year old girl in real life, until I start to speak, then they notice that long hair needn't imply that you're female.
So how long did it take you people to learn C/C++/C#?
Nobody here 'knows' them as said before. C is fairly 'minimal', C++ is more extensive, but C# is so big that it's just impossible to know all of it.
There are some languages like Smalltalk, Scheme and Pure Prolog that are just so small that you can know every part of the language. All three have no 'reserved words', from the top of my head, the only characters with a special meaning in Smalltalk are: [:],. (plus a space), and in Scheme/Common Lisp: (,.`') (plus a space again), not sure about Prolog though.
Oh, P.S. in case you wonder, the first languages of each paradigm were:
Structured: ALGOL (1958)
Object Oriented: Smalltalk or Simula, depending on what your view on 'object oriented' is.
Higher order: Lisp (1960s, the first lisp that is, Lisp had a lot of variants over the decades, the only two that survived are Scheme and Common Lisp, Higher order programming is thus older than either object oriented or C, most people think it's fairly recent)
Declarative: Prolog, around the 1980's from the top of my head.
Sorry if I'm feeding you a bit too much by the way, but I'm actually enthusiastic about your eagreness here, I'm also needing a way to get tired. (See above)
Last edited:
#36
GreatEscapist
178
0
I'm so sorry, but most of that went ooooooover my head.
But I think I picked up main points...things to look for when I'm learning the languages.
So how long did it take you people to learn C/C++/C#?
I already knew how to program in various languages. For me I just picked up what I needed to know over time as I wrote various programs in C. I've never used C++ for work, but have done some windows programming at home. One common practice for some programs is to use C++ for the user interface stuff, and use C for internal stuff.
Things to look for when I'm learning the languages.
For a student new to learning, I'm not sure what books or web sites to recommend. The main thing is a series of programs that you write as part of the learning experience, either adding onto something you're already learned, or branching off to a different aspect of programming. Maybe there's some online community college class you could take. Since you're goal is to learn how to program as opposed to wanting a tool to help you right away with something like a physics class, then C is a good enough place to start.
Regarding programming concepts in general, which I think was the point of some of the previous posts:
Modular programming - You separate the code for a relatively large project into a number of smaller functions (subroutines). This generally makes the code easier to follow, and makes it easeir for a team of programmers to work on a single project. Virtually everyone does this now, so it's not often mentioned.
Structured programming - whatever meaning it might have once had, it's mostly part of an ongoing debate, with experts disagreeing on the basics, like the usage of goto's. I wouldn't worry about it. As a game programmer, you'll be part of team and they'll have some type of coding standards already in place.
Object oriented programming - data structures and/or methods are combined to create "objects". You could consider a mailing address to be an object, it contains a name, street address, city, state, zip, ... Methods could include how to read/write mailing address objects from/to a file, or how to display them on a screen.
Multi-threading. Since you want to be a gaming programmer, you'll have some involvment with multi-threading. With multi-threading you have separate programs that behave like or actually run on separate cpu's as part of a game, that include some form of communication with each other. For example one thread might be inputting a players controller inputs sending the inputs to another thread does the physics calculations, which then sends object position update information to a graphics thread which updates the image seen on the screen.
Parallel math. The cpu's in PC's and also the gpu's in video cards have the ability to do math on a list of numbers instead of just one number at a time. This can be used in a game's physics engine to speed up the calculations for object position updates. The cpu and gpu's makers supply libraries to simplify implementation.
Kajahtava said:
prime number generation examples
GreatEscapist said:
I'm so sorry, but most of that went over my head.
Most of the examples show how to create a list of prime numbers via an iterative process that tests one number at a time. Since the letter "l" looks like the number "1", it's a bit more difficult to follow. The "declaritive" example uses a language type that you're unlikely to encounter in a game programming environment.
Please keep this discussion on track. Also, please remember that this is a 15 or 16 year old we are trying to help, not someone pursuing a PhD in computer science.[/color]