Get the latest Education e-news
 

Go Back   Game Career Guide Forums > Programming
Forum Home Register Members List Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 08-23-2008, 06:32 PM   #11
radertj
Junior Member

Activity Longevity
0/20 17/20
Today Posts
0/11 sssssss12
Default

I fail to see how leaking memory and overusing objects isn't bad programming practice. It's sad that the C++ programmers you see a lot write such poor code. How far along are they into their education?

Saying that something isn't a programming practice isn't really an honest approach to the issue. Even if it isn't a practice, it's still pitfall than using low level functionality of the language with poorly named variables. By isolating problems to languages, you are also assuming you aren't ever going to touch a low level language. If you think you are going to write all applications in Java, I hope you don't plan to get a job working on a AAA title as anything other than a tools programmer (unless you want to work on Shadowbane). I don't think it's possible to be a good programmer and only know one language.

Typically, Microsoft Visual C++ is the industry standard in regards to IDE's being used in the industry today. With a solid understanding of the language, cross platform code isn't that hard to write, but it definitely takes a little longer. But honestly, what beginner programmer is going to be writing cross-platform code consistently?

As far as that code snippet goes, I think it wouldn't need a comment if the variable names depicted what they are being used for. The programmers at High Moon Studios claim they didn't need comments, because of constant scrum meetings, smart variable naming, and hourly integrations. The Bourne game turned out pretty well, so they are doing something right .

To be fair, you also have to remember that people can write code in java with poorly named variables and objects without comments just the same. This problem is not confined to low level languages.

I'm coming from a C background, so I may be biased. Either way, any programming at all is a good way to start. I find that starting with the harder guy will make you appreciate what managed languages can do, and eliminate the stress of having the training wheels taken off.
__________________
Thomas Rader
radertj is offline   Reply With Quote
Old 08-23-2008, 06:38 PM   #12
Gshonk
Moderator

Activity Longevity
0/20 20/20
Today Posts
0/11 ssssss831
Location: Philadelphia, PA
Default

Gotos merrr. They make me sick.
__________________
Grant Shonkwiler()
"I would love to fix the world if someone would just give me the source code"
Website Industry blog LinkedIn
Gshonk is offline   Reply With Quote
Old 08-23-2008, 07:10 PM   #13
yaustar
Administrator
 
yaustar's Avatar

Activity Longevity
2/20 19/20
Today Posts
0/11 sssss2272
Location: UK
Default

If programmers that have being using C++ for 5+ years still got caught out by some obtuse behaviour of the language, then it is definitely something that beginners should avoid. Even Scott Meyers admits to stumbling when peer reviewing Exceptional C++.

The problem with C++ is that it assumes the programmer knows exactly what they are doing all the time. E.g
Code:
int main()
{
  int blah[4];
  int foo;
  for( int i = 1; i <= 4; ++i)
  {
    blah[i] = 0;
  }
}
This code on most platforms will run without crashing and a beginner will be none the wiser that the code is actually flawed. Higher level languages such as Java and Python will give a runtime error. They are designed to make it harder to run 'wrong' code in which makes them great for beginners.

Back when I was using VC 6, it drove me nuts when I found odd quirks that wasn't the same as the GCC based MinGW compiler. This included being able to use -> or . irrespectively whether the variable was a pointer or not and the for loop variable scoping to be wrong:

Code:
for( int i = 0; i < 10; ++i )
{
  // stuff
}

for( int i = 0; i < 10; ++i ) // Compiler error, redefinition of i
{
}
In regards to memory management, it is just another area to learned regardless of the language. Resource/Memory management is apparent in most language, for example, in Java knowing how the garbage collector works allows the developer to write better and more efficient code based on their understanding of bottlenecks and performance of the collector.

More and more games are using higher level languages for the bulk or all of game development. Python, Java, Lua, C# just to name a few.

Quote:
I find that starting with the harder guy will make you appreciate what managed languages can do, and eliminate the stress of having the training wheels taken off.
By that reasoning, everyone should be starting in ASM instead of C or C++ then.

Last edited by yaustar : 08-23-2008 at 07:19 PM.
yaustar is offline   Reply With Quote
Old 08-23-2008, 07:20 PM   #14
Adrir
Administrator
 
Adrir's Avatar

Activity Longevity
1/20 20/20
Today Posts
0/11 sssss1467
Location: London, UK
Default

Quote:
Originally Posted by radertj View Post
I fail to see how leaking memory and overusing objects isn't bad programming practice. It's sad that the C++ programmers you see a lot write such poor code. How far along are they into their education?

...

Saying that something isn't a programming practice isn't really an honest approach to the issue.
I agree that programmers transitioning from a managed to an unmanaged language will hit these pitfalls but this isn't the result of being taught bad practice. I'm just saying that Java doesn't teach you bad practice, you just get into the habit of relying on the garbage collector and working in a fully object-orientated environment.

To suggest to a beginner that it is not a good idea to learn Java because you learn poor practice is in my opinion, utterly rediculous.

Quote:
Originally Posted by radertj View Post
By isolating problems to languages, you are also assuming you aren't ever going to touch a low level language.
No, I believe that beginners can learn how to program without need to wrestle the features of certain language.

Quote:
Originally Posted by radertj View Post
If you think you are going to write all applications in Java, I hope you don't plan to get a job working on a AAA title as anything other than a tools programmer. I don't think it's possible to be a good programmer and only know one language.
It is common knowledge that C++ is the de-facto language in the Industry. However, in my opinion it is easier as a beginner to learn something like Java or Python and then transition to C++.

Quote:
Originally Posted by radertj View Post
As far as that code snippet goes, I think it wouldn't need a comment if the variable names depicted what they are being used for. The programmers at High Moon Studios claim they didn't need comments, because of constant scrum meetings, smart variable naming, and hourly integrations.
I disagree, but everyone is entitled to their opinions.

If true, the feat at High Moon Studios is a triumph of communication rather than programming style. However, as soon as you recruit a new guy on the team or someone goes off on long-term illness, I think they'd have hit major problems.

Quote:
Originally Posted by radertj View Post
To be fair, you also have to remember that people can write code in java with poorly named variables and objects without comments just the same. This problem is not confined to low level languages.
Yes that's true, but that wasn't the point I was really getting at with that example.

Quote:
Originally Posted by radertj View Post
I'm coming from a C background, so I may be biased. Either way, any programming at all is a good way to start. I find that starting with the harder guy will make you appreciate what managed languages can do, and eliminate the stress of having the training wheels taken off.
Yes - any programming at all is a good way to start, although coming from a background in programming micro controllers, I found that wrestling with things like registers and memorising function numbers was a waste of time. It didn't teach me how to get better at thinking about or solving problems which is the meat and bones of programming.

I would rather make learning the language as easy as possible, and focus on getting a strong understanding of the fundamentals as well as problem solving. Once you've got these skills, you can easily apply them to any language including C++.

Quote:
Originally Posted by yaustar
By that reasoning, everyone should be starting in ASM instead of C or C++ then.
Ironically, that's how I discovered programming for the first time. Good old Design & Technology.
__________________
Michael 'Adrir' Scott :: Games, Virtual Worlds, Education
Networking | Current Project | Research | Teaching

Last edited by Adrir : 08-23-2008 at 07:24 PM.
Adrir is offline   Reply With Quote
Old 08-23-2008, 07:38 PM   #15
yaustar
Administrator
 
yaustar's Avatar

Activity Longevity
2/20 19/20
Today Posts
0/11 sssss2272
Location: UK
Default

Personally, I find the idea of not writing comments in a large team environment silly. Having to work out what a section of code was supposed to do when the game crashes in it wastes valuable time which could have been avoided by writing a high level two line comment for that code block.
yaustar is offline   Reply With Quote
Old 08-23-2008, 09:43 PM   #16
TG1
Super Moderator
 
TG1's Avatar

Activity Longevity
0/20 18/20
Today Posts
0/11 ssssss271
Location: New York
Default

Quote:
Originally Posted by yaustar View Post
Personally, I find the idea of not writing comments in a large team environment silly. Having to work out what a section of code was supposed to do when the game crashes in it wastes valuable time which could have been avoided by writing a high level two line comment for that code block.

Agreed, I think it's so much easier reading and understadning 2 lines of comment then starting to track down a variable across the code block no matter how good its name is, although a good program has both good comments and good varaiable names.

To come into Java's defense, although you can't play around with the computer's guts like you can in C/C++ I've seen some crazy code written in it, as an example (also an example of consequences of poorly documented code) - we have a module that a prgrammer wrote a few years ago that I think uses every design pattern inveneted in order to make it as generic as possible. although this is really cool, nobody today understands what it does and we can't really fix the bugs in there, so currently this entire module is being rewritten.
Also in my current position (where I have alot of optimization and scalability tasks) I have the pleasure of hanging around thread dumps and garbage collector logs alot...

As for Java being a good language for beginners, although it is much easier then C++ or C, when it's being used by people who are unfamilar with OO concepts, they usually try to bend it into a procedural mold (by, for example, creating one giant class with all the methods in it) which can cause bad programming habits.

The biggest advantage of Java (IMO) is that it lets you concentrate on the logical problem and algorithm at hand, rather then spending time on memory allocations and compiler behavior (although, as I mentined earlier, you do sometimes find yourself changing variable types and code logic in order to improve performance)
__________________
Tamar G
My web site
Linkedin profile
Facebook profile

Last edited by TG1 : 08-23-2008 at 09:46 PM.
TG1 is offline   Reply With Quote
Old 08-23-2008, 09:51 PM   #17
Marco Roy
Senior Member

Activity Longevity
0/20 17/20
Today Posts
0/11 ssssss156
Location: Montreal, Canada
Default

Quote:
Originally Posted by radertj View Post
As far as that code snippet goes, I think it wouldn't need a comment if the variable names depicted what they are being used for. The programmers at High Moon Studios claim they didn't need comments, because of constant scrum meetings, smart variable naming, and hourly integrations. The Bourne game turned out pretty well, so they are doing something right .
I guess they forgot to hire a software engineer...

Quote:
Originally Posted by Adrir View Post
To suggest to a beginner that it is not a good idea to learn Java because you learn poor practice is in my opinion, utterly ridiculous.
Totally; in fact, Java helps programmers learn good practices. When I first started Java, I hated the fact that I had to instantiate multiple objects to do something as simple a reading and writing a file (which can be done with one or two objects in C++). After my programming maturity level increased substantially, I discovered that the ways Java had me take were actually the good ways to go, and that the C++ code I used to write was full of bad practices. And that is one example amongst many.
__________________
Aspiring game designer and software engineering student at École de technologie supérieure (ETS)
CONJUREIGDA ProfileLinkedIn ProfileFacebook PageMy Website
Marco Roy is offline   Reply With Quote
Old 08-23-2008, 10:03 PM   #18
Gshonk
Moderator

Activity Longevity
0/20 20/20
Today Posts
0/11 ssssss831
Location: Philadelphia, PA
Default

Comments are a must, even if you write good clean code and have good variable names, you must at least comment to let me know what is going to happen so I don't have to read every line of code to figure it out. Try working in legacy code at a company that has been around for 30 years where there have been almost 100 programmers it sucks if they don't comment right.
__________________
Grant Shonkwiler()
"I would love to fix the world if someone would just give me the source code"
Website Industry blog LinkedIn
Gshonk is offline   Reply With Quote
Old 08-24-2008, 10:23 AM   #19
yaustar
Administrator
 
yaustar's Avatar

Activity Longevity
2/20 19/20
Today Posts
0/11 sssss2272
Location: UK
Default

Heh. GameDev has a new topic on comments.

The one bit I agree with is that the comments should show the 'why' and the code, the 'how'.
yaustar is offline   Reply With Quote
Old 08-24-2008, 02:38 PM   #20
radertj
Junior Member

Activity Longevity
0/20 17/20
Today Posts
0/11 sssssss12
Default

The High Moon example is definitely not a typical example. Please don't take that as a "You don't need comments" argument, because that was not my intent. I definitely agree that comments should tell why and not how and should be used to eliminate any ambiguety.

Starting in ASM was a little exaggerated.
__________________
Thomas Rader
radertj is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Powered by vBulletin® Version 3.6.9
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
All times are GMT -8. The time now is 09:58 AM.






UBM Tech