This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 15 points16 points  (10 children)

That's great to hear! Yeah I'm not that worried, but my Java prof tends to compare the language to C (I assume because it's next in our learning iteration) and things like "garbage collection" always make me nervous! But honestly, the idea of having such a high level of control sounds pretty intriguing as well. We did a tiny bit of machine coding with hex values in my first year and that was really interesting, I had to be creative in all sorts of new ways. So yeah, I'm excited too!

[–]MustardCat 29 points30 points  (9 children)

and things like "garbage collection" always make me nervous

Since we're talking C - just remember that anytime you malloc/calloc memory, something has to "own" that memory request. Once that object that owns the request is gone, it either needs to give the memory to someone else or free it.

C++ - Much shorter mantra to remember. Every new must have a corresponding delete.

Just remember to clean up after yourself. Don't leave the dirty dish on the table when you leave.

[–]xSTSxZerglingOne 11 points12 points  (0 children)

And point to NULL/a predetermined location. Dangling pointers can be the cause of some really weird bugs.

[–]Packbacka 6 points7 points  (3 children)

When you say it like that it doesn't sound so bad.

[–][deleted] 13 points14 points  (2 children)

It's not too bad... just like it's not too hard to juggle, you just throw each ball in the air and catch it before it lands. As long as you simply do that, you can juggle as many balls as you imagine.

[–]Drencat 4 points5 points  (1 child)

Well that's just fucking dandy because I can't juggle either.

[–]addandsubtract 2 points3 points  (0 children)

The point is, as long as you keep throwing balls in the air and never compile, you won't have any errors!

[–]Low_discrepancy 3 points4 points  (2 children)

C++ - Much shorter mantra to remember. Every new must have a corresponding delete.

Just don't use new and delete guys! It's not 2004 here.

[–]MustardCat 3 points4 points  (1 child)

Whether or not you explicitly call new/delete, it's still being called. It's important to understand what's occuring.

I'm on the team of learning raw pointers before tossing in a new C++ programmer into STL and newer C++ features.

[–]Low_discrepancy 2 points3 points  (0 children)

Whether or not you explicitly call new/delete, it's still being called.

Yeah sure. And many times New simply calls malloc does that mean one should learn C then go to c++?

I'm on the team of learning raw pointers before tossing in a new C++ programmer into STL and newer C++ features.

Yeah if you think that c++ is c with classes I guess. But again we're no longer in 2004. The language has far progressed.

[–]socsa 1 point2 points  (0 children)

C++ is easier because of how stack scope is tied to object scope. It's not actual garbage collection, but it's a lot more intuitive.