{"id":477,"date":"2014-12-02T15:52:46","date_gmt":"2014-12-02T15:52:46","guid":{"rendered":"http:\/\/www.tech-g.com\/?p=477"},"modified":"2014-12-02T15:52:46","modified_gmt":"2014-12-02T15:52:46","slug":"should-i-learn-c-before-c","status":"publish","type":"post","link":"https:\/\/www.voodoo.business\/blog\/2014\/12\/02\/should-i-learn-c-before-c\/","title":{"rendered":"Should i learn C before C++"},"content":{"rendered":"<p>While trying to answer a friend&#8217;s question who just messaged me on facebook today about this very matter, i wanted to see if anyone has any idea i missed on this matter, visiting this thread on stack overflow i found the classic debate, here is my take on that classic debate that i stood by for many years (and I&#8217;m usually not a stubborn person) <\/p>\n<p>So here is the state of affairs.<\/p>\n<p>1- Camp 1: learn C first, it will help you when you learn C++ and you will be a better C++ programmer<\/p>\n<p>2- Camp 2: You carry too many methods that are bad practices in C++<\/p>\n<p>Well, here is the thing, the course of action i recommend is the following, I also explain exactly why so that if it does not apply to you, you can infer your own judgment<\/p>\n<p>The way I think of it is in terms of how much time learning will take and what you end up with<\/p>\n<p>Even though C is certainly not a prerequisite to C++, and with practice, Someone who started with C++ can be as efficient a C++ programmer as one who started with C, the truth of the matter is that C is ALMOST a subset of C++, there are few minor differences that make some C code not valid for a C++ compiler, but they can be summed up in a page or so.<\/p>\n<p>So let&#8217;s get started composing the logic on whether you should learn C before C++ or not.<\/p>\n<p>Objective 1: C will never be of any use to me, i have an assignment in C++ and that is all i care about, getting that assignment over and done with, in this case i recommend starting with C++.<br \/>\nObjective 2: I want to learn C++ so that i can make software.<\/p>\n<p>Assuming you have objective #2<\/p>\n<p>So, C is a small language, learning it from a good book can be around a 230 page read (I recommend Kernighan- Ritchie. The C programming language), once you finish with C, you can train on the basic concepts that you will need plenty in C++, the building blocks inside objects\/classes of C++ are technically written in C.<\/p>\n<p>At this stage (stage 1 of 2) Once you know C, C is under your belt, this is a great language for embedded devices, for example a router has a few kilobytes left for you after linux is installed on it&#8217;s 4MB of memory, you can&#8217;t fit the C++ library in there, C is the tool you need here (with much smaller libraries), a C++ developer will not wrap his head easily around what subset of C++ he\/she is allowed to use, but if you know C, you are already productive after the first 230 pages, you can start doing serious things at this stage.<\/p>\n<p>Then, the upgrade to C++, from a time perspective is a simple one, one thing to take care about is to always remember that you need to focus on Object oriented, when i made the switch to C++ many years ago, i paid plenty of attention to the concept of OO, and in no time, i found myself using it professionally when writing in C++, and not using it at all when writing in C, so the case of sloppy programming in C++ for those coming from C is not a big deal, nor has to apply to you, with very little effort you can get over your C habits, you just need to stay aware that you want to use OO.<\/p>\n<p>From my deep understanding of both languages, 90% of what you learn in C is also part of what you will have to learn in C++, so you will not be wasting any time, reading a C++ book when you come from C is much much faster, so my recommendation is that you learn C first. this route will give you the most bang for your time.<\/p>\n<p>I even recommend living in C for a year or so before you make that magical jump to C++. most of Linux&#8217;s important software packages are for example written in C not C++, so having good command of C first can be very beneficial.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While trying to answer a friend&#8217;s question who just messaged me on facebook today about this very matter, i wanted to see if anyone has any idea i missed on this matter, visiting this thread on stack overflow i found the classic debate, here is my take on that classic debate that i stood by [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-477","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/477","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/comments?post=477"}],"version-history":[{"count":1,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/477\/revisions"}],"predecessor-version":[{"id":478,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/477\/revisions\/478"}],"wp:attachment":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/media?parent=477"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/categories?post=477"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/tags?post=477"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}