Hacker News new | ask | show | jobs
by int_19h 1328 days ago
C and C++ are still horrible languages even if you want to teach those concepts, because of how many footguns they have. That's why Pascal was so popular as a teaching language, historically speaking - it still has pointers and other stuff you need for manual memory management, but it's much simpler and more regular both syntactically and semantically.
1 comments

no, it has exactly the same issues as c and c++, and some of its own, such as arrays of different sizes being different types. guess why it isn't used anymore
Arrays of different sizes are different types in C, as well - this is obvious when you are dealing with pointer-to-array types.

That aside, Pascal removes a lot of UB and other footguns by forcing explicitness for e.g. casts and pointer arithmetic, or providing (verifiably safe) byref argument separately from raw pointers. Strings and arrays are a mess in standard Pascal, which is why everybody used dialects that solved them - most notably Borland's, of course, which was used for a lot of DOS and early Win32 software.

Anyway, I'm not suggesting Pascal specifically today. The point is that C and C++ were never good teaching languages, which is why something else was usually used as one whether we look at 80s, 00s, or today.