Game Programming: Part Two - Page 3
Blogs > CecilSunkure |
Vronti
United States111 Posts
| ||
KaiserJohan
Sweden1808 Posts
My question is, how do you actually do the 'artistic' stuff? For example; How do I make textures? How do I make models? Is stuff like this possible for someone who sucks at drawing by hand? lol | ||
BisuDagger
Bisutopia19142 Posts
On March 02 2012 21:58 KaiserJohan wrote: I'm a software developer toying with making a game engine and then a game. My question is, how do you actually do the 'artistic' stuff? For example; How do I make textures? How do I make models? Is stuff like this possible for someone who sucks at drawing by hand? lol Unless you generate your models procedurally through OGL or DirectX then you pretty much need an artist who can makes the models for you. But making textures is your skill in photoshop, not your ability to draw with your hand and making models is your ability to create objects in 3D-max or maya. I am not at all artistic but both or doable by the average person if you take your time to learn the artistic techniques for both of those softwares. I recommend having a friend do it for you. Your only tasks should be to make the game and just use placeholder art to see that functionality works. (ex. just load in basic geometry for now to simulate visual feedback. Then convince a very kind artist that the work on the game is there and you just need the art to make it complete. | ||
PaqMan
United States1475 Posts
| ||
nimdil
Poland3746 Posts
On March 05 2012 01:32 PaqMan wrote: I want to start programming and eventually programming games, but only as a hobby. I saw your recommendation about python and I've been reading one of the books on it, but I ran across something else today. Love2D is a framework to make 2d games in LUA. Do you have any experience with it?? I wanted to know if I should keep learning Python or pick up Love and try that out. If you are new to programming in general, stick to one language and learn it. The most important thing is to learn one language well enough to make it relatively easier learn others. Switching languages at the beginning won't help. For the start - especially if you are going to learn on your own - you should start with one of the more popular languages so in general one of the: C, C++, Obj-C, C#, VB.NET, Python, PHP, Perl, Java That said not all are equally games-friendly. Generally speaking the more popular language the more tools you will find, the more tutorials are out there, the greater is the community etc. Easier. Also - unless language is created for specific purpose (like PHP and Perl from this list) you will probably discover a wealth of resources which will aid you in coding games. Lua is scripting language so in essence you probably won't be able to code a game in it. You can - however - work on a game based on specific game engine in Lua. For example Spring - http://springrts.com/ - is open source RTS engine. Written in C++ but it is more complicated | ||
CecilSunkure
United States2829 Posts
On March 05 2012 01:32 PaqMan wrote: I want to start programming and eventually programming games, but only as a hobby. I saw your recommendation about python and I've been reading one of the books on it, but I ran across something else today. Love2D is a framework to make 2d games in LUA. Do you have any experience with it?? I wanted to know if I should keep learning Python or pick up Love and try that out. I'd recommend Python and PyGame, as I've used it before and loved it. I have never used Lua, but from what I know it's not commonly used on it's own to create games. | ||
sluggaslamoo
Australia4494 Posts
I would prefer to write in any other dynamic language over Python. Haskell, Ruby, Lisp, Smalltalk, Lua, Javascript, any. Okay maybe not PHP but you get the picture. Though I see Coffeescript (using V8 Javascript engine) as the best language for making games in this day and age. V8 Javascript is very very VERY fast compared to other dynamic languages, and Coffeescript is like Ruby syntax with Python-style context sensitive whitespace and Javascript's beautiful functional paradigm at the core. Just seems like a language with a lot of potential. http://coffeescript.org/ On March 05 2012 07:04 CecilSunkure wrote: I'd recommend Python and PyGame, as I've used it before and loved it. I have never used Lua, but from what I know it's not commonly used on it's own to create games. Lua is a great language, I don't see anything wrong with it for hobby game making. Its is widely used for non-performance-intensive stuff, and not for core engines because 1. C++ libraries already exist for it and 2. its slow compared to C++. If you are not coding Mass Effect 3, then Lua is definitely a viable option. On March 01 2012 23:47 nimdil wrote: I sort of agree. Flash is already outdated and death is waiting for it. HTML5/JS is basically removing it from the market. Steadily. Python is excellent language and there are many examples of software written in C/C++ that can be extended with Python so it's worth to take a look. As for C and C++. I disagree that there is no disadvantage in learning C++ first instead of C. For the following reasons: 1. C++ is fast. C is faster! At least that's how Visual Studio makes the end code - not sure about gcc/g++ 2. If you learn C++ you won't learn C specific approach to programming. Namely you will focus on creating/removing objects instead of allocating/freeing memory. That's actually significant difference in terms of performance. Also you won't be that used to using pointers. C background may very well let you implement algorithms more efficiently. 3. If you start with C++ you will probably never revert to pure C - in some way you will never know C. The other way around is not true - however - as surely (especially in programming games) you will want to start using OOP - so C++. 4. Finally - C is easier. There is less stuff to learn. If you want to learn some architecture specific stuff (like parallel programming) you should go with C. Once you are proficient with C you can expand with C++ - this way you can always fall back on C experience. You don't use a lot of the OOP features of C++ for games unfortunately because of performance, every nanosecond counts, and that includes micro optimisations. Really you are writing uglified C in C++, purely for speed reasons. I love C, but I really don't like C++ heh. | ||
nimdil
Poland3746 Posts
On March 05 2012 08:54 sluggaslamoo wrote: I've been on the big programming thread and met quite a few python fanboys here and there but I don't know what everyone's fascination with python is, most if not all people who love python have also not been very knowledgeable programmers in my experience. Most python fanboys don't even know how the GC works, which I believe at least understanding the cyclic referencing problem is important (although no longer a problem apparently). I mean its alright but I just see Python as pretty weak with nothing really special about it, it barely even classifies as a multi-paradigm language these days. I would prefer to write in any other dynamic language over Python. Haskell, Ruby, Lisp, Smalltalk, Lua, Javascript, any. Okay maybe not PHP but you get the picture. Though I see Coffeescript (using V8 Javascript engine) as the best language for making games in this day and age. V8 Javascript is very very VERY fast compared to other dynamic languages, and Coffeescript is like Ruby syntax with Python-style context sensitive whitespace and Javascript's beautiful functional paradigm at the core. Just seems like a language with a lot of potential. http://coffeescript.org/ Lua is a great language, I don't see anything wrong with it for hobby game making. Its is widely used for non-performance-intensive stuff, and not for core engines because 1. C++ libraries already exist for it and 2. its slow compared to C++. If you are not coding Mass Effect 3, then Lua is definitely a viable option. You don't use a lot of the OOP features of C++ for games unfortunately because of performance, every nanosecond counts, and that includes micro optimisations. Really you are writing uglified C in C++, purely for speed reasons. I love C, but I really don't like C++ heh. What kind of games are we talking about? I can't imagine anyone coding game like Hom&m without some OOP. And if you don't use OOP why bother with C++ - ISO C seems to be a lot clearer and more efficient. | ||
ShadowWolf
United States197 Posts
On March 05 2012 19:01 nimdil wrote: What kind of games are we talking about? I can't imagine anyone coding game like Hom&m without some OOP. And if you don't use OOP why bother with C++ - ISO C seems to be a lot clearer and more efficient. C unquestionably becomes a lot harder to read as compared to other languages as the complexity of the application increases and the efficiency increase is not necessarily always even there. The whole reason C++ was invented has to do with improving maintainability while representing a business problem with a higher degree of accuracy. In general, outside of specific circumstances that should be obvious, C and C++ are basically around the same performance level. On a Desktop PC you're not exactly dealing with a situation where a template class or something is appreciably killing your machine. I mean, compare the Quake 2/3 (written in C) source to the ID Tech 4 (written in C++) source code. | ||
sluggaslamoo
Australia4494 Posts
On March 05 2012 19:01 nimdil wrote: What kind of games are we talking about? I can't imagine anyone coding game like Hom&m without some OOP. And if you don't use OOP why bother with C++ - ISO C seems to be a lot clearer and more efficient. If OOP was necessary in game development then people would have done it with C as well using ADTs (abstract data types). Typecasting for Polymorphism and passing a pointer and lookup every time you wanna call a method on an object, you are not going to use Iterators and ArrayLists (or any design patterns) for instance because they are slow to build and you would be creating one 60 times a second when you could just save all that time and memory by iterating through an array. Objects also just take up a lot more memory than primitive types. So you are mostly going to stick with primitive data-types and data-structures, writing code in terms of functions and data, aka structured programming. I'm not a huge performance nerd so I don't know the exact details. This is also only for core components though like AI, animation and graphics, it is more common to have less CPU intensive stuff to be written in OO or even in scripting languages like Lua. You can look at the api (blizzard calls it a language -_-) Galaxy, where you have the ability to script triggers using code in the SC2 Map Editor, there's no OO in there at all, the api calls have a very C-like naming convention. There may be some games that will be a bit more OO than others, but the bigger and older the game is the less OO it is because optimisations are more important than maintainability. Remember games usually run on a single release cycle, so maintainability is much less of an issue compared to having a wider customer base because the CPU specs can be lower. Balance patches never involve code, the only time it does is for a bug fix. C++ is just used because it is the de facto standard for making games, why? I have no idea, probably because C++ came out at just the right time, when game companies were agile enough to shift to new languages and most code was done in-house. But now we are stuck in a vicious cycle, because all the good game libraries are now in C++, people keep developing more game libraries in C++, and almost nobody makes their own large scale game engines anymore. Now the fastest compilers are for C++ too so nobody is going to go back to a pure C compiler, because you can just write C using the C++ compiler. On March 06 2012 08:44 ShadowWolf wrote: Most game engines are written in C++ with some of the more performance critical parts written in ASM or C as is required. E.g. Source, Unreal Engine, Unity, etc. There are very few engines still written entirely in C and more engines are farming off the less critical pieces to C# and other more RAD oriented languages (LUA and Python also very popular I hear - not sure on that one). C unquestionably becomes a lot harder to read as compared to other languages as the complexity of the application increases and the efficiency increase is not necessarily always even there. The whole reason C++ was invented has to do with improving maintainability while representing a business problem with a higher degree of accuracy. In general, outside of specific circumstances that should be obvious, C and C++ are basically around the same performance level. On a Desktop PC you're not exactly dealing with a situation where a template class or something is appreciably killing your machine. I mean, compare the Quake 2/3 (written in C) source to the ID Tech 4 (written in C++) source code. I haven't looked at the code, but I would presume that the code is much better mostly because ID just had better developers. It is much harder to work on old C++ than C code in my experience because of how badly designed the language is, its just so inconsistent and if you get one bad programmer you are pretty much screwed. | ||
ShadowWolf
United States197 Posts
C++ became the de-facto standard in many places because it's easier to make sense of than C code. I'm not sure your source of experience, so I'm not going to comment about your specific situation; however, in general it stands that C++ code is more maintainable and more accurately represents in a clear-cut manner the problem being solved as compared to straight-C. That said, there are several modern, maintained compilers that support C99 and some even already adding support for C11. C was used in games for quite a long while after C++ was standardized. The reason I suggested you to compare is because the Quake2/3 source code is messy and repetitive whereas the ID Tech 4 source code uses OO concepts to eliminate and specialize classes - you should see some of their internal helper's migration to use of templates and what-not. The point was it's a decent example of how migration helped clean up their code. It's not like it's a pinnacle of quality - there are classes with over 100 members in there, but it definitely does the job at a level that most games cannot. Also, if you look at basically any commercial game's source you'll see design patterns all over the place. Dynamic Arrays (you used ArrayList, I think you meant this?) are commonplace anymore with specialized allocators for the objects that require them. A lot of times you'll see re-implmenetations of STL library stuff because the STL can be a little too heavy-weight for many types of games (or you need more granular control). The major reason that all the APIs might look C-like in Galaxy is because C-style functional syntax is arguably easier to create. I know if I were creating a scripting engine then emulation of either C or Javascript is where I would start just cuz it's simple, bare-bones, and the few commercial lexers I've seen come with support out of the box. But I'm not familiar with Blizzard's development on Galaxy so I'm guessing here. The point I'm trying to make is that C++ isn't a panacea but it's not a pox either. C and C++ both suffer from many of the same pitfalls, but I (and many others) feel that the increased type-safety, objects, and generic programming concepts improve the design of your code and help express your concepts in a more robust, maintainable, and functional way. And, really, that's what it's all about because even in a single-release game cycle you better believe at least some components of your code are going to be re-used - especially as models like F2P and whatever you call "social media" style games like the ones you see on Facebook become more profitable. Or even just consider franchises like Call of Duty and whatever - those games aren't made from scratch every time. Going back to my own example: There's holdovers from ID Tech 3 in ID Tech 4. That said, some really interesting insight on the topic can be gleaned here: http://www.team5150.com/~andrew/carmack/ Though I don't think he ever did write his .plan on migrating from C to C++. | ||
sluggaslamoo
Australia4494 Posts
On March 06 2012 13:21 ShadowWolf wrote: C++ is a powerful tool and like all powerful tools it has the potential to let yourself walk in to huge pitfalls - incidentally C and C++ share common ground here. I personally believe that C++ makes it a lot harder to shoot yourself in the foot as long as you're familiar with how a language that isn't pure works - i.e. careful use of overloads, RAII for life, sensible design patterns, thought about the direction of your systems. Admittedly, a the worst examples of C++ are far more obtuse than the worst examples of C, but that's because there's nearly no limit to how many coding patterns you can combine together at any point in C++. I mean, you can (to some extent) see this if you follow a lot of C# code - between LINQ and some of the new stuff plus the DLR you can do some pretty nonsensical stuff. But I mean, I don't think there's anywhere near sufficient evidence to say that the language is designed poorly. There are features of the language that are designed poorly, e.g. Exceptions; however, I don't feel that's sufficient that you can paint a broad brush. C++ became the de-facto standard in many places because it's easier to make sense of than C code. I'm not sure your source of experience, so I'm not going to comment about your specific situation; however, in general it stands that C++ code is more maintainable and more accurately represents in a clear-cut manner the problem being solved as compared to straight-C. That said, there are several modern, maintained compilers that support C99 and some even already adding support for C11. C was used in games for quite a long while after C++ was standardized. The reason I suggested you to compare is because the Quake2/3 source code is messy and repetitive whereas the ID Tech 4 source code uses OO concepts to eliminate and specialize classes - you should see some of their internal helper's migration to use of templates and what-not. The point was it's a decent example of how migration helped clean up their code. It's not like it's a pinnacle of quality - there are classes with over 100 members in there, but it definitely does the job at a level that most games cannot. Also, if you look at basically any commercial game's source you'll see design patterns all over the place. Dynamic Arrays (you used ArrayList, I think you meant this?) are commonplace anymore with specialized allocators for the objects that require them. A lot of times you'll see re-implmenetations of STL library stuff because the STL can be a little too heavy-weight for many types of games (or you need more granular control). The major reason that all the APIs might look C-like in Galaxy is because C-style functional syntax is arguably easier to create. I know if I were creating a scripting engine then emulation of either C or Javascript is where I would start just cuz it's simple, bare-bones, and the few commercial lexers I've seen come with support out of the box. But I'm not familiar with Blizzard's development on Galaxy so I'm guessing here. The point I'm trying to make is that C++ isn't a panacea but it's not a pox either. C and C++ both suffer from many of the same pitfalls, but I (and many others) feel that the increased type-safety, objects, and generic programming concepts improve the design of your code and help express your concepts in a more robust, maintainable, and functional way. And, really, that's what it's all about because even in a single-release game cycle you better believe at least some components of your code are going to be re-used - especially as models like F2P and whatever you call "social media" style games like the ones you see on Facebook become more profitable. Or even just consider franchises like Call of Duty and whatever - those games aren't made from scratch every time. Going back to my own example: There's holdovers from ID Tech 3 in ID Tech 4. That said, some really interesting insight on the topic can be gleaned here: http://www.team5150.com/~andrew/carmack/ Though I don't think he ever did write his .plan on migrating from C to C++. In terms of background, I'm not a game developer but I have acquaintances who work at a very high level in games development, EA games, Eidos, etc. Ironically speaking to these people and hearing stories completely halted my passion for wanting to become a games developer, and now I'm reserved to spending a lot more time in computer sciency stuff and hobby games development. I get paid a lot more and get to work in an easy going environment. I will reserve my judgement on the source code until I see it, but I really can't believe someone would use a List and pass through them using an iterator in a high-spec game heh , however if it was going to run on low specs anyway then I can see people going for more maintainability. I'm really talking about games in the top tier. Although A lot of times you'll see re-implmenetations of STL library stuff because the STL can be a little too heavy-weight for many types of games (or you need more granular control). I can definitely believe this at least for "lower tier" games. The major reason that all the APIs might look C-like in Galaxy is because C-style functional syntax is arguably easier to create. I know if I were creating a scripting engine then emulation of either C or Javascript is where I would start just cuz it's simple, bare-bones, and the few commercial lexers I've seen come with support out of the box. But I'm not familiar with Blizzard's development on Galaxy so I'm guessing here. I thought you might say that. Not all APIs are C-like like Galaxy. A lot of them are often sorted into classes as globally accessible class methods using very basic OO, like SFML (obviously not a real game engine but just to give you an example). To me Galaxy almost appears to be a direct port of the basic AI triggers, but then again its only an assumption and that's as far as it goes. Javascript also runs on a functional paradigm so that is certainly not how I would do it in JS, its just that there is a lot of bad Javascripters out there . Admittedly, a the worst examples of C++ are far more obtuse than the worst examples of C, but that's because there's nearly no limit to how many coding patterns you can combine together at any point in C++. I mean, you can (to some extent) see this if you follow a lot of C# code - between LINQ and some of the new stuff plus the DLR you can do some pretty nonsensical stuff. But I mean, I don't think there's anywhere near sufficient evidence to say that the language is designed poorly. There are features of the language that are designed poorly, e.g. Exceptions; however, I don't feel that's sufficient that you can paint a broad brush. If you have become proficient in tonnes of different languages and paradigms and even like to create your own grammars from time to time its just so easy to say C++ really sucks and not think twice about it, even worse is that a lot of people of my type agree with me which means I never end up coming up with any great reasons for why haha. There are definitely poorly designed languages and well designed ones. There's no arguing about this. There are certain conventions in creating languages which should be thought of. Things such as POLS (principle of least surprise), facilitating the developer in his use of the language paradigm, the ability to be DRY (don't repeat yourself), conciseness, readability, etc. This is just off the top of my head. C++ fails in many of these aspects, find new things about C++ 5 years down the track, some things require braces, some things don't, an interface method requires an abstract class method that is assigned a value of 0, etc. PHP is also a "bad" language in my books, such as arrays actually being hashes causing all kinds of weird shit, the loosest typing known to man, etc. My favorite language is Ruby, and the reason is that it follows many of these principles and implements them extremely well. It is fully object-oriented (even nil [NULL] is an object), I can just take glances at blocks of codes and immediately understand what it does, it solves cyclic inheritance with mixins, it has open classes which allows for really elegant library implementations, duck-typing, there are hardly any keywords instead they are methods on Object (foreach X in Y becomes Y.each |X| {yield x to the iterator block}), you can pass blocks of codes as an argument and yield objects to them, dynamic typing but alleviates the type-safety issues with strict typing instead of the more common loose typing. It has a great amount of flexibility, but unlike C++, its still hard to write bad ruby code. Its a very great implementation of a language of the OO paradigm, of course you can also do a lot of functional stuff too, but not Haskell tier functional. Carmack will always be a hero in my books, but he wasn't known for being the most academic programmer. I really enjoyed his rants about the earliest DX's vs OpenGL. | ||
ShadowWolf
United States197 Posts
I think you misunderstood my point about Galaxy. Functions that look and feel like C functions are just plain easier to write. Arguments are more simple, there's no real complex data structures that need to be passing, and you're probably going to be able to augment the language more easily. I didn't mean to suggest that they used C or even C-interfaces. Just that using things that look similar to C is extremely common in my experience. SMFL is a library and doesn't seem to be relevant to proprietary external scripting interfaces and why they might look very C/JS-ish. That said, a couple of google searches confirmed Galaxy is 100% based on C style syntax. Eh, I mean, Ruby is a cool language. It also has limitations. It's probably a superior entry-level language to C++. It's also unquestionably slower, less flexible, and possibly has fewer core-language enhancements in its future. From what I've learned of Ruby, it's probably one of the better languages (up there with Python) in terms of getting stuff done well in not a lot of time with decent quality. That said, I'm not sure what you mean by your complaints about C++. I mean, I have a million gripes about the language of C++, but some of that stuff you listed off is naught more than personal preference and doesn't make a strong argument for why C++ is awful, just why C++ is worse than Ruby in some specific areas. And that's fine - I mean, the fundamental concept of application development and improving hardware is that we can abstract ourselves from low-level concepts like what C++ requires that you focus on. But that's neither here nor there. The exception I had to what you posted was that C++ produces generally inefficient code when put side-by-side with C and is harder to maintain than C. I'm interested in demonstrating that neither of those, again emphasizing the "in general" part even in a game - you'll probably have some straight-C code around very select portions of your engine for a while longer, is true. There's a sort of weird C > C++ perspective that I don't quite understand and it seems to be based on things that haven't really been true for a while. Also side-note: if you're developing on MSVC then that's the equivalent of saying "I know car engines really well because I work on a '94 civic." Yeah, it's definitely still a Car (C89/90) and you'll probably pick up the necessary bits to figure out an '09 Civic (C11), but it's so old and dated that you're missing a lot of cool stuff. | ||
sluggaslamoo
Australia4494 Posts
On March 06 2012 15:32 ShadowWolf wrote: I don't know why you can't believe a list wouldn't be the proper choice. I'm not sure what you're imagining, but a vector that's sized out is quite efficient and access to items on the vector are quite reasonably fast. I think you're imagining a lot of complexity to exist that doesn't actually exist. The list is a perfect choice and optimizing it to be effectively just as fast is trivial in the gaming domain. The impression I get from your writing is the last complete exposure you had to C++ was circa Visual C++ 6.0, which, if true, totally justifies your views. If that's the case then they are dated and should be updated. If that's not the case then you seem to have a lot of misguided impressions about how inefficient C++ really can be, which totally makes sense because most people don't re-check their assumptions - especially if you're talking to game developers. I know and have discussed with a few of them myself and a lot of times they do the things they do because they know they work, they have worked in the past, and they (basically) always will work. It's a completely sensible viewpoint, but in terms of discussing with people just learning you'd probably want them to learn the new skill set in additional to familiarizing themselves with the old one so they have a more marketable set of skills. I think you misunderstood my point about Galaxy. Functions that look and feel like C functions are just plain easier to write. Arguments are more simple, there's no real complex data structures that need to be passing, and you're probably going to be able to augment the language more easily. I didn't mean to suggest that they used C or even C-interfaces. Just that using things that look similar to C is extremely common in my experience. SMFL is a library and doesn't seem to be relevant to proprietary external scripting interfaces and why they might look very C/JS-ish. That said, a couple of google searches confirmed Galaxy is 100% based on C style syntax. Eh, I mean, Ruby is a cool language. It also has limitations. It's probably a superior entry-level language to C++. It's also unquestionably slower, less flexible, and possibly has fewer core-language enhancements in its future. From what I've learned of Ruby, it's probably one of the better languages (up there with Python) in terms of getting stuff done well in not a lot of time with decent quality. That said, I'm not sure what you mean by your complaints about C++. I mean, I have a million gripes about the language of C++, but some of that stuff you listed off is naught more than personal preference and doesn't make a strong argument for why C++ is awful, just why C++ is worse than Ruby in some specific areas. And that's fine - I mean, the fundamental concept of application development and improving hardware is that we can abstract ourselves from low-level concepts like what C++ requires that you focus on. But that's neither here nor there. The exception I had to what you posted was that C++ produces generally inefficient code when put side-by-side with C and is harder to maintain than C. I'm interested in demonstrating that neither of those, again emphasizing the "in general" part even in a game - you'll probably have some straight-C code around very select portions of your engine for a while longer, is true. There's a sort of weird C > C++ perspective that I don't quite understand and it seems to be based on things that haven't really been true for a while. Also side-note: if you're developing on MSVC then that's the equivalent of saying "I know car engines really well because I work on a '94 civic." Yeah, it's definitely still a Car (C89/90) and you'll probably pick up the necessary bits to figure out an '09 Civic (C11), but it's so old and dated that you're missing a lot of cool stuff. Hey, not trying to be an ass or anything, and I've probably mis-interpreted a couple of your points too, but yeah I'm gonna avoid addressing a few paragraphs because I believe you mis-interpretted what I was saying, but lets leave it at that. I dunno why you lump C and JS together, C is based on the structured programming paradigm, JS is based on an imperative functional programming paradigm o_O. The only reason JS would look anything like C is if the programmer isn't well versed in functional programming. For example if you are doing Server side stuff, you might write using Concurrency Driven design, such as what you'd see in NodeJS. You would have a lot of trouble doing something like this in C. I don't do a lot of C++ because I don't like it very much, so feel free to enlighten me on any cool features that I might be missing out on. Very recently I was re-learning C++ using the plain old g++ because I selected some comp-sci electives (I chose to do business and IT in University instead of comp-sci). That said I didn't attend any lectures or tutes and just did the required lab tests and exams, I just flicked through the slides and if I saw anything I didn't know I did some learning on it in the library and watching recordings of the lecturer slide show presentations. Your right on point that before I did that, I was using MSVC++ 6.0. I probably wouldn't dare touch that with a 10-foot pole now, although I do everything in Linux so I'd be using GNU now if anything. The reasons listed weren't that great as I said, If I actually had a think about it I'd probably come up with better reasons. The main thing is unlike the differences between Ruby and C++, I don't believe C++ has that many advantages over C when it comes to pure programming. I don't feel like there are many things I could do better in C++ than in C. You can still do OOP in C using ADTs and you will have much more organised C code than bad OOP in C++. Even bad OO in Ruby still looks good and won't cause many issues. Like I implied in my first post though, developing C++ on your own isn't that bad, its having to rely on other developers to be immaculate. Issues like cyclic inheritance (or the diamond problem) are a very real possibility. The other problem being that it has good intentions, but multiple substitution is very poorly designed in C++ and can cause a lot of problems. Java saw this as a really big problem but solved it in the stupidest way possible with multiple interface inheritance, because it completely eliminates one of the core advantages of OOP which is code re-use. And then people come out with idiotic books on Java about how to "write code in interfaces instead of implementations". Interfaces are useful, but they are a terrible substitute for implementation inheritance. Most other languages do this much better, e.g Scala with traits, or Ruby with mixins. However there is also a "skill ceiling" that you hit with older languages, where you get frustrated because certain implementations would be soooo much better in another language, I don't get this feeling between C++ and C, one big difference between older imperative languages and new dynamic languages is the usage pf higher order functions. I still think there are certain principles which make for good and bad languages. Consider quicksort in C, C++ and Haskell. (Mind you I tried to find the shortest variations of each one) C
C++
Haskell qsortOneLine s = case s of{[]->[];(x:xs)->qsortOneLine [y | y<-xs, y<x] ++ x : qsortOneLine [y | y<-xs, y>=x]} Now imagine if every time you wrote something in functional declarative instead of imperative, how small your code base would be in comparison and how easy it would be to maintain because a lot of your processes will be stateless. Notice how C++ isn't actually that much better than C, but Haskell can be extremely concise. In Ruby I'm doing stuff like this all the time, although in a lot less cryptic manner. With your points on Ruby, its definitely slower (although Mac Ruby will be a lot faster), but this is a non-issue as I'm not making a high-spec game. Which is why I mentioned Coffeescript (Javascript) with Google's V8 engine as a great contender for games programming. Its not as fast as C++ but it is pretty damn fast from what I've seen and is a great language. I dunno what you mean by flexibility, limitations, and fewer core language enhancements. Ruby 1.9 is significantly improved over 1.8 in terms of performance, syntactic sugar for a lot more things, and just a lot more features over all. As for limitations do you mean low level stuff? Although unnecessary for the most part, I can write inline Java or C in Ruby. When I'm coding games I will import a lot of Java libraries (e.g JOGL) and do my implementation in JRuby. I can have a fast 3d game in OpenGL that is completely cross-platform and runs on a JVM written in almost pure Ruby. Can''t get more flexible than that. As for performance, I'm not saying that C++ is slower than C. But conceptually abstractions have to be slower than primitive types. A lot of these are micro-optimisations that I wouldn't deem important at all and only slightly important if you are writing a top-level game. I guess the game programmers believe that if its simple enough to make that optimisation, that they are going to do it anyway. I'm sure for most they would rather maintain their sanity and at least keep their code maintainable. http://assoc.tumblr.com/post/411601680/performance-of-stl-vector-vs-plain-c-arrays | ||
alexpnd
Canada1857 Posts
| ||
opsayo
591 Posts
| ||
CecilSunkure
United States2829 Posts
On March 07 2012 19:06 opsayo wrote: Cecil do you recommend anything for python besides pyGame? I love python but pygame looks pretty ghetto (installing it for a 64-bit Mac OS is not elegant). Haha I don't know what you mean "looks ghetto". You just include it into your project, and then coding it from there looks like usual 'ol Python. And sorry nope, I don't have experience with other things to recommend. | ||
sluggaslamoo
Australia4494 Posts
On March 07 2012 19:06 opsayo wrote: Cecil do you recommend anything for python besides pyGame? I love python but pygame looks pretty ghetto (installing it for a 64-bit Mac OS is not elegant). Most unix platforms come default with Python so I don't really understand this post. You can always write your own game-engine though, you'll learn a lot from it | ||
ShadowWolf
United States197 Posts
I work in kind of a C++/C#/Java primarily shop with quite a fair amount of legacy C/ASM code. I've been working here for going on 7 years now and have worked on several code bases whose inception occurred in the early 1990s - in fact, we have header files whose copyright information is dated 1990 :-D. I feel like I've seen a gambit in terms of high quality and low quality C and C++ code since I've had to maintain and enhance quite a few projects. Incidentally, bad code is bad code and I feel like I've been too busy trying to "defend" (if you will) C++ against C and not really focusing on the fact that bad code is more or less unsalvagable regardless. To the point: we actually had a C# class so complex, so poorly written, and so buggy that I had to work an entire weekend just to rewrite the whole thing. And C# generally keeps you from screwin' stuff up! :-\ At work, we have some legacy VB6 code that someone spent 2 weeks attempting to migrate before entirely giving up and the project being canned. But, anyway, to address your points: I don't believe your analysis of the C and C++ code was entirely fair or accurate. The primary reason why I feel that is that the C++ is reusable while the C code is not. Anything that supports iterators or std::begin/end can be passed as parameters to that sorting algorithm and it will be successfully sorted. This is extremely powerful and so much better than the C algorithm! I mean, I think you would agree with me based on your perspective and enjoyment of Ruby. Granted, the Ruby code is more compact, tells the story, and is just as useful, but I have conceded that point already. But in the end, no - if you do C with ADTs you'll have far, far more code than a decent implementation of C++ and you'll have the added disadvantage of now using C with ADTs combined with the fact that you're now limited in how you can pass things around - C with ADTs tends to fall down unless you basically pass everything by void*, which means you cannot enforce a lot of the nice behaviors and you certainly will not get any modern C++ design patterns such as RAII. As an example, look at this sample code implementing a container in C using an ADT: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4550&lngWId=3 I did a fairly poor reinterpretation of that for C++ here. You'll have to excuse passing everything by-val instead of by const-reference; I had some time to do this at work waiting for something and kinda got in a rush at the end. http://pastebin.com/VNHhg8Ht Keep in mind I did it with slightly fewer lines of code (I checked removing the C code's comments fwiw), it's actually typesafe (the C version is 100% not typesafe!), and it works with various types. E.g. the following code compiles against it fine: + Show Spoiler + std::vector<int> sample(5, 5); int arraySample[] = {1,2,3,4,5,6}; SampleContainer<int> list; list.Add(5); list.Add(7); list.AddRange(sample.begin(), sample.end()); list.AddRange(std::begin(arraySample), std::end(arraySample)); list.Remove(5); list.Remove(128); std::for_each(list.GetData(), list.GetData() + list.GetSize(), [](int& i){std::cout << i << std::endl;}); const char* strings[] = {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"}; SampleContainer<std::string> listOfString; listOfString.AddRange(std::begin(strings), std::end(strings)); std::for_each(std::begin(listOfString), std::end(listOfString), [](std::string& s){std::cout << s << std::endl;}); You've used some terminology that's not clear to me. What do you mean by "pure programming"? And also, what do you mean by "multiple substitution"? These are terms that are foreign to me, so I'm afraid to comment further on those. I don't want to talk past you, but I'm not finding anything you've mentioned to back up that it's somehow worse to work with C++ on a sizable team and my experience has been that it's absolutely not. Coffeescript is an interesting language - I was reading about it a few days ago and it's something I've thought was a nice new way of approaching some problems. Otherwise, I take back my statements about Ruby. I know I wanted to touch on a point there but I can't, for the life of me, remember what it was or how it was relevant so I think I was just posting nonsense. Ruby definitely has come a long way, though looking at the Ruby2C stuff I'm not entirely sure it's gonna get you the performance you're desiring without a lot of extra leg-work, but it's a step and something interesting that definitely adds some as-needed flexibility. I'm not sure it gets anywhere near the level of low-level functionality I'd want in a situation like that, but I think it's probably good enough. The final point: Abstractions only have penalties for the times you pay for them. For example, virtual method invocations only affect those objects that actually have a v-table and not every object is required to have one. That's where C++ is really nice: you only pay the price for features you actually use. So while a std::vector has an abstraction layer around it, the standards writers usually make the elements involved as pass-through as possible so the penalties you pay are quite minimal. So yes, absolutely abstractions have costs, but, generally speaking, these abstractions are often highly optimized for the library writers (and even some subtypes; e.g. several containers are optimized to the point of being basically straight Win32 CRT calls in the VC2010 STL implementation). In the case of that study, I don't see how a stack-allocated array of integers is in any way comparable to a repeated heap-allocated array of integers. I'd be interested to see which compiler he uses and whether new'ing the array of integers has any affect. That said, there again is why C++ can be better than C at times: if you need the performance of a C-style array then you have it and it's actually 100% compatible with the STL using std::begin and std::end (and there are absolutely times when a C-array is the better choice for solving a problem)! Also, the guy is wrong in one of his premises: std::vector is guaranteed to be contiguous memory. It was, as the result of an oversight, missed in C++98, though, so that's probably why he had the misconception that it was not guaranteed. (http://herbsutter.com/2008/04/07/cringe-not-vectors-are-guaranteed-to-be-contiguous/) Perhaps you could provide a sample of the really unmaintainable C++ code you're thinking of when you write that and it might help me understand your point of view better than discussing in abstracts? | ||
e-Goh
New Zealand18 Posts
I'd pretty much agree with you. For those starting out, it doesn't matter what language you pick, be it C, C++, C#, Java, Python or whatever. You can write, object-oriented C, or non-object-oriented C++. It's up to the programmer how he executes his algorithms. Much like how exact build orders don't matter all that much to bronze leaguers, if the code is bad enough, the nuances of language architecture don't matter. However, that being said, it's pretty obvious you're not a beginner, but are nevertheless looking for something more to chew on. Game programming, as opposed to application programming, largely focuses on how much performance you can eke out, oftentimes at the cost of convenience for the programmer or elegance of the code. The way modern computer architecture has been progressing, the main bottlenecks we generally face are not the speed in executing algorithms (cpus are quite fast), but memory accesses and management. If you are writing for the PC, it doesn't really matter because gamers have humungous amounts of memory and caches the size of whales. It only becomes more of a concern when dealing with consoles, or mobile devices where the hardware is much more limited. The reason why game developers are not the biggest fan of STL is because it does a huge amount of alloc/deallocs on the heap during runtime. I've seen a single std::string initialization make 20 small allocations at once! This causes memory to fragment and results in less memory being available. Imagine memory pockmarked with 16kB holes while trying to allocate 4MB. All that memory in the holes aren't available because they aren't big enough to accomodate the new allocation. We much prefer pre-allocated fixed-size memory pools/containers when possible. Lately, there's also been a movement against inheritance in general. The strength of C++ has always been that it naturally causes data that gets used together (i.e. in an object) be located close together in memory. However, when working repetitive operations on a set of many objects (e.g. updating the x, y, z position of all game objects), it thrashes the cache with all the superfluous data. Instead of one memory fetch retrieving 16 sets of useful coordinates, it now only retrieves one, simply because of the way memory is arranged. The name of this new movement is dubbed data-oriented programming (as opposed to object-oriented though they are not mutually exclusive), and is by and large championed by a fellow called Mike Acton. Google him to find out more, but just be warned he can be a wee bit overzealous. It just so happens that straight C lends itself more to this style of programming, though there's no compelling reason why it can't be accomplished in C++ as well. It is a non-intuitive approach though, which can be unsettling for a generation of programmers brought up on pure OOP, myself included. I hope that gave you some food for thought. Programming is like a never-ending learning adventure! | ||
| ||