I’m just going to start teaching classes of C programming to university first-year CS students. Would you teach `defer` straight away to manage allocated memory?
My suggestion is no - first have them do it the hard way. This will help them build the skills to do manual memory management where defer is not available.
Once they do learn about defer they will come to appreciate it much more.
Absolutely the wrong take. You can teach CS with just pencil and paper, but that doesn’t advance the technology, it might only benefit academia in a narrow sense. CS students should be actively engineering software in addition to doing science.
No, but also skip malloc/free until late in the year, and when it comes to heap allocation then don't use example code which allocates and frees single structs, instead introduce concepts like arena allocators to bundle many items with the same max lifetime, pool allocators with generation-counted slots and other memory managements strategies.
No. They need to understand memory failures. Teach them what it looks like when it's wrong. Then show them the tools to make things right. They'll never fully understand those tools if they don't understand the necessity of doing the right thing.
There is a technical specification, so hopefully it will be standard C in the next version. And given that gcc and clang already have implementatians (and gcc has had a way to do it for a long time, although the syntax is quite different).
If you're teaching them to write an assembler, then it may be worth teaching them C, as a fairly basic language with a straightforward/naive mapping to assembly. But for basically any other context in which you'd be teaching first-year CS students a language, C is not an ideal language to learn as a beginner. Teaching C to first-year CS students just for the heck of it is like teaching medieval alchemy to first-year chemistry students.
Absolutely, it's not their first language. In our curriculum C programming is part of the Operating Systems course and comes after Computer Architecture where they see assembly. So its purpose is to be low level to understand what's under the hood. To learn programming itself they use other languages (currently Java, for better or worse, but I don't have voice on that choice).
zffr|9 days ago
Once they do learn about defer they will come to appreciate it much more.
orlp|9 days ago
The point of a CS degree is to know the fundamentals of computing, not the latest best practices in programming that abstract the fundamentals.
jurf|9 days ago
baq|9 days ago
leni536|9 days ago
flohofwoe|9 days ago
brabel|9 days ago
junon|9 days ago
uecker|9 days ago
thayne|9 days ago
gignico|9 days ago
dapperdrake|9 days ago
kibwen|9 days ago
NooneAtAll3|9 days ago
learning Python first is same difficulty as learning C first (because main problem is the whole concept of programming)
and learning C after Python is harder than learning Python after C (because of pointers)
gignico|9 days ago
adhamsalama|9 days ago