Posts tagged ‘c’

Some of the robotics kids have expressed interest in learning to program the processor on the robot but have no prior programming experience. Consequently, today I held a meeting about learning C (the only language with a compiler for our processor). If you think Mudd was like drinking from a firehose, you got nothing on me. In 2 hours, I attempted to teach three kids and a mom nearly all of C. We covered

  • compiling code before running it
  • basic syntax: semicolons, curly braces, and their ilk
  • built-in types: int, bool, char, short, long, unsigned
  • variables, and declaring and defining them
  • if statements, and for and while loops
  • boolean logic: && || ! == etc.
  • creating functions, including arguments and returning values
  • header files and the actual .c files
  • scoping
  • precompiler commands like #include and #define
  • structs, though we only covered these briefly
  • pointers, including pointers to pointers, dangling pointers, and the array/pointer duality (again, kinda briefly, except their utility in affecting things outside the current scope)
  • cout and cin, though again only briefly (not really necessary for programming a robot that lacks both of these)
  • compiler errors
  • other odds and ends that were mentioned in the sample robot drivers (extern, static, and other keywords like that)

We’ll see how much of this actually stuck, but at the time the kids seemed to understand a lot of the stuff we covered.

Looking back on it, it took me months to get the hang of all of this! Though to be fair, I was supposed to be learning this stuff and applying it to tricky situations (creating my own hash tables, memory allocators, etc) at the same time.