Skip to main content

Learning to Code: Starting Point for Objective-C

As readers of this blog know, the more I delve into programming, the more convinced I am that it should be a standard school subject — not merely an elective sought after by a few enthusiastic students. Programming skills reinforce the value of breaking problems into simpler pieces. In the end, a computer must reduce problems to simple tasks. Good writers, historians, chemists… we all break problems into little, digestible, solvable tasks.

And just as a musician must practice scales, the basics of programming need to be practiced and sometimes revived. It is no secret that my C skills have atrophied, so I am starting from the beginning. My journey towards Cocoa Goodness begins with two books:


In the early pages of Clair's text, he mentions that you need a good understanding of C to work effectively in Objective-C. Turning to my bookcase, I found several C books, but settled on the Absolute Beginner's Guide because it is operating system and compiler agnostic. It is an old and simple book (1994 being the ancient past in computer time), yet it is precisely what I needed for a quick review.

I'm strange, I realize. Not many people like to go back and read basic grammar books, yet I always enjoy recalling the little bits about English I forget. Any time I teach a writing or literature class, I review the materials and feel like I'm discovering something new. Programming has that same feel.

As Clair reminds readers of the basic syntax and common functions in C, I turn to the Perry text and read the short chapters on the same topics. Clair assumes that his readers know C, C++, Java, and similar languages. He also stresses that Objective-C is closer to C than C++ — so you need to unlearn (C++) and relearn (basic C) as you move into Objective-C.

Many, many years ago, when I was an undergraduate, USC had several NeXT computers. The language used to program the NeXT was Objective-C and the operating system was NeXTSTEP (with the silly all-caps but "e" format). As I start writing about Obj-C, you'll be able to recognize this legacy. I graduated from USC in 1990, so a fair number of years (22+) have elapsed since I last used Objective-C. Even as a Mac owner and user, I clung to other tools for as long as possible. Now, I must go back to the future.

Programmers might wonder why I'm not turning to that fabled classic, The C Programming Language by Brian Kernighan and language creator Dennis Ritchie. Or maybe an O'Reilly book, such as C in a Nutshell. The Absolute Beginner's Guide is a better text for me. It's much better than a "Dummies" or "Idiots" text, sparing readers the attempts at humor. Perry keeps chapters focused on one topic. At the end of the book, there is a code listing for a complete blackjack game. I like that the code heads towards a real project, something I can play with and modify.

Going back and forth between a dense technical text (Clair) and a more project-based text (Perry) helps me consider issues from two perspectives. Beginners don't think about pointers and memory, which is an essential aspect of coding. The better you understand computing theory, I believe the better your code. You don't need to understand the finest details, but enough to appreciate what is happening "under the hood" when you create an application.

Young writers can get overwhelmed when we focus too much on grammar and mechanics. Beginning programmers can also be overwhelmed by too much deep theory. Focusing on ideas first, then developing an appreciation for how a language works seems perfectly logical to me. We don't teach children grammar before they speak! We teach them about nouns and verbs, periods and commas, long after a child is speaking.

As a programmer, I like to see how problems are solved, and then I study the code. After I study the code, I enjoy going that extra level or two deeper — which is why I love learning about the magic performed by compilers.

A good enough comparison: When I learned BASIC, I didn't need to understand what the interpreter or compiler was doing. As I learned C, it helped to learn how memory worked. Later on, I learned how to optimize C code, based on what the compiler would do and how a particular CPU worked. Yet, learning BASIC was an ideal introduction to programming: I learned to express simple ideas (BASIC) before learning how to write properly structured programs (Pascal, Fortran, and C). Yes, I know you can do a lot with modern BASIC derivatives — but early BASIC, was called BASIC for a reason. BASIC allowed mere mortals to program.

What have I learned as I revisit C and begin to learn Objective-C? I'm going to bore readers with a bit of C in my next post, since that's what I've been revisiting. I'll also discuss how learning something like C helps me as a creative and academic writer. Yes, coding can be poetic. It is certainly inspiring.

Comments

  1. I've never been a fan of K&R. It's a nice historical curiosity, but not as the first introduction to a new C programmer.

    ReplyDelete
  2. I can really identify with your description of coding as poetic: there is a beauty to a well-written piece of code that I find very pleasurable.

    ReplyDelete

Post a Comment

Popular posts from this blog

Slowly Rebooting in 286 Mode

The lumbar radiculopathy, which sounds too much like "ridiculously" for me, hasn't faded completely. My left leg still cramps, tingles, and hurts with sharp pains. My mind remains cloudy, too, even as I stop taking painkillers for the back pain and a recent surgery.

Efforts to reboot and get back on track intellectually, physically, and emotionally are off to a slow, grinding start. It reminds me of an old 80286 PC, the infamously confused Intel CPU that wasn't sure what it was meant to be. And this was before the "SX" fiascos, which wedded 32-bit CPU cores with 16-bit connections. The 80286 was supposed to be able to multitask, but design flaws resulted in a first-generation that was useless to operating system vendors.

My back, my knees, my ankles are each making noises like those old computers.

If I haven't already lost you as a reader, the basic problem is that my mind cannot focus on one task for long without exhaustion and multitasking seems…

MarsEdit and Blogging

MarsEdit (Photo credit: Wikipedia) Mailing posts to blogs, a practice I adopted in 2005, allows a blogger like me to store copies of draft posts within email. If Blogger, WordPress, or the blogging platform of the moment crashes or for some other reason eats my posts, at least I have the original drafts of most entries. I find having such a nicely organized archive convenient — much easier than remembering to archive posts from Blogger or WordPress to my computer.

With this post, I am testing MarsEdit from Red Sweater Software based on recent reviews, including an overview on 9to5Mac.

Composing posts an email offers a fast way to prepare draft blogs, but the email does not always work well if you want to include basic formatting, images, and links to online resources. Submitting to Blogger via Apple Mail often produced complex HTML with unnecessary font and paragraph formatting styles. Problems with rich text led me to convert blog entries to plaintext in Apple Mail and then format th…

Screenwriting Applications

Screenplay sample, showing dialogue and action descriptions. "O.S."=off screen. Written in Final Draft. (Photo credit: Wikipedia) A lot of students and aspiring writers ask me if you "must" use Final Draft or Screenwriter to write a screenplay. No. Absolutely not, unless you are working on a production. In which case, they own or your earn enough for Final Draft or Screenwriter and whatever budget/scheduling apps the production team uses.

I have to say, after trying WriterDuet I would use it in a heartbeat for a small production company and definitely for any non-profit, educational projects. No question. The only reason not to use it is that you must have the exclusive rights to a script... and I don't have those in my work.

WriterDuet is probably best free or low-cost option I have tested. It is very interesting. Blows away Celtx. The Pro version with off-line editing is cheaper than Final Draft or Screenwriter.

The Pro edition is a standalone, offline versio…