I learned C in the mid nineties using a copy of Visual C++ 1.0 that a friend had gotten from his father (and probably he got it from work). It was the only compiler I knew of and once I was ready to move beyond toy programs, I was seriously hampered by the fact that this compiler couldn't produce text mode executables (any call to printf opened its own new window that definitely wasn't cmd.exe) and it couldn't set the graphics mode for blitting pixels. It was heavily oriented around this new fangled MFC thing but I was a teenager so I wanted to program games not business apps or whatever. That meant I wanted text mode or graphics mode.
My high school CS class had Borland C++ and I could set mode 0x13 with that in DOS. But I had no way of obtaining this compiler as a kid. And it probably didn't work on Windows 95 anyway.
Anyways, it wasn't until the early 2000s that I finally learned about GCC, a free as in beer and freedom compiler and the simplicity of it would have been amazing for learning.. If only I had known.
But as mesmerized as I was by C++ at the time, Borland Pascal was a lot more fun to play around with. I remember unsuccessfully trying to wrap my head around the different kinds of pointers, and the humble beginnings of std.
This is incorrect. Visual C++ definitely could do all those things, it was in no way a toy. You probably had it mis-configured somehow.
It wasn't in any way a "toy". What I think you're talking about is that Microsoft was pushing the "Visual" aspect of the IDE that it was trying to copy from Visual Basic, but with MFC, and was doing a sucky job at it. You didn't have to use it. Most of us didn't.
Funny thing I still use win10.
> Integers - whole numbers which can be either positive or negative. Defined using char, int, short, long or long long
char is either signed or unsigned depending on the platform/implementation. Use signed char if you want signed integers.
Telling people who are new to C to define booleans with macros is not a good idea, as they have had a proper implementation since c99.
It also feels weird to treat structs and pointers as advanced topics. They are basically required to be productive in the language.
stdint.h was introduced in c99, not c11.
Explaining bitwise operators as "bitmasks" is also quite weird. Bitmasking is just one of the few things you can do with them.
> In C, functions must be first defined before they are used in the code. They can be either declared first and then implemented later on using a header file or in the beginning of the C file, or they can be implemented in the order they are used (less preferable).
This paragraph reads weird. I haven't found any place where the tutorial mentions how to properly write header files. It might be because of the interactive part, but if that is the case then this tutorial doesn't really teach you how to program in C because the tooling around it is an important part of actually using the language. It is also fairly common to declare functions in order of use. Discouraging that is like telling people they need to use tabs over spaces instead of actually focussing on language semantics.
> Note that C does not have a boolean type
`_Bool` and `long long` are both introduced in C99, this is mixed up info.
Edit: probably tailor-made for old MSVC, which didn't support _Bool until VS2013.
When somebody says "This program is written in C", my initial thought is "Which C?". There is no one, single C.
I don't write C daily. Heck, I don't write it monthly any more. And so my grey cells are struggling with which versions introduced what, and you've spotted something I would have missed on a first read.
And this is a problem.
Can you list all the undefined behaviours, and which language features came into which version across ANSI, C99, C11, C17 and C23? The last one feels a little brighter in my mind, but I definitely can't, and if I was writing a C tutorial - like many that have been written - I'd probably be explicit about choosing a version and sticking with it, and good luck and godspeed to everything outside that version.
Of course this is one of the reasons learning C is harder than other languages, and why languages like Zig and Odin have a decent chance: ergonomically simpler than Rust, all the power and flexibility, (much) less of the head scratching.
Things are a lot better today than they used to be though: compilers that don't support modern features are rarer, and the compilers give much better errors on things like UD.
Modern languages - even those that have high levels of C interop like Zig - can (and do) avoid those problems.
I do agree that some of the UB is a problem though.
I think the jury is out on Zig and Odin (but I like Zig a lot, in particular), but I feel Rust has hit a tipping point - like Go, Python and Java - where there's too much production code out there for it to disappear in the next ten years.
If you were to ask me about languages where that might not be the case in ten years, I'd point to where usage is not very production oriented (R, Julia), or where people have had a good try and decided they want to pull back investment (anecdotally, Ruby and Scala seem to be on that curve right now).
Though I suspect it’s fair to say the entire settlement is built of glass houses here :-)
https://news.ycombinator.com/item?id=43798312
I suppose if one wants absolutely no surprises, they will need to lock the entire toolchain as well, regardless of the language…
I’m amazed something like this gets traction here.
It is, however, a terrible tutorial (it's full of beginner errors made by people who don't understand C but think they do based on behavior by whatever compiler they're using at the time).
There is presumably some correlation between sites riddled with ads and having terrible content. Perhaps ad-blockers should show how many ads they have blocked more prominently.
I read the first chapter of that book and loved it! Very unlike other books on C which dedicate an entire chapter to `for` loop for instance. How do other programmers even read a book like that? Isn't it tiring to read through how a `for` loop works for the 70th time.
My condolences on the first part, but congratulations on your dissertation!
On the Array Page:
/* print the 7th number from the array, which has an index of 6 */
printf("The 7th number in the array is %d", numbers[6]);
There is no mention of what %d is or does. Once you know, it's fine, it's the display placeholder for the variable but that's what throws me off on tutorials.
I loved the interactive tutorial!!!
Wondering how long it will take before Linux can be ported to Zig by LLMs. Supposedly subset of it already builds with the Zig compiler (which also compiles C), with some minimal adjustments.
Moral of the story: books are better for learning when it comes to C.
The younger generations totally sideline C completely.
Myself a non-coder but experienced SysAdmin who can write cool Perl, TCL scripts, C almost feels almost natural when reading it. I just haven't had the time available to dive in.
It could be that I was exposed to it at 14 (2003) but chose perl because MSN/Y!M/AOL messenger bots were the discord bots of today. Still, eager to dive in. Some reason Java too.