Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: C tutorial for Perl programmers?

by bulk88 (Priest)
on Sep 03, 2013 at 05:55 UTC ( #1052019=note: print w/ replies, xml ) Need Help??


in reply to C tutorial for Perl programmers?

Teach strict types, tell them types are objects. Teach casts. Teach machine representation/memory/pointers. Teach memory management (malloc vs static vs alloca vs auto). Teach what .objs and .libs are. Teach symbol resolution/linking. Teach them "(*(__int64 **)&pointer) += 2" does not add 2 to the pointer but 16. Named parameters. Type promotion for extra credit. "if" doesn't need curlies if 1 line long. "switch". No sigils. Thats all I can think of. Both Perl and C are all algebra and PEMDAS.


Comment on Re: C tutorial for Perl programmers?
Re^2: C tutorial for Perl programmers?
by QuarterToWhen (Novice) on Sep 03, 2013 at 11:11 UTC
    That looks like a good start. I might leave pointer arithmetic for "if we have more time". I could probably spend a few days on that alone, likewise type promotion.

      Also, don’t overlook these:

      • definition vs. declaration
      • the preprocessor: #define, conditional compilation, #include
      • arrays and const
      • struct, union, enum, and typedef
      • the more commonly-used standard libraries: stddef.h, stdio.h, string.h, stdlib.h
      • the different uses of static

      Some more advanced topics for later:

      • extern
      • variadic functions
      • long jumps

      Also of practical help when teaching memory management: explain the meaning of “segmentation fault” and “bus error” — your student(s) will be seeing a lot of these! ;-)

      Hope that helps,

      Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

      Dont leave pointer arithmetic for later. Teach it early. It was the hardest thing for me to understand when going from Perl to C, if a pointer is just a number, why is +2 way to far off to the right in memory? Do I have to do +0.5 to get to the first slice? (no, go learn pointer arthmitic)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1052019]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2014-10-25 17:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (146 votes), past polls