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

Practical Technology Skills

This blog is a revision to a column I wrote for Direct Media publications. Normally, I wouldn't repost something I wrote for hire, and I certainly don't wish to anger one of my publishers. However, since this blog is primarily accessed by one of my graduate seminars, I think the publisher will appreciate that I am extending my thoughts for educational purposes. I'm also more than willing to encourage businesses to visit the Direct Media home page . Page numbers seemed to be a half-inch lower on each successive page. I stared at the mid-term paper, handed in to me by a junior at the university, and thought back to my fights with dot-matrix printers. When I was an undergrad, my Epson FX/80 printer jammed often and would sometimes rip pages after the sprockets slipped out of alignment with the punched holes of the perforated paper. Surely the undergraduate author of this paper suffered the curse of a similarly possessed printer, I told myself. “I guess when I changed the ma...

Pursuing a University Degree Online

Visalia Direct: Virtual Valley February 2008 Issue January 7, 2008 Pursuing a University Degree Online When a star high school student graduates in Tulare County, the difficult reality is that he or she most likely will leave to attend a four-year university. For an eighteen-year-old student, leaving the Central Valley, or at least Tulare County, is part of the educational experience. But, after returning to Visalia some of us find out that our undergraduate educations are not quite enough. For those in education, Fresno State, Fresno Pacific University, Chapman University, and others have offered courses in Visalia for a number of years. This makes it possible to work and still complete a teaching credential or an advanced education-related degree. I have been thankful for the options we have in the Central Valley. But, as others have learned, if you are interested in some fields you must commute to Fresno — or even further. With the drive to Fresno taking just under an hour...

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 ...