278 karma · joined November 17, 2016
The other option, and the one I choose, is to go from high-level languages down. What I'm not so sure about is just throwing people in in the middle, so that they are trying to grasp abstractions like functions and variables at the same time as they are trying to understand pointer arithmetic.
In the subset of Racket we use, all values are immutable, so an understanding of memory (stack vs. heap) is less necessary. We do still talk about "frames" to understand lexical scope, though, and students get used to thinking of each function call using up a new "frame" of memory to store its local variables. This allows them to understand the memory efficiency of recursive functions.
We then move onto Python, and _do_ talk about an "environment" (stack) and a "heap" (I call the heap "object-land" because objects live there). This enables us to talk about garbage collection. More importantly, students get used to thinking about variables as being bound to either primitives or pointers to shared memory.
In Go, there _are_ pointers, and students get used to thinking about memory addresses as values. They learn that pointers are useful both for sharing mutable references, and for avoiding expensive copies. (In Go, arrays are values, and passing a large array to a function copies it.) But none of the sharp edges of C's pointers are present. Go does "escape analysis" so that if you return a pointer to a local variable, that local variable is allocated on the heap; it is safe to point to anything and if you do, it won't be garbage collected. There's no pointer arithmetic.
By the time they see C, in the third-year course, a lot of the pieces are in place to have a good understanding of how the stack and heap (and manual memory allocation) really work. And along the way, because they were using higher-level languages, the students have been creating cross-platform, complex programs (web servers, games, etc.) that they're proud of. :-)
Re: sibling's comment that "some people aren't cut out to be engineers," I think that's a somewhat dangerous attitude. I think the study of computation is profound & rewarding and should be part of a liberal arts education for everyone; even apart from that, programming is also a useful skill for people who won't get a job as an engineer.
I can certainly imagine a different sequence, where students learn logic gates, hardware, assembly, then C, working their way up to higher levels of abstraction. Even in this case though, the goal isn’t to jump in and start writing big programs in C right away.
https://gist.github.com/alex-lew/883ee382a697b39f0f6b49561a0...
By the way, I use Atom, which has an excellent Pollen plugin, to write. Typing '@' then pressing tab turns into ◊{}, with the cursor between the lozenge and the braces.
It's also neat to show students, after they've spent months learning Racket, that all sorts of useful things -- including the writing of their assignments! -- can be automated with their new skills.
http://www.townandcountrymag.com/society/politics/a12015570/... https://www.google.com/amp/jezebel.com/confederate-monuments...
(Note: since Racket supports exact bignums, in a sense numbers are not atomic either! Only Booleans ;-)
Rather than expect applicants to take measures to whitewash their résumés (which also gives an advantage to those applicants whose extracurriculars are already "generic," i.e. upper-class and white), it seems we should be educating employers to be aware of their biases when reading these résumés, and teaching strategies for overcoming them.