![](sad.gif)
C and/or C++
Ok my college prof says C/C++ have bad memory leaks? I don''t know for sure what he is saying or if it is true? I see something about not using pointers like char *text? Is this only with char types or all types? If so then are we to use strings all the time? I guess I don''t understand the problem that is caused by char *text. Any ideas?
Windows SUCKS! Deal with it!
if(windows crashes)
{
run Linux
}
else
{
yea right!!
}
![](sad.gif)
Rule # 1 ... all professors in the programming field are F***** in the head... ( other wise wouldnt they rather be making 5X more money NOT teaching code ? ) They are failures... ( not all granted but most are.)
Rule # 2 ... ANY language can be abused if you abuse the language...
With that said memory leaks are ALWAYS caused by the programmer... after all the computer is just doing what you had it set out to do, did''t you?
With char * text = "HAHA C++ I love my doggie?"; You just allocated strlen(test); number of bytes... whether you knew it or not... .. Therefore IF in your program you do char * ALL OVER THEPLACE 100000000 times... you will eventually run outta memory... This applys to ALL types... after all a type can only EXIST in the computers memory... right? Where do u think they are stored? On the top of your monitor? HAHA
Read up on memory allocation bro and always remember this... Your professor is OLD, OUT_DATED, SLOW, OLD did i memntion OLD FOGGY? hehe he doesnt know SHIT... just learn what you can and dont take to heavelly ANY advise they give
-=spacemadness
Rule # 2 ... ANY language can be abused if you abuse the language...
With that said memory leaks are ALWAYS caused by the programmer... after all the computer is just doing what you had it set out to do, did''t you?
With char * text = "HAHA C++ I love my doggie?"; You just allocated strlen(test); number of bytes... whether you knew it or not... .. Therefore IF in your program you do char * ALL OVER THEPLACE 100000000 times... you will eventually run outta memory... This applys to ALL types... after all a type can only EXIST in the computers memory... right? Where do u think they are stored? On the top of your monitor? HAHA
Read up on memory allocation bro and always remember this... Your professor is OLD, OUT_DATED, SLOW, OLD did i memntion OLD FOGGY? hehe he doesnt know SHIT... just learn what you can and dont take to heavelly ANY advise they give
-=spacemadness
March 10, 2001 10:07 PM
yes C and C++ do allow you do create memory leaks. It is something that you have to keep in mind. More modern languages do not have the problem, but modern languages will often have another problem or two. So you''re going to have to deal with tradeoffs no matter what language you use. If possible try to learn multiple languages simultaneously, that way you won''t get locked into any particular way of thinking.
The difference between a C/C++ memory leak & VB/Java memory leak, is that you can fix the C/C++ leak yourself.
Your prof forgot the qualifer, "If you''re dumb or careless, ..."
Magmai Kai Holmlor
- The disgruntled & disillusioned
Your prof forgot the qualifer, "If you''re dumb or careless, ..."
Magmai Kai Holmlor
- The disgruntled & disillusioned
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
I agree, the only memory leaks in a C/C++ program are those you cause on your own, through carelessness or stupidity. Always assume your teacher is an idiot, and you''ll be right more than half of the time
.
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
![Resist Windows XP''s Invasive Production Activation Technology!](http://www.crosswinds.net/~druidgames/resist.jpg)
http://www.gdarchive.net/druidgames/
![](wink.gif)
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
![Resist Windows XP''s Invasive Production Activation Technology!](http://www.crosswinds.net/~druidgames/resist.jpg)
http://www.gdarchive.net/druidgames/
OK, if you go through college thinking all professors are stupid, you will not do well. Teachers & professors get my utmost respect, if only for having to deal with students who think their teachers are stupid.
Second, if your professor is comparing Java with C++, then he was probably talking about automatic garbage collection. Java uses reference counting and garbage collection for everything, so you can have no leaks. C/C++, as a language, do not implement this, so it''s possible to get leaks when using it.
On the other side of things, you have no control over how Java does its memory management; automatic reference-based garbage collection can cause performance problems. With C/C++, the entire memory management scheme is up to the designer.
In this respect, the difference between Java and C++ is like the difference between an automatic and a manual shift car. Sure, if you use an automatic then it''s easy to brake going up hill and you never have to worry about stalling or blowing the clutch. But how many race car drivers use automatics?
Professionally, Java is mostly used in web-based applications or database applications (where there is a web interface). If you want to do anything more than that, I suggest you learn C++ on your own time. I just went through a long process of looking for new programmers for two positions--we didn''t extend any offers to people who listed Java as their main language. It''s not that we were prejudiced; they just didn''t have the skills we needed.
Second, if your professor is comparing Java with C++, then he was probably talking about automatic garbage collection. Java uses reference counting and garbage collection for everything, so you can have no leaks. C/C++, as a language, do not implement this, so it''s possible to get leaks when using it.
On the other side of things, you have no control over how Java does its memory management; automatic reference-based garbage collection can cause performance problems. With C/C++, the entire memory management scheme is up to the designer.
In this respect, the difference between Java and C++ is like the difference between an automatic and a manual shift car. Sure, if you use an automatic then it''s easy to brake going up hill and you never have to worry about stalling or blowing the clutch. But how many race car drivers use automatics?
Professionally, Java is mostly used in web-based applications or database applications (where there is a web interface). If you want to do anything more than that, I suggest you learn C++ on your own time. I just went through a long process of looking for new programmers for two positions--we didn''t extend any offers to people who listed Java as their main language. It''s not that we were prejudiced; they just didn''t have the skills we needed.
Ok, I don''t want to say anything bad about anybody coz people have their own ideas, beleifs and talents. So maybe your professor is very talented in something.
C/C++ has memory leaks, very correct but who makes c/c++ programs. Java has memory leaks too, but then who makes java programs ? Human beings right. So errors(memory leaks) to will be happen coz of programs by humans only, the compiler isn''t at fault here. God did not give us c/c++ so I guess its up to us(human beings) to either code correctly or if we find a mistake in the code to correct it.
C/C++ has memory leaks, very correct but who makes c/c++ programs. Java has memory leaks too, but then who makes java programs ? Human beings right. So errors(memory leaks) to will be happen coz of programs by humans only, the compiler isn''t at fault here. God did not give us c/c++ so I guess its up to us(human beings) to either code correctly or if we find a mistake in the code to correct it.
Hello from my world
Correct me if I''m wrong (which I may very well be), but aren''t memory leaks only caused in C++ when you allocate memory on the heap? And not on the stack? In other words, the only way that a memory leak can occur is if you allocate it by using the new keyword, the STL allocator class, malloc, or whatever else there is out there, and if you lose the pointer or forget to do a delete (or STL unallocate, etc). And the stack basically takes care of itself, right? So you basically have to program incorrectly to cause a memory leak, right? Like the only way for a memory leak to happen is if you, the programmer, allocate some memory, and you are just lazy and "forget" to deallocate. That''s how I understand it, you basically have to be lazy and not really care about your work to allow memory leaks. But maybe it''s more complicated than my understanding of it. If so, disregard my immature ignorance
![](smile.gif)
Well there''s two problems I''ve run into with instructors. They have bias like we do, and sometimes they''re underqualified.
My profs seemed to like the stuff they''re familar with or stuff that''s easier to use. They liked pascal better C, and Java better than C++, and Delphi better than MSVC. They weren''t interested in the same aspects of programming that I was, and liked different tools, and so that''s what they taught.
I had one instructor that was seriously underqualified. He couldn''t code his way out of an infinite loop, he barely knew how to write code and he was teaching the intro to programming class.
The university''s CS department was fairly new (~5years old), and they were having problems staffing the classes.
It isn''t always the teacher problem that a class moves slowly - their job is to teach every student in the classroom, not just you. And sometimes you get a ''special'' class.
Magmai Kai Holmlor
- The disgruntled & disillusioned
My profs seemed to like the stuff they''re familar with or stuff that''s easier to use. They liked pascal better C, and Java better than C++, and Delphi better than MSVC. They weren''t interested in the same aspects of programming that I was, and liked different tools, and so that''s what they taught.
I had one instructor that was seriously underqualified. He couldn''t code his way out of an infinite loop, he barely knew how to write code and he was teaching the intro to programming class.
The university''s CS department was fairly new (~5years old), and they were having problems staffing the classes.
It isn''t always the teacher problem that a class moves slowly - their job is to teach every student in the classroom, not just you. And sometimes you get a ''special'' class.
Magmai Kai Holmlor
- The disgruntled & disillusioned
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
I agree with the racecar analogy, it is put much better than I could have explained it
. The other thing you have to worry about, is what if the people who wrote Java left memory leaks in the VM (they wrote it in C/C++, go figure)?
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
![Resist Windows XP's Invasive Production Activation Technology!](http://www.crosswinds.net/~druidgames/resist.jpg)
http://www.gdarchive.net/druidgames/
Edited by - Null and Void on March 11, 2001 3:00:56 AM
![](wink.gif)
![](tongue.gif)
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
![Resist Windows XP's Invasive Production Activation Technology!](http://www.crosswinds.net/~druidgames/resist.jpg)
http://www.gdarchive.net/druidgames/
Edited by - Null and Void on March 11, 2001 3:00:56 AM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement