Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Coming from ASM, C, then C++, and finally landing (forced) into the Java territory, I thought I may provide an opinion about the subject. </p> <p>First, with all due respect to the Java community, the business experience shows that while C/C++ programmers can get used to the Java principles and programming (it may not be that easy), the opposite happens more rarely. In other terms, a C++ programmer will have to learn and cope with tons of Java rules (Frameworks...) but she will eventually (and usually) be able to produce a <em>long term working</em> code by injecting a lot of her <em>system</em> experience into the process. A Java programmer going to C, used to more theoretical principles, and strict structure rules may</p> <ul> <li>feel insecure as she has to decide many things, like program organization and structure</li> <li>feel surprised with the pointers, and memory management: allocation and freeing, which has to be thought carefully - discovering the world of memory leaks</li> <li>feel discouraged, as the bugs won't appear black on white in a console dictated by the JVM through 200 lines of stack trace, but may happen at a deeper / system level, maybe caught thanks to an IDE in front of which the Java programmer will contemplate some assembly code for the 1st time in her life</li> <li>feel perplex as to what algorithm and how to implement it, the one that was integrated into Java that she never had to worry about...</li> </ul> <p>So, now, my task is to help you to feel secure, confident, and motivated before learning C/C++!</p> <p>My advice is to start with C, because</p> <ul> <li>C by itself owns all the very concepts you never had to face with Java</li> <li>as a Java programmer you already have a classes 'approach', and starting with C++, you may be tempted to stick to the Java OO principles</li> <li>C principles are limited to a few. C looks like the very last human thing before entering the dark world of assembly language.</li> </ul> <p>What I would emphasize during the C study is, for instance</p> <ul> <li><p><strong>Pointers</strong> Java uses pointers of course, but hides its access while actually passing classes to methods as pointers. In C, you will have to learn the difference between by <code>value</code> and by <code>reference</code>. Also, the more subtle difference between <code>char x[3]</code> and <code>char *x = "ab"</code>. And how convenient pointers are to go through an array etc..., you know <code>*++x</code> or <code>*x++</code>. A lot has been said about pointers, my advice would be</p> <ol> <li>always keep control, i.e. don't put too many indirections when not necessary</li> <li>don't <code>typedef</code> pointers, like <code>typedef int *pointerToInt</code> ; it seems easier at first (<code>pointerToInt pi</code> instead of <code>int *pi</code>) after a few levels, I prefer to count the stars than the 'pointerTo' [some big cies do that]. Except maybe the pointers to functions, unreadable anyway.</li> </ol></li> <li><p><strong>Memory</strong> When you need memory, you allocate it, and when you don't need it anymore, you free it. Easy. The thing is to allocate the right amount, and not to free it twice... Have to get used to that. And get used to the heap, the stack... And When your program runs and address NULL (0) you may have a visible exception. Maybe not.</p></li> <li><p><strong>Data structure</strong> So you want to use a convenient HashMap? Sure, after you developed it. Or there are some libraries you can link that do that kind of thing, just chose the right one. To be fair, when programming in C, you [have to] think different, and may find a more appropriate algorithm than a map for a given problem.</p></li> </ul> <p>All in all, you will feel disoriented at first, but eventually (unless you have nightmares) you will find before you a lot of room for fun and pleasure. C allows a person to program with complete freedom: C goes according to your ideas, not the opposite.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload