Hacking C programing

  • Thread starter Thread starter sightlight
  • Start date Start date
  • Views Views 11,060
  • Replies Replies 96
  • Likes Likes 1
Sounds like a good way to weed out people who aren't cut out for game design early in the course.

Unsurprisingly, there's usually a 50% drop-out rate during first year. Far too many people always go into the course thinking it'll be easy cause all they'll be doing is "designing characters and levels, while playing other games".

On a side note, our year was a disaster because we were the pilot year. Started us off with GameMaker in first year, which was great and all. But then they decided it would be a great idea to teach us DirectX 10 without knowing any C++ whatsoever. So it did take the college a few years to come up with a good teaching path. :)
 
I took a Game Dev C++ in college and not in a single moment were memory management and pointers discussed. Its completely possible for a beginner to jump into the language without wading into the low-level aspects of the language.

That's the beauty and strength of C++, the high/low level versatility of the language and its enormous catalog of mature libraries.

You probably used pointers and just didn't know it. Most probably, the libraries you used did all the memory management part for you. But it's very likely that you had to deal with pointers, even without knowing they were pointers.

About people saying there's no advantage in learning C++ without pointers, quite frankly, didn't you heard that C/C++ is faster than most high level languages, especially C# and Java which run in a virtual machine? Also, C#/Java are well known for wasting RAM unnecesseraly making the software slower for system with lack of RAM
 
About people saying there's no advantage in learning C++ without pointers, quite frankly, didn't you heard that C/C++ is faster than most high level languages, especially C# and Java which run in a virtual machine? Also, C#/Java are well known for wasting RAM unnecesseraly making the software slower for system with lack of RAM

If you have no idea how to use pointers and other efficient techniques in C++, there's simply no way your program will be faster than the Java/C# alternative which does JIT compilation, dynamic optimisations during runtime and forces you to use pointers when coding. Sure they might need that little bit of extra RAM to run their virtual machines, but that does not make software slower at all.

It's a complete myth that Java/C# are significantly slower than C++. They used to be, but they haven't been for years. We even have PSP emulators made with Java now (eg. http://jpcsp.org/index.php?p=About). Sure with the correct optimisations, the odds are that you can beat Java/C# performance, but that's not something that's easy to do for the average coder, and most of the time is unnecessary. Even if there was a significant delay, the amount of time to learn and develop applications is significantly smaller in Java. You can pump out high-performance applications far more easily when using Java/C# than you can with C++.

That's why C++ is more suitable for game developers who need to extract as much power as possible from the hardware they're working on. Not for beginners who don't even know what "int" means.
 
Anything that runs via a virtual machine is factually slower than a native binary counterpart of the same code, it goes without saying.

Wrapping your head around Pointers is not as difficult as some people think - we use house addresses in everyday life with relative ease, why shouldn't we be able to do the exact same thing with addresses in memory? It's really not rocket science.

As far as useful examples and reference guides are concerned, I can wholeheartedly recommend cplusplus.com - if what you're looking for refers to the standard C or C++ library package, you'll find it there and it always comes with an example.
 
Sure they might need that HUGE LOAD of extra RAM to run their virtual machines, but that does not make software slower at all.
Fixed, I found quite incredible how Android apps which are based in Java consumes so much RAM. My smartphone's have 80% of its 300mb of RAM consumed, even when I don't have any app running besides the ones that execute in the phone's boot. And this is because Android uses Dalvik which is a VM optimezed for handhelds.

It's a complete myth that Java/C# are significantly slower than C++. They used to be, but they haven't been for years. We even have PSP emulators made with Java now (eg. http://jpcsp.org/index.php?p=About).

Well, I would say that the Java PSP emulator is highly optimized to have a good performance. It's a great work, but only proves that highly optimized Java programs can be fast for real-life purposes. Of course, there's no difference in performance between making a calculator in C++ or Java, but for complex software C++ clearly wins.

Even if there was a significant delay, the amount of time to learn and develop applications is significantly smaller in Java. You can pump out high-performance applications far more easily when using Java/C# than you can with C++.

That's why C++ is more suitable for game developers who need to extract as much power as possible from the hardware they're working on. Not for beginners who don't even know what "int" means.

I have to disagree. Quite frankly, Java and C++ are almost identical in terms of syntax and code. And both Java and C++ use 'int' for that matter. Sure in C++ there is some small details in using characters and strings, but it's nothing hard to learn and actually gives you a lot of freedom later when you have to implement string based functions.

Not only that, but since Java takes off the control you have in C++, you have to memorize a whole lot of function names, when in C++ many times you only have to write a 2-line code using familiar tools. In Java you need to search for a function everytime you need to do something fancy that the Java creators didn't intend you to do.

Java is only easier to learn when start studying how to make graphical UI or how to make data structure stuff. But this is not basic programming knowledge anymore and at this point both the C++ and Java student already have a fair amount of programming knwoledge.
 
Fixed, I found quite incredible how Android apps which are based in Java consumes so much RAM. My smartphone's have 80% of its 300mb of RAM consumed, even when I don't have any app running besides the ones that execute in the phone's boot. And this is because Android uses Dalvik which is a VM optimezed for handhelds.



Well, I would say that the Java PSP emulator is highly optimized to have a good performance. It's a great work, but only proves that highly optimized Java programs can be fast for real-life purposes. Of course, there's no difference in performance between making a calculator in C++ or Java, but for complex software C++ clearly wins.



I have to disagree. Quite frankly, Java and C++ are almost identical in terms of syntax and code. And both Java and C++ use 'int' for that matter. Sure in C++ there is some small details in using characters and strings, but it's nothing hard to learn and actually gives you a lot of freedom later when you have to implement string based functions.

Not only that, but since Java takes off the control you have in C++, you have to memorize a whole lot of function names, when in C++ many times you only have to write a 2-line code using familiar tools. In Java you need to search for a function everytime you need to do something fancy that the Java creators didn't intend you to do.

Java is only easier to learn when start studying how to make graphical UI or how to make data structure stuff. But this is not basic programming knowledge anymore and at this point both the C++ and Java student already have a fair amount of programming knwoledge.

Operating systems will always take up a fair amount of RAM to use. I wouldn't blame Java for that at all. Besides, the core point here is that RAM usage rarely affects the speed of an application. We have plenty of RAM these days, so using RAM usage as a reason to learn C++ is silly for beginner programmers.

And again, nobody is arguing that C++ is inferior or anything. We know that complex software in C++ is going to win once you use pointers effectively, your own memory management system, and bit of assembly here and there. However, beginners are not going to be writing complex applications for years, and by learning C++ you're just going to confuse them. It's not the syntax so much that matters, but mostly those extra things that are unique to the language that are confusing, as well as the cryptic error messages that love to appear often. Hand-holding is a great thing for a new developer, as it won't cause them to give up in frustration.

I think you missed my point with referencing "int". I'm not saying that "int" or control structures are the reason to not learn C++ or anything like that. I'm saying it's silly to tell a beginner to jump into the deep end when they know absolutely nothing about programming. Jumping into the deep end almost made me give up on programming, and while I don't really want to "toot my own horn", I'm quite a good coder, got a 1.1 degree in college (along with Best Software Engineer) and a massive 90% on my final year project. If I almost gave up trying to understand C++ before I tried Java, imagine someone who might not be as logically minded trying to learn it.

You don't need to memorise anything as a programmer. Most IDEs will provide auto-complete, and there's plenty of documentation for Java anyways. From my own experiences, most functions in C++ have far more cryptic names than functions in Java. It's harder to remember C++ functions than it is to remember Java functions because of that reason. Could you provide an example of something that's not natively available in Java, but is natively available in C++? From my own experiences, you often have to implement basic functionality in C++, while that functionality is already available to you in Java. On a side note, when I was working with Canvas for the first time in JavaScript, I was shocked as to how much functionality was already available to the developer without the use of a library.

See, what you consider basic programming, is not basic programming. To us, yes, it's basic and should be relatively simple to pick up, but that's certainly not the case for the average programmer out there. I remember in one interview I had, I was basically asked how long it would take me to learn a new programming language. I jokingly answered 5 minutes, but I explained my point as to how most languages are similar in syntax and that it's really algorithms that matter. Some people got offended saying it takes months to learn a new language, while other people understood where I was coming from.
 
Operating systems will always take up a fair amount of RAM to use. I wouldn't blame Java for that at all. Besides, the core point here is that RAM usage rarely affects the speed of an application. We have plenty of RAM these days, so using RAM usage as a reason to learn C++ is silly for beginner programmers.
RAM usage affects the speed of an applications once it's lacking. Handheld devices are getting more common each day, sparing RAM is pretty important if you're not a short-sighted PC programmer.

And again, nobody is arguing that C++ is inferior or anything. We know that complex software in C++ is going to win once you use pointers effectively, your own memory management system, and bit of assembly here and there.
This quote only shows you how much you don't know about programming languages. Even if you don't use pointers or your own management memory system, a C++ app will always be as fast or faster than a Java application provided they're running the same implematation of a code.

However, beginners are not going to be writing complex applications for years, and by learning C++ you're just going to confuse them. It's not the syntax so much that matters, but mostly those extra things that are unique to the language that are confusing, as well as the cryptic error messages that love to appear often. Hand-holding is a great thing for a new developer, as it won't cause them to give up in frustration.
I'm not going to say C/C++ is the best language to learn programming, but Java is far from being easy to learn either. If there's a famous language to begin learning how to program it's Pascal. The only real significant difference between Javal and C++ is the usage of pointers, and no ones obliguates you to use them in a C/C++ program. Besides the first language I learned was C and it didn't make me quit or anything. It only made me enjoy programming. :lol:

Sorry if you had a bad experience with C++, but maybe you learned from a bad teacher or with a bad guide?

You don't need to memorise anything as a programmer. Most IDEs will provide auto-complete, and there's plenty of documentation for Java anyways. From my own experiences, most functions in C++ have far more cryptic names than functions in Java. It's harder to remember C++ functions than it is to remember Java functions because of that reason. Could you provide an example of something that's not natively available in Java, but is natively available in C++? From my own experiences, you often have to implement basic functionality in C++, while that functionality is already available to you in Java.

You provide me with examples, since you claim this so passionately! My main point was that Java needs you to use functions for everything, it has way more function to memorize than C++ for the same kind of program. Plus, C++ also have IDEs with auto-complete, but if you don't have a clue about what the name of the function is you're going to have google them every fucking time for both languages.
 
CRL, java byte-code and such are basically human-into-machine specific compilers, those allow most high-level languages to be run optimized.

Java running on a VM (ie: on a windows environment) will be slow like hell, but that doesn't mean it'll be slow if pre-compiled through byte code and run directly onto hardware.

the thing is, what i've been doing, and it's been fruitful to me:

need to get how to map physical addresses, how to write your own "register handlers", memory management, and such, and then you start coding on higher language. Once you get stuff like, ie, HEX, you could do anything. It's not the coding language, but how would you like the machine behave for you. Higher languages will include bloated (sometimes very useful yet!) functions and will waste most resources if not used correctly
 
RAM usage affects the speed of an applications once it's lacking. Handheld devices are getting more common each day, sparing RAM is pretty important if you're not a short-sighted PC programmer.


This quote only shows you how much you don't know about programming languages. Even if you don't use pointers or your own management memory system, a C++ app will always be as fast or faster than a Java application provided they're running the same implematation of a code.


I'm not going to say C/C++ is the best language to learn programming, but Java is far from being easy to learn either. If there's a famous language to begin learning how to program it's Pascal. The only real significant difference between Javal and C++ is the usage of pointers, and no ones obliguates you to use them in a C/C++ program. Besides the first language I learned was C and it didn't make me quit or anything. It only made me enjoy programming. :lol:

Sorry if you had a bad experience with C++, but maybe you learned from a bad teacher or with a bad guide?



You provide me with examples, since you claim this so passionately! My main point was that Java needs you to use functions for everything, it has way more function to memorize than C++ for the same kind of program. Plus, C++ also have IDEs with auto-complete, but if you don't have a clue about what the name of the function is you're going to have google them every fucking time for both languages.

Programming for handheld devices is a different ball-game. Of course RAM is going to be more important if you're trying to develop a complex application that's limited to something like 4MB RAM. Sometimes those limitations are fun to play with. I remember when I knew little about C++ and tried writing some DS homebrew that drew bubbles that grew and collided correctly with each other, but I ran out of memory quickly. Gave me a strong appreciation for efficient memory management, but that concept would have flew over my head if I tried to learn that first before college.

If you don't teach about pointers and memory management in C++, you're going to end up with memory leaks, inefficient code that has to copy objects everywhere, and probably horrendously messy code as well. You're going to be writing far more code to get a simple task done. That's a great thing about Java, you write significantly less bug-free code at a far quicker rate than C++ code. The fact that Java also has all of the garbage collection and security mechanisms against overflows is also very powerful and aid to help the developer. Odds are as well, those mechanisms would probably be far more efficient than what an average developer could write by himself.

That's great that you were able to survive learning C when learning by yourself. Everyone isn't capable of jumping into the deep end of things. Most coders I've met are still terrible, and they still got jobs (somehow). Some people need to start off easy and not have a load of concepts thrown to them at once. If you're going to teach how to code, you should always teach how to write good code. C++ requires you to learn more in a short space of time than Java does. And again, should you get an error, you get meaningful errors that tell you exactly where the problem is, which is one of the best things about Java as well.

Function names are common sense in most languages. If I want to do a string replace in Java, I just go "myString.replace("thisword", "withthisword");". If I want to something similar in say, there isn't even a function for that! I'd have to write my own, and that might take a bit of time to not only come up with an algorithm for it, but to make sure it's just as efficient. And even if there was a function, it'd have weird names like "strpos". I rarely have to Google anything in Java, but for C and C++, constantly searching up documentation as to what they weirdly named functions do.

Besides, functions to do everything is a good thing! It keeps your code clean and makes sure it's not ambiguous, which is why operator overloading isn't supported in Java. Not to mention, when working with a large team, it ensures that other coders aren't doing anything stupid with your code. The likes of getters and setters ensure that you can validate input etc. And as you said, we have the IDE to help auto-complete functions and show a list of them. But remembering functions isn't my argument, it's the fact that they're so oddly named and less intuitive in C/C++.
 
Visually updating stuff while you code is called scripting, you do this most commonly in LUA or Python. There might be a C/C++ script parser out there. Basically Unreal Engine allows for scripting in atleast C#, it's pretty great, but soooo confusing to get started with. There's probably a few other engines which allow of this like CryTek Engine.

Maybe take a look at Unity?
 
If I want to do a string replace in Java, I just go "myString.replace("thisword", "withthisword");". If I want to something similar in say, there isn't even a function for that! ........ And even if there was a function, it'd have weird names like "strpos". I rarely have to Google anything in Java, but for C and C++, constantly searching up documentation as to what they weirdly named functions do.

The function you're looking for is strcpy(thisvariable,"withthisword"); from the string.h default library. Since it's such an old fuction and the Java equivalent have the same sintax, I can only think Java's myString.replace() is just a reimplematation of the strcpy() function. :lol:

It's not skyrocket, since it's about functions you use frequently, so it's not that hard to memorize at all. I still find the good old printf() or even the cout<<string; to be quite easier to remember than the Console.println() for example. Your problem seems to be you're not familiar with C/C++ and thus have some hard time with it. My main problem with Java is when it comes to working with making list, queue and etc... In C++ if you want to make an iteration it's as easy as doing oldpointervalue = nextpointervalue; In java you have to use some obscure functions that changes names depending if you're working with a list, a queue, a binary tree and etc...
 
The function you're looking for is strcpy(thisvariable,"withthisword"); from the string.h default library. Since it's such an old fuction and the Java equivalent have the same sintax, I can only think Java's myString.replace() is just a reimplematation of the strcpy() function. :lol:

It's not skyrocket, since it's about functions you use frequently, so it's not that hard to memorize at all. I still find the good old printf() or even the cout<<string; to be quite easier to remember than the Console.println() for example. Your problem seems to be you're not familiar with C/C++ and thus have some hard time with it. My main problem with Java is when it comes to working with making list, queue and etc... In C++ if you want to make an iteration it's as easy as doing oldpointervalue = nextpointervalue; In java you have to use some obscure functions that changes names depending if you're working with a list, a queue, a binary tree and etc...

strcpy doesn't replace "thisword" "withthisword". It just deep copies one char array to another char array. In most languages, string replace as the name implies, goes through the string and replaces the first instance of the word you supplied in the first parameter, with the word you supplied in the second parameter. For more details, look at the link here: http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/String.html#replace(char, char)

Lists and other collections are far more difficult in C++ than in Java. Simple example, to iterate over a list in C++, you have to use the most bizzare of syntax ever:

Code:
std::list<int>::const_iterator iterator;
for (iterator = intList.begin(); iterator != intList.end(); ++iterator)
{
    std::cout << *iterator;
}

Whereas in Java, if I want to iterate over a list:


Code:
for (String myString : myStringList) {
    System.out.println(myString);
}

I'd find it hard to believe that Java functions change names, considering the majority of them implement the List interface which means they all have the exact same list of functions, with maybe one or two additional functions depending on what type of collection you're working with.
 
strcpy doesn't replace "thisword" "withthisword". It just deep copies one char array to another char array. In most languages, string replace as the name implies, goes through the string and replaces the first instance of the word you supplied in the first parameter, with the word you supplied in the second parameter. For more details, look at the link here: http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/String.html#replace(char, char)

Lists and other collections are far more difficult in C++ than in Java. Simple example, to iterate over a list in C++, you have to use the most bizzare of syntax ever:

Code:
std::list<int>::const_iterator iterator;
for (iterator = intList.begin(); iterator != intList.end(); ++iterator)
{
    std::cout << *iterator;
}

Whereas in Java, if I want to iterate over a list:


Code:
for (String myString : myStringList) {
    System.out.println(myString);
}

I'd find it hard to believe that Java functions change names, considering the majority of them implement the List interface which means they all have the exact same list of functions, with maybe one or two additional functions depending on what type of collection you're working with.

how I learned to interate a list at the university:

Code:
//just for context, declaring your own list structure
 
struct no
{
  int value;
  struct no *next;
}list;
 
list *myList = somepointer; //Setting a variable with its initial value
list *iterator = myList; //This is our iterator

Code:
//The line of code that actually does the iteration
 
 
iterator = iterator->next;
 
how I learned to interate a list at the university:

Code:
//just for context, declaring your own list structure
 
struct no
{
  int value;
  struct no *next;
}list;
 
list *myList = somepointer; //Setting a variable with its initial value
list *iterator = myList; //This is our iterator

Code:
//The line of code that actually does the iteration
 
 
iterator = iterator->next;

It's not a very flexible or intuitive list though. It's not code that you can quickly glance over to fully understand. You also have to understand the pointer talk that's going on there.

So for you the one developer who understands it perfectly, that's great. But when you're wanting help from others, or want to write reliable code, or want your code to be easily understandable by other developers, then the Java approach is far better. Your code is nowhere near reliable or flexible, and it's incredibly messy. I know it's only quick code, but that's precisely my argument. In Java, you can do more complex stuff much more quickly while still maintaining nice readable code with meaningful method names that you can glance over quickly.

Hence for newbies, Java is far better to learn first than C++.
 
Anything that runs via a virtual machine is factually slower than a native binary counterpart of the same code, it goes without saying.
Java's JIT nowadays, (like Dolphin and the faster branch of Desmume, if that says anything for speed compared to normal C++).
 

Site & Scene News

Popular threads in this forum