• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

arit

Member
Quick question. I've been using Java since I began college, and now I need to use C++. The problem is my teacher wants the things we'll make to run on Linux, and I'm too lazy to put dualboot on my PC, so is there a way to make some code in Windows and compile it for use in Linux?

A virtual machine (e.g. virtualbox) running linux should be sufficient.
 

Water

Member
Quick question. I've been using Java since I began college, and now I need to use C++. The problem is my teacher wants the things we'll make to run on Linux, and I'm too lazy to put dualboot on my PC, so is there a way to make some code in Windows and compile it for use in Linux?

What kind of stuff are you writing? If it's not low-level, doesn't involve platform specific libraries, and you are using standard C++, you can probably do 99% of your work using a sufficiently modern compiler in Windows. (Virtual machine is nicer, of course, if you'll bother to set one up.)

Visual Studio 2013 supports most of the new features. If that's not good enough, there's the Cygwin environment you can install in Windows and use a new-ish GCC plus most usual *nix tools.

Since you'll be almost certainly be turning in source code rather than binaries, you might technically not even need to compile for Linux, but I certainly recommend testing the work on the school Linux systems before turning it in. At least for the first times.
 

Kansoku

Member
What kind of stuff are you writing? If it's not low-level, doesn't involve platform specific libraries, and you are using standard C++, you can probably do 99% of your work using a sufficiently modern compiler in Windows. (Virtual machine is nicer, of course, if you'll bother to set one up.)

I'll be working with Graph Algorithms. I don't think specific libraries will be necessary, but who know, my teacher is kinda crazy =P

Will look into setting up a virtual machine then. Thanks everyone.
 

Moosichu

Member
I'm just wrapping up my gap year. In November after a weeks work experience (my first programming experience :p). I have been teaching SQL, PHP and Javascript and have been making a lot of use of the Yii framework.

Question is: starting Uni next year and they will be traching Java and ML to begin with. Should I get ahead and look at those or focus on a different language now for fun like C to widen my vocab as it were.
 

Tristam

Member
Having done most of my programming with scripting languages (JS, PHP, Python, Perl) and having toyed around with Java--all mostly in a Linux development environment--I'm now getting into .NET as part of my new job, where both VB.NET and C# are used. It took me a good hour or two to figure out how to reference external libraries in compiling a VB.NET executable using VBC.** In Java it is sufficient to merely include the source or compiled class files in the same directory as the file that uses them, but for VBC I had to specifically compile the class file as a library (using the /target switch with library as the value) and then include that as a reference (using the /reference switch with the new DLL as the value) in compiling the file that imports it. For .NET guys and gals, is this strictly a necessary step, or is there an alternative/better method for importing namespaces living in separate files?

And yeah, I know Visual Studio will add these references automatically when building from VS, but for the simple learning exercises that I'm doing now to familiarize myself with the language I prefer to do most things in a text editor and using command line tools.

**The reason it took me so long was twofold. First, all the StackOverflow responses I could find more or less said: use Visual Studio. Second, MS's documentation on VBC (http://msdn.microsoft.com/en-us/library/c03639ab.aspx) confused me somewhat. I kept attempting to use the /imports switch since the "Purpose" for it reads "Imports a namespace from a specified assembly" (which is what, in my mind's eye, I wanted to do) whereas the /reference switch "Purpose" reads "Imports metadata from an assembly."
 
I'll be working with Graph Algorithms. I don't think specific libraries will be necessary, but who know, my teacher is kinda crazy =P

Will look into setting up a virtual machine then. Thanks everyone.
VirtualBox or VMWare will be your best bets. Install a *buntu or Mint. Once you're there grab gcc, QtCreator, valgrind, and... live like a king
 

GabDX

Banned
I learned Fortran for my computational physics class and it was so damn worth it. The way arrays are handled and the ability to do element-wise operations make number crunching so much more convenient than in something like C/C++.

As a simple example, just compare this in Fortran:
Code:
z = sqrt(x**2 + y**2)
with this in C:
Code:
for (int i = 0; i < N; i++) {
    z[i] = sqrt(x[i]*x[i] + y[i]*y[i]);
}
Both do the same thing but in Fortran it's just way more readable and faster to type. Anyone else with some Fortran experience?
 

upandaway

Member
Would it be reasonable to first learn Python with Python 2 materials and then with 2-to-3 materials, or is it better to just jump into 3? Preferably in the context that I won't use it for at least a year or two for anything practical.

I was planning on learning 2 and then 3 but I'm not sure if that's a bad idea in 2014.
 

poweld

Member
Would it be reasonable to first learn Python with Python 2 materials and then with 2-to-3 materials, or is it better to just jump into 3? Preferably in the context that I won't use it for at least a year or two for anything practical.

I was planning on learning 2 and then 3 but I'm not sure if that's a bad idea in 2014.

I think 2.7 is still the standard. If you learn that, I'm sure it won't be too difficult to transition to 3 when it becomes the generally accepted standard.
 
I learned Fortran for my computational physics class and it was so damn worth it. The way arrays are handled and the ability to do element-wise operations make number crunching so much more convenient than in something like C/C++.

As a simple example, just compare this in Fortran:
Code:
z = sqrt(x**2 + y**2)
with this in C:
Code:
for (int i = 0; i < N; i++) {
    z[i] = sqrt(x[i]*x[i] + y[i]*y[i]);
}
Both do the same thing but in Fortran it's just way more readable and faster to type. Anyone else with some Fortran experience?

Fortran is the reason I switched from Aerospace to Computer Science.
 

Tamanon

Banned
Would it be reasonable to first learn Python with Python 2 materials and then with 2-to-3 materials, or is it better to just jump into 3? Preferably in the context that I won't use it for at least a year or two for anything practical.

I was planning on learning 2 and then 3 but I'm not sure if that's a bad idea in 2014.

2 is still incredibly widely used.

I don't think the differences are too terrible to learn later on. You can even start on some of them, since some work in Python 2 anyways.

For instance:

Code:
print "Hello World"

can be written the Python 3 way where print is a function. This will actually work in Python 2.7.

Code:
print("Hello World")
 

Roflobear

Member
Just a couple of Java questions:

1) If I have multiple instances of the Scanner object (say one in the main method, one in another method in another class called by the main method, and yet another one in another method called by the main method), do I have to close each one or just the one in the main method?

I thought each instance had to be closed individually with the close() method but whenever I did this, I would run into problems. I usually fixed it by leaving the close() method of only the Scanner in the main method so I was wondering if that's the only time it's needed?

2) My professor said the following code

Code:
InputStreamReader inStream = new InputStreamReader(System.in);
BufferedReader stdin = new BufferedReader(inStream);

is more efficient than the following code

Code:
Scanner stdin = new Scanner(System.in);

I don't really understand Scanners or BufferedReaders that well but was wondering why this is the case
 

upandaway

Member
Thanks for the Python answers, guess I'll go with 2

2) My professor said the following code

Code:
InputStreamReader inStream = new InputStreamReader(System.in);
BufferedReader stdin = new BufferedReader(inStream);

is more efficient than the following code

Code:
Scanner stdin = new Scanner(System.in);

I don't really understand Scanners or BufferedReaders that well but was wondering why this is the case
Differences between Scanner and BufferedReader (though I'm not 100% on it, you may wanna research more)

- BufferedReader is synchronized and Scanner isn't, so use BufferedReader for concurrency
- Scanner tokenizes input and BufferedReader uses strings, so use Scanner when you need to parse primitive types
- BufferedReader has a bigger buffer, so use it for long strings, otherwise use Scanner when you wanna parse specific stuff

It's a matter of which is more fit for your needs
 

phoenixyz

Member
I would recommend starting with Python 3. Most libraries are available by now. I don't really see much sense in clinging to an old version (Python 3 is out for more than 5 years) especially when starting out. If your stuff really, absolutely needs to run in a Python 2 environment then go ahead and learn it, otherwise jump straight into Python 3 imho.
 
Just a couple of Java questions:

1) If I have multiple instances of the Scanner object (say one in the main method, one in another method in another class called by the main method, and yet another one in another method called by the main method), do I have to close each one or just the one in the main method?

I thought each instance had to be closed individually with the close() method but whenever I did this, I would run into problems. I usually fixed it by leaving the close() method of only the Scanner in the main method so I was wondering if that's the only time it's needed?

You were running into problems because you were (probably?) reading from System.in. When you call close() on a scanner it invokes the close() method on the underlying input stream. In this case, closing standard input means you can't read from it for the rest of the life of the process. You shouldn't ever really close standard input anyway.
 

oxrock

Gravity is a myth, the Earth SUCKS!
Would it be reasonable to first learn Python with Python 2 materials and then with 2-to-3 materials, or is it better to just jump into 3? Preferably in the context that I won't use it for at least a year or two for anything practical.

I was planning on learning 2 and then 3 but I'm not sure if that's a bad idea in 2014.

When I got back into programming I started with python 2 but only because I had already had some previous experience with it. I don't really see there being a reason for starting with 2 currently honestly. They're so similar that there's hardly a difference, so if you need to write in 2, you totally can. Going from 2-3 has some annoying quirks however. For me, having to use the print function instead of just wrapping a string in quotes pissed me off. I guess I'm just silly that way. From what I understand, 2 is still the most widely used version but i think it's no longer receiving updates, so slowly people will be migrating to 3.
 

tuffy

Member
From what I understand, 2 is still the most widely used version but i think it's no longer receiving updates, so slowly people will be migrating to 3.
2 is still getting maintenance updates, but no longer getting new features. The good news is that a number of features were backported from 3 to 2.7 and 3.3 added features to make porting from 2 easier (like re-adding 'u' prefix support for Unicode strings). So it's a lot easier to write code that supports both Python 2 and 3 these days.
 

upandaway

Member
My main reason for going with 2 was that I had a book someone gave me which was mostly 2 (2009), but now I see that there's a free PDF online of the same book adapted for 3 (date on it is 2014) so I might as well go with 3 now and briefly look at 2 after. Reading on a screen will be a bit annoying but oh well.
 

mltplkxr

Member
Just a couple of Java questions:

1) If I have multiple instances of the Scanner object (say one in the main method, one in another method in another class called by the main method, and yet another one in another method called by the main method), do I have to close each one or just the one in the main method?

I thought each instance had to be closed individually with the close() method but whenever I did this, I would run into problems. I usually fixed it by leaving the close() method of only the Scanner in the main method so I was wondering if that's the only time it's needed?

2) My professor said the following code

Code:
InputStreamReader inStream = new InputStreamReader(System.in);
BufferedReader stdin = new BufferedReader(inStream);

is more efficient than the following code

Code:
Scanner stdin = new Scanner(System.in);

I don't really understand Scanners or BufferedReaders that well but was wondering why this is the case

Buffered streams are useful when the source of the input stream or the destination of the output stream is slow. The most common case is accessing files. Accessing files is slower than accessing memory. When a buffer is inserted between the file and the program in the stream chain/pipe, the buffer will fill itself with data from the file and the program will access the buffer in memory instead of accessing the file. That's why it's more efficient.

Imagine you have a bowl of coffee grains (a file) and a grinder (your program). If you only use a FileInputStream, you're taking one grain at a time and putting it in your grinder, grinding the grain, taking another one, grinding it again, etc. Putting a buffer between the file and the program is like attaching a funnel to the grinder. Now you can take a scoop of coffee or the whole bowl and put it into the funnel, and just start to grinder.

Another metaphor would be the difference between a musket and a machine gun. With the musket, you take a bullet, put in the barrel of the gun (etc) then shoot. With a machine gun, you put a magazine (a buffer) in the gun and shoot several bullets until you need to recharge.

Java I/O on O'Reilly is a great book on the subject, if you want to understand the subject.

Regarding the prob with your program, it's really hard to say without looking at the code.
 
Anybody here use any postscript? Would love to know how to insert an actual line break. Better yet, a structure that would create a line break. It has been a nightmare trying to figure this out. I have to manually go through each line of data.... ugh
 

NotBacon

Member
From the Linux thread:

QfzGxQb.jpg
 
Seems like there is no consensus on what languages to learn first. Someone says python and then another C#. This is why people get confused.
 

NotBacon

Member
Seems like there is no consensus on what languages to learn first. Someone says python and then another C#. This is why people get confused.

Generally: Python or Java, then C

Windows specific or quick GameDev: C#

Linux shenanigans: C

Android: Java

Really doesn't matter as the biggest difference between languages is just syntax.
 

r1chard

Member
I think 2.7 is still the standard. If you learn that, I'm sure it won't be too difficult to transition to 3 when it becomes the generally accepted standard.
2.7 is the current 2.x standard and will be supported for more than a decade from now.

I would recommend a new Python developer learn Python 3 and then learn the small changes necessary to switch to Python 2 if that becomes necessary on a project-by-project basis. Python 3 has well enough support these days to be productive - I've personally not had to switch back to Python 2 for some time. Even OpenStack is looking like switching in the near future (just as soon as we deal with gevent, grrr).


Really doesn't matter as the biggest difference between languages is just syntax.
For that list yes. Then there's Haskell et al.

We had a Haskell proponent come along to PyCon AU last weekend and try to convince a bunch of web developers that they were doing it wrong (he repeatedly stated that he cannot program without the tools Haskell provides - this line of reasoning kinda mystified the audience). I don't have anything against Haskell (except that I don't appear to be clever enough to use it) but his argument didn't really go down well :)
 
What is the best online resource to learn something like C? I've never done anything other than a bit of html and I want to be thorough with this. Is C even the best first language to go for? I'd like to eventually switch to a job in programming.
 
What is the best online resource to learn something like C? I've never done anything other than a bit of html and I want to be thorough with this. Is C even the best first language to go for? I'd like to eventually switch to a job in programming.
C can get a bit confusing with pointers and memory locations stuff. But understanding these concepts is important in programming. I would start with java (it is what i started with so i have a bias). Java is neither too simplistic (like ruby python) nor to complicated like c and c#.
If you have an idea of what you want to do with programming, look up what language is fit for that task and learn accordingly.
 
C can get a bit confusing with pointers and memory locations stuff. But understanding these concepts is important in programming. I would start with java (it is what i started with so i have a bias). Java is neither too simplistic (like ruby python) nor to complicated like c and c#.
If you have an idea of what you want to do with programming, look up what language is fit for that task and learn accordingly.

On his behalf; do you know of any very solid Java resources? I had been learning Python but decided it was probably better to use a language that was more widely used (and learning OOP seems wise) so I was thinking of diving back into Java--which I haven't worked with since my second semester in college which was 2008.
 

oxrock

Gravity is a myth, the Earth SUCKS!
On his behalf; do you know of any very solid Java resources? I had been learning Python but decided it was probably better to use a language that was more widely used (and learning OOP seems wise) so I was thinking of diving back into Java--which I haven't worked with since my second semester in college which was 2008.
psh python > java (not really but I'm partial)

Also, what exactly are your goals for programming? Might be best to just jump right into a language appropriate for your goals.
 
On his behalf; do you know of any very solid Java resources? I had been learning Python but decided it was probably better to use a language that was more widely used (and learning OOP seems wise) so I was thinking of diving back into Java--which I haven't worked with since my second semester in college which was 2008.
I learned a good chunk of android from the New Boston:https://buckysroom.org/videos.php
But I don't know if that's what you would call a solid resource. They have a lot of introductory information, but nothing theoretical or involving questions like "what are good design patterns", which is what you want if I'm understanding you correctly.
 

upandaway

Member
On his behalf; do you know of any very solid Java resources? I had been learning Python but decided it was probably better to use a language that was more widely used (and learning OOP seems wise) so I was thinking of diving back into Java--which I haven't worked with since my second semester in college which was 2008.
I used Head First Java to learn it "properly" after a pretty bad teacher in high school and it was really good.
 

Roflobear

Member
Differences between Scanner and BufferedReader (though I'm not 100% on it, you may wanna research more)

- BufferedReader is synchronized and Scanner isn't, so use BufferedReader for concurrency
- Scanner tokenizes input and BufferedReader uses strings, so use Scanner when you need to parse primitive types
- BufferedReader has a bigger buffer, so use it for long strings, otherwise use Scanner when you wanna parse specific stuff

It's a matter of which is more fit for your needs

Thanks for the response. I should start learning the differences between the two. I/O stuff always confuses me

You were running into problems because you were (probably?) reading from System.in. When you call close() on a scanner it invokes the close() method on the underlying input stream. In this case, closing standard input means you can't read from it for the rest of the life of the process. You shouldn't ever really close standard input anyway.

Yup that's actually exactly what I was doing. That would explain why I was running into trouble whenever I used the close() method on all the Scanners aside from the last one in my main method. I guess it's bad programming practice to have that many instances of Scanner open at the same time? Someone on Stack Overflow said if you absolutely need to use it in another method, just pass it as a parameter in that method. That's probably what I'll start doing. Also could you explain what you meant when you said not to close standard input? What's the drawback of doing it, especially if it's at the end of a main method? Eclipse always gives that yellow underline if you don't close it.

Buffered streams are useful when the source of the input stream or the destination of the output stream is slow. The most common case is accessing files. Accessing files is slower than accessing memory. When a buffer is inserted between the file and the program in the stream chain/pipe, the buffer will fill itself with data from the file and the program will access the buffer in memory instead of accessing the file. That's why it's more efficient.

Imagine you have a bowl of coffee grains (a file) and a grinder (your program). If you only use a FileInputStream, you're taking one grain at a time and putting it in your grinder, grinding the grain, taking another one, grinding it again, etc. Putting a buffer between the file and the program is like attaching a funnel to the grinder. Now you can take a scoop of coffee or the whole bowl and put it into the funnel, and just start to grinder.

Another metaphor would be the difference between a musket and a machine gun. With the musket, you take a bullet, put in the barrel of the gun (etc) then shoot. With a machine gun, you put a magazine (a buffer) in the gun and shoot several bullets until you need to recharge.

Java I/O on O'Reilly is a great book on the subject, if you want to understand the subject.

Regarding the prob with your program, it's really hard to say without looking at the code.

Those metaphors were great. Really made BufferedReaders easier to understand. As for my code, all my instances of Scanner were wrapped around System.in so like lorebringer said, I guess I was closing System.in as well. That would explain why I was running to issues. Also thanks for the book recommendation. I'll check it out when I get the chance
 

P44

Member
Seems like there is no consensus on what languages to learn first. Someone says python and then another C#. This is why people get confused.

Amongst all the options, you can pretty much go for anything, there isn't an a beginner language per se, all languages that would be advised are used in programming in the real world, so there sort of can't be a beginner language. That said, C# or Python would both be good options.

Don't get hung up on language too much, language is just a tool, a few more years and you'll know 3-4 languages or maybe even more and you'll just use them where they're most suited - the most important thing is that you extract the principles, the method of thought, etc.

-----

I've decided to start dabbling with machine learning, going to have a go with making some gesture control shit for a wii remote. Should be fun regardless. I just need some software/drivers to take the input and a way to get that input.
 

Water

Member
What is the best online resource to learn something like C? I've never done anything other than a bit of html and I want to be thorough with this. Is C even the best first language to go for? I'd like to eventually switch to a job in programming.
No, C is far from the best first language. I explain some of the reasoning here. Learning C eventually is good (not mandatory though), but you are wasting your time unnecessarily and slowing down your learning if you start from it.
 
Also, what exactly are your goals for programming? Might be best to just jump right into a language appropriate for your goals.

I don't really have a specific goal. I'm stuck in a dead end major at a useless college so I'm trying to create another job path for myself. I don't know what kinds of jobs are out there for the most part. Game design would be a dream, obviously, but I don't know if it's really safe to make that my goal, so I'm not specifically working towards that.
 
Yup that's actually exactly what I was doing. That would explain why I was running into trouble whenever I used the close() method on all the Scanners aside from the last one in my main method. I guess it's bad programming practice to have that many instances of Scanner open at the same time? Someone on Stack Overflow said if you absolutely need to use it in another method, just pass it as a parameter in that method. That's probably what I'll start doing. Also could you explain what you meant when you said not to close standard input? What's the drawback of doing it, especially if it's at the end of a main method? Eclipse always gives that yellow underline if you don't close it.

If you're creating new instances of a Scanner when you already have one open then yeah, that's probably not a great idea. The scenario you describe, where you need to have other methods reading from Standard input sounds like more of a design issue than anything else, you should consider if it's possible to do all your reading at once and then store in an intermediate data structure. If you do need to do a lot of reading in sequence it might be cleaner to keep that as the main purpose of a single method with calls to other methods that don't need to do I/O, since it's generally better to minimise the amount of functions that perform I/O. Of course all of this might be useless, I'd have to see the code to know for sure.

In terms of closing input/output streams, semantically this means performing whatever operations are needed to cleanly stop using the stream. So for example, closing an output stream over a file will flush the buffer (so that queued writes will definitely happen), then call the necessary OS level functions to release the lock on the file so that other processes can use it. When you close System.in or System.out, the specifics of what happens depend on the OS but the end result is that those streams are marked as closed for the rest of the life of the process and cannot be reopened. There is no reason to do this as these streams are merely an abstraction over whatever input/output the OS has connected to the process and so aren't a resource that you need to worry about closing correctly. There's no harm in placing a close when you are certain the program is done using the stream but there's also no benefit. One possible exception to this rule is that if you are writing to System.out, you may need to manually flush() the stream before you exit the application. I believe System.out is line buffered by default so newline char writes should flush it but if you are using print() or some function that doesn't insert a newline char you may end up terminating before those characters are written. This doesn't apply to a Scanner of course since you are not writing in that case.

Eclipse warnings are just that, warnings that something might be wrong and while they are usually right they can sometimes have false positives, like this scenario, or maybe a situtation where you are intentionally casting in a way that you know is safe but the compiler doesn't. I recommend that you omit the close, and add an annotation to let eclipse know that it should suppress the warning about closing streams in this particular case.

If you add
Code:
 @SuppressWarnings("resource")
to the top of the method it will not warn about this particular issue in that method only. Sometimes these annotations are useful if you know that it's a false positive (which it is in this case)
 

oxrock

Gravity is a myth, the Earth SUCKS!
I don't really have a specific goal. I'm stuck in a dead end major at a useless college so I'm trying to create another job path for myself. I don't know what kinds of jobs are out there for the most part. Game design would be a dream, obviously, but I don't know if it's really safe to make that my goal, so I'm not specifically working towards that.

Game design is a super mega awesome goal! It's something you can do in your spare time until it takes off, you don't have to go all in with it. Being an indie game dev is the thing to do these days. With that in mind, IF you have a real interest int at least learning it... you have two major avenues to choose from. Unity is a solid choice with c# as the programming language and I also hear the new unreal engine is really sweet. That uses c++. Or you can be a complete nub like me and just screw off in pygame/python but I highly suggest the first two if you have any intention of ever actually releasing any games.
 
Generally: Python or Java, then C

Windows specific or quick GameDev: C#

Linux shenanigans: C

Android: Java

Really doesn't matter as the biggest difference between languages is just syntax.

Have to comment on the bolded. Sure there are syntax differences, but I would say the paradigm is just as significant. All of the examples you listed are object oriented, except C, which is imperative. When choosing a language for a job (or to learn), you should probably consider paradigm before language. Some tasks are easily written in a high level, functional/imperative language like JavaScript, whilst others may benefit from a declarative logic programming language like Prolog.

How I think of it is:

  1. Get a problem
  2. Which paradigm best suits the problem?
  3. Within that paradigm, which language is the most appropriate (libraries, maturity, etc)?
  4. Use that syntax.
 

Roflobear

Member
One possible exception to this rule is that if you are writing to System.out, you may need to manually flush() the stream before you exit the application. I believe System.out is line buffered by default so newline char writes should flush it but if you are using print() or some function that doesn't insert a newline char you may end up terminating before those characters are written.

Thanks for the response! It cleared a whole lot of things up. Also I might not be understanding your point I quoted correctly but if System.out.print("..."); was the last instance of System.out in my program, should I manually flush() it at the end?
 
Gaf Pogrammers: I'm receiving a JSON response from a server. To interpret the response, is there a way to skip the bufferreader part and use the JSONTOKNER directly? Is the way that I'm currently doing it efficient?
Code:
				BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
				StringBuilder builder = new StringBuilder();
				String line; 
				while (null != (line = reader.readLine()))
					builder.append(line);
				reader.close();
				
				JSONTokener tokener = new JSONTokener(builder.toString());
				//JSONTokener tokener = new JSONTokener(new InputStream(response.getEntity().getClass()));
				JSONObject jsonobject = new JSONObject(tokener);
 
I don't really have a specific goal. I'm stuck in a dead end major at a useless college so I'm trying to create another job path for myself. I don't know what kinds of jobs are out there for the most part. Game design would be a dream, obviously, but I don't know if it's really safe to make that my goal, so I'm not specifically working towards that.

The Games industry is awful, I do not suggest anyone pursue it as a career.

Also most designers in the games industry can't program for shit.

If you just want something to improve your career options I suggest web based technologies and scripting languages. Python/JavaScript would be where I would start.
 

GabDX

Banned
I would to try my hand at making video games. I'm mainly interested in the physics and AI. I don't mind if my games have horrible programmer art. I already know some C++ and I would like to stick to that language. Where should I start? Any books or website I should take a look at?
 

emb

Member
I would to try my hand at making video games. I'm mainly interested in the physics and AI. I don't mind if my games have horrible programmer art. I already know some C++ and I would like to stick to that language. Where should I start? Any books or website I should take a look at?
I went through Lazy Foo's SDL tutorials a while back, and they seemed pretty good. It's very introductory though, so of course it won't get you much into physics or AI yet.
 
I would to try my hand at making video games. I'm mainly interested in the physics and AI. I don't mind if my games have horrible programmer art. I already know some C++ and I would like to stick to that language. Where should I start? Any books or website I should take a look at?


that's a very open ended question and the first answer, without being trite, is really "google it". Game programming, particular in c++, covers a lot of areas and what information you need will depend on quite a few factors.

- do you want to write the graphics engine yourself? in which case you'll need to learn openGL or DirectX. For openGL i've used the lighthouse3d GLSL tutorials but they might be a bit advanced for starting. i learnt the basics via googling, and reading the OpenGL Red Book. There's a lot more to this than just putting pixels on a screen also - there's spatial culling, for instance, which means managing data in such a way that you can easily determine what needs to be drawn at all and not calling things that don't fall into view. scene management can get quite complicated, as can the render/update loop design.

- if you don't want to do that you'll have to look at available engines which range in complexity. some of them are "complete" engines that generally provide graphics, physics, audio etc. but don't expose a C++ api, instead using a scripting language like Lua (cryengine) or C# (unity). At the other end you have things like Ogre3D that manage a lot of the graphics stuff but little else and do provide a C++ interface, so you might want to look at that.

- general game programming tips can be found all over the place from game dev forums to stack overflow. one site i like is gameprogrammingpatterns.com which is a general overview of applying object-oriented design principles to game programming. if you have some experience with these (like from the gang of four book "design patterns") this can be a good resource. it's probably a good resource regardless tbh.

books i feel i've gotten good stuff from:

C++ for game programmers - good overview of game programming using C++ and the STL, more generic knowledge than specifics ie doesn't cover graphics/audio etc.
Physics for Game Developers - as the title says, physics and collision for games with examples in c++.
Game Engine Architecture - a great overview of what goes into a game engine, by Jason Gregory (Naughty Dog)

otherwise i'd say start small, you should be able to find tutorials by googling something like "space invaders c++" that should take you through creating a simple game. given you say you know some c++ (how much is some?) i've say look at Ogre or similar (i actually have no experience with it myself, as i've either rolled my own engines in C/C++ or used higher level tools like Unity). You can get started by going to www.ogre3d.org/tikiwiki/tiki-index.php?page=Tutorials

if anyone has any better middle-level suggestions (irrlicht?) please offer as like i say I don't have much experience in that area.

anyway the most important thing is to have fun! and try to finish what you start.. (that's a whole other kettle of fish and my main problem at the moment)


edit: for AI the one book i've used is Artificial Intelligence for Games, Millington/Funge. It's not bad, but I'd probably start with looking for online tutorials as books can get expensive.
 
^^

A few relevant books I've read:

  • Dunn, F., & Parberry, I. (2011). 3D math primer for graphics and game development. CRC Press.
    Great book for me, introduction to 3D graphics. Code examples in C++.​
  • Russell, S., & Norvig, P. (1995). Artificial Intelligence: A modern approach . Prentice-Hall, Egnlewood Cliffs, 25.
    Probably a little too theoretical for a beginner wanting to jump straight into code, but a great book covering a lot of content.​
  • Cormen, T. H., Leiserson, C. E., Rivest, R. L., & Stein, C. (2001). Introduction to algorithms. Cambridge: MIT press.
    You need to brush up on algorithms before you can code AI.​
 
Top Bottom