logoalt Hacker News

tsimionesculast Wednesday at 1:39 PM3 repliesview on HN

That often leaves people with very bad mental models of how programs actually compile in modern optimizing compilers and in modern operating systems (e.g. people end up believing that variables always live on the stack, that function parameters are passed on the stack, that loops are executed in the same way regardless of how you write them, etc).


Replies

dmwilcoxlast Wednesday at 2:26 PM

Think about how far they've come if you get them to have these "misconceived" ideas!

They would understand code and data are in the same place, that all flow control effectively boils down to a jump, and they have a _more_ accurate picture of the inside of a machine than anyone starting out with Python or JavaScript could hope for.

Having spent 25 years to get to assembler, I wish I'd started it sooner. It's truly a lovely way to look at the machine. I'll definitely be teaching my kids how to program in assembly first (probably x86-16 using DOS as a program launcher)

show 2 replies
t-3last Wednesday at 2:47 PM

After learning asm, teach compilers and have them think about how to generate code stupidly, then think about how to generate efficient code. If you don't want people thinking about the stack, just teach them RISC rather than x86.

show 1 reply
bitwizelast Wednesday at 2:58 PM

But if they know assembly, they can look at actual compiler output and form the correct mental models...