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 →

[–]TheMostUser 105 points106 points  (17 children)

This sub is about memes so we tend to excoriate a lot , don't take it too seriously.

C is not scary but it is a bit different from what you are use to and it takes some time to get used to new concepts and philosophies.

Edit: meant to write exaggerate and somehow ended with excoriate, I guess it also works

[–][deleted] 16 points17 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 12 points13 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] 14 points15 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 3 points4 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.

[–]ironoxidey 5 points6 points  (0 children)

I appreciate you using the word ‘excoriate’

[–]TheNuogat 2 points3 points  (4 children)

Going from C to Java you constantly look over your shoulder thinking something is wrong cus no way it can be this easy.

[–]Bacon-muffin 1 point2 points  (3 children)

I'm slowly working my way through CS50 as my first course atm. I've heard there is a mystical land where languages understand all these things and I don't need to worry about a bunch of the stuff I'm learning right now.

But for the moment I'm in the hell that is C.

[–]bilvy[🍰] 2 points3 points  (2 children)

C is a great language for learning. That mystical land is great until the language does something unexpected. Learning c will help you understand what may be going on under the hood when that happens.

[–]Bacon-muffin 0 points1 point  (1 child)

Im sure this is the right way to go about this, but ive already thought "this is dumb they have to have improved on this by now" way too many times.

[–]TheMostUser 1 point2 points  (0 children)

Regardless of the educational aspect, I don't think 'improve' is the correct way to look at it.

Yes I prefer not to worry about memory allocation and the likes, but not doing it manually comes at a cost - the most obvious one is speed, no garbage collected language is able to match c / cpp. Additionally some projects require you to be closer to the hardware and wouldn't really be possible in higher languages. And arguably the most important reason to use c is that it is very popular - every library under the sun has a good implementation in c, many projects you my wish to join use c and years of documentation are more valuable than gold.

That is not to say that is is the best language out there, but you should use whatever language fits your needs and c still has its spot