Handmade Hero»Forums»Code
Trevor Adrial Hart-Maloney
9 posts
Programming Tutorials
I've created a site dedicated to low level programming. The first set of tutorials which is an intro to basic C programming just got finished and is up now, I figure this community would be interested in something like this:

http://www.lowlevelprogramming.org/
José Eduardo Terán
1 posts
Global Educator. Game Developer
Programming Tutorials
Hey,

I am looking at it and it is actually very interesting. Thanks for sharing it!
Ginger Bill
222 posts / 2 projects
I am ginger thus have no soul.
Programming Tutorials
Edited by Ginger Bill on
I am reading parts of it now and it seems very interesting. I do have a few questions:


  • * Why are you teaching references which are C++ not C.
  • * Why are you teaching about member functions as well?
  • * In C, when a struct/union/enum is declared, you have to prefix the type with it unless you have typedef'd the struct/etc declaration. e.g. `struct Type x = {0};` or `typedef struct Type {...} Type; Type x = {0};`
Trevor Adrial Hart-Maloney
9 posts
Programming Tutorials
I guess I'm confused when you say "references to C++ and not C", I showed a code example of C++ from a game I worked on in the part on comments and we're compiling with VC++ but that's really it...I may mention it a few times but overall I'm teaching with C.

As far as member functions go all I showed was that you could call a function from a struct...I may have mentioned "methods and members" elsewhere, but I don't see why that would be an issue...As far as the struct and union thing you are right, however it still compiles and I didn't feel like having that overhead for a total beginner, maybe that was dumb but it is what it is, I may go revisit it later.

I appreciate the feedback, and it gives me some stuff to think about!

Thanks!
Trevor Adrial Hart-Maloney
9 posts
Programming Tutorials
I appreciate that, thanks!
Ginger Bill
222 posts / 2 projects
I am ginger thus have no soul.
Programming Tutorials
Reducing confusion is what you need to do. If you want to teach C++, then say you are teaching C++ not C with some C++ features.

C is very different language compared to C++. Perfectly valid C code can be uncompileable C++ code.

One example is that in C, pointer types are weakly typed.

1
2
3
int* x = ...;
char* y = x; /* Valid C code but not C++ */
char* z = (char*)x; /* Both valid in C & C++ */


The weakly typed pointers are both useful and dangerous. They allow for polymorphism and subtyping.


If you teach people that this is C code, when they try a different compiler or OS, they will expect it to work as C code.

Be extremely clear with what you are teaching and try not to give misnomers or other false information.

If you are showing code from your game, that is fine but make sure you clearly show it is C++ and not C.

C is much simpler language compared to C++ and most people program different in one to the other.
Misu Popescu
6 posts
Programming Tutorials
Edited by Misu Popescu on
Sorry to say, but you just seem to confuse C with C++. C does not have references or member functions man :(

You can't claim to teach C when you are actually teaching a restricted set of C++. As programmers we should try to be as clear as possible, especially when we teach other people. Essentially you are using a subset of C++, which would be just fine, if you wouldn't claim that this is C!

C is a different language than what you think it is, try a little experiment and save your reference example from http://www.lowlevelprogramming.org/CTuts/Part10.html as "test.c" (note the use of .c termination). After that try to compile the code with a C compiler :)

A small suggestion: In order to stop spreading confusion around beginners, just change all "C" from your website to "C++", this will make your tutorials a decent start for a beginner.
Trevor Adrial Hart-Maloney
9 posts
Programming Tutorials
Again, I briefly touched on it because it is a part of the C++ compiler, the bulk of what is being taught is C, I feel like it would be a little silly to say "C++" and then basically teach C style C++. I feel like griping about that one small tiny part out of 20 tutorials seems a little silly to me...in earlier lessons I would even mention "Since this is being compiled as C++, you can do this, however it's not C" so I think I made the distinction fairly well...
Trevor Adrial Hart-Maloney
9 posts
Programming Tutorials
Also I'm using the C++ compiler because it is the main compiler for Windows if you want to use VS, so that's why I chose to use it. Maybe I will go in and do another part on pure C but I didn't feel it was beneficial in any way to do that for a beginner.
Mārtiņš Možeiko
2233 posts / 1 project
Programming Tutorials
Edited by Mārtiņš Možeiko on
For beginner it will be very confusing when he reads this in part 10 "References are key to learning pointers, one of the most powerful parts of C", and then comes to handmade hero (or any other forum) asking something about his code. Like "why do reference in C code does A or B?" He'll get response that there are no references in C code. He will be confused, and we will be confused.

Windows compiler (if by that you mean Visual Studio) compiles C code perfectly fine. It's not "C++ compiler", it compiles in C or C++ mode depending on file extension and command-line arguments (same as GCC and CLANG). If you have extension .c then file won't accept any C++ features unless you pass special command-line argument.
Yes, MSVC doesn't support all the latest standards like c11 or c99, but majority of c99 is supported.