$ CFLAGS="-g -O0" make simple
cc -g -O0 simple.c -o simple
$
This is so handy. I never knew that you could call make without writing a default Makefile. Thanks!A thousand times yes.
If you are going to use C, then at least know what it's doing!
You can run gcc with the -S flag, which will dump the assembler output (so you dont have to go through gdb)
You can also use `objdump` from binutils
I sometimes think that an ideal approach to learn programming might be to learn it on several abstraction levels at once to see how things interact.
One good combination would be Assembly + C + Python for instance. Assembly helps understanding C and C helps with understanding Python.
I'm not sure how long this has been the case, but this is how C is taught at my school (Penn) and I'm sure many others.
In my CIS240 class (currently enrolled) we learn computers from the ground up and eventually learn C. First we do binary arithmetic by hand to get a feel for it, then we design basic circuits (and some complicated) that can perform the basic computer instructions (ADD. MULT, SHIFT, AND, XOR, etc.) then we keep building up off of these basics until we are finally writing C, at which point we will (hopefully) have a good grasp at what is going on and appreciate our programming language of choice a whole lot more.
Assembly was always daunting to me. Then I took Computer Systems at the University. It ended up being seriously fun. The way it made me think and try to solve problems were engaging and different it seemed. It required a new way of thinking and made me think about things I never thought about. Although we only wrote smaller programs for the class, I found them fun and I still remember the class nearly 10 years later.
In regards to the original post, I'm not sure I would be putting C with assembly or learn one over or for the other. They both have their uses and reasons for knowing. Forcing yourself to learn one before the other does not seem like a logical way to go. I think it's best to start with what makes the most sense for your end goal and / or you are most interested and motivated to begin and get most deeply into.
I used to teach Assembly and I spend a lot of time talking about how it connected with C since assembly is almost always used in conjunction with C. I have a free text on the web that was used in the class. It only covers 32-bit x86 since that's all there was back then. http://www.drpaulcarter.com/pcasm
Fascinating, reading it made me remember how fun it was to use Softice.
It's been more than a decade since I've worked in C, but don't C compilers have an option to emit assembly directly?
Hmm, interesting..
I think this always scares/annoys certain programmers. See comments near the bottom of every thread that suggests learning assembly, including this one.
I think it scares/annoys programmers who do not know assembly and will never learn it.
The simple fact is that knowing assembly and C anyone one can build whatever other language anyone else is using. These are the building blocks. It's simply a lexer and a parser away.
Your favorite scripting language was probably built with C. If for no other reason than superior performance. Even if you writing in Lisp/Scheme, you probably also do some C code generation. C is unavoidable.
And the guy that knows assembly and C is probably a better C programmer than the one who doesn't know assembly.
This probably makes some programmers uncomfortable. Why else would they argue against anyone teaching or learning assembly, or make excuses why they will not learn it?
Probably. I could be wrong here, and of course there are always exceptions. But I consistently see the same sort of comments trying to argue against anyone else teaching or learning assembly. There must be a reason for it.
+1 for hackerschool
I like what these guys are doing.
Mixed feelings here:
* Knowing what the machine is doing is useful and important, especially while debugging. I think every really good C coder I know has been comfortable with assembly at least on some platform.
But…
* C is not a fancy macro assembler. C's behavior drives an abstract machine, and any machine code that achieves the same output assuming that all the C behavior is defined is equally valid. The believe that compiler is just transliterating your code to ASM is responsible for many serious bugs. C Compilers haven't been like that for 20 years (or more). E.g. aliasing rule violations. The fact that it isn't is utterly essential for performance, especially as things like good SIMD use become more critical for performance.
Even when the compiler is mostly transliterating the expectations from the simplified mental machine model can be misleading, e.g. alignment requirements on load on some architectures.