Skip to main content

Posts

Showing posts with the label Objective-C

Learning to Code: Comments Count

I like comments in computer programming source code. I've never been the programmer to claim, "My code doesn't need comments." Maybe it is because I've always worked on so many projects that I need comments  to remind me what I was thinking when I entered the source code into the text editor. Most programmers end up in a similar situation. They look at a function and wonder, "Why did I do it this way?" Tangent : I also like comments in my "human" writing projects. One of the sad consequences of moving to digital media is that we might lose all the little marginalia authors and editors leave on manuscript drafts. That thought, the desire to preserve my notes, is worthy of its own blog post — so watch for a post on writing software and notes. Here are my rules for comments: Source code files should begin with identifying comments and an update log. Functions, subroutines, and blocks of code should have at least one descriptive comment. ...

Learning to Code III: Hello World

In my earlier posts (I, II, and Intro), I explained that I'll be using Xcode to learn Objective-C and the Cocoa Frameworks to learn about programming OS X and iOS applications. If you look back at those posts, you will find how to create a new command line application in either C or Objective-C. This blog entry compares "pure C" to the C code I'll be using within an Objective-C file. Because Objective-C is a superset of C, you can use any valid C programming code in an Objective-C file. After this blog post, I'm going to be doing all coding within Objective-C projects, for simplicity among other reasons. Hello, C Programming Begin by creating a new "Command Line Tool" project in C. Apple's Xcode handily creates the code to output "Hello World!" to the command line. Run the code and you'll see the results in the "debug area" of the Xcode window. Ah, for the old days when aspiring young coders had to type the "Hello W...

Learning to Code II: Welcome to Xcode

If you're going to develop iOS or OS X applications, you're going to be using Xcode, Apple's integrated development environment (IDE). The blog post is an extremely simple introduction to Xcode. It's so simple that I'm only going to discuss one command in the IDE: the "Run" application button. Before starting to program on a computer, I create a folder (directory) for my programming projects. I call the folder "Programming" to keep the contents obvious. You can name your programming projects folder anything, but be sure you can locate it easily. I like to keep programming projects outside my "Documents" folder, at the top level of my personal user folder. Most of the folders within the home directory for a user are created by the operating system. For example, Apple's OS X creates the following: Desktop, Documents, Library (usually hidden), Movies, Music, Pictures, and Public. The home folder for most users won't have as ma...

Learning to Code: The Tool(s)

If you want to learn Objective-C, it helps to know C. Learning C — or reviewing it — is a good way to become familiar with Apple's development tools, too. Learning to program is a cause of mine. I advocate teaching programming to all students, not merely a handful of geeks, hackers, or nerds. When we teach everyone about coding, it demystifies how computers work and it introduces students from a wider variety of backgrounds to what could be an excellent career path. Years ago, educators would use LOGO or BASIC in elementary school classrooms. Then, along came HyperCard. There are still introductory programming tools based on LOGO, BASIC, and HyperTalk languages. You can learn to program using AppleScript or by writing Microsoft Word macros in Visual Basic for Applications (VBA). Personally, I'm for using whatever tools a teacher might enjoy at the earlier ages (K-6). In high school, though, I am biased towards plain, simple, C as a foundation for future coding skills. ...

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: Clair, Robert. Learning Objective-C 2.0: A Hands-on Guide to Objective-C for Mac and iOS Developers (2nd Edition) ., 2013. 9780321832085 / 0321832086 Perry, Greg M. Absolute Beginner's Guide to C. 2nd ed., Indianapolis, Ind.: Sams Pub., 1994. 0672305100 In the early pages of Clair...

Computer Languages Change - Like Spoken Languages

Are computer languages inherently "artificial" and "pure" — either like Esperanto or a dead language, such as Latin? Or, are computer languages as much "living" as spoken languages? Understand, I am not considering low-level assemblers or "dead" computer languages that exist in virtual museums (and yes, there are tech archives to explore). I mean the languages that are in wide enough use that programmers develop attachments to them and vocally argue about their futures. In spoken languages, some people are purists. These experts like to "prescribe" grammars and the meanings of words, insisting on a rigid approach to a language. By comparison, some scholars of language as "descriptive" researchers, trying to document a language's evolution. Most scholars, however, are a bit of both — we try to prescribe dominant rules, while accepting change will happen. The French try desperately to maintain an official "Frenc...

Programming Language Hierarchies

Computer languages are often divided into groups, such as "3GL" and "4GL" — third- and fourth-generation languages. The divisions aren't perfect, and don't always represent a chronological evolution. Trends that seemed to be advancing programming have been abandoned when they proved overly complex or simply unnecessary. Human languages experience similar trends. Artificial attempts to control languages, human and computer, often fail because the users of the languages have more influence than the "gatekeepers" wish. A few languages are better "controlled" than others, but in the end the people seeking to communicate will do whatever they believe is needed. I've heard compiler designers complain about software programmers "abusing the language" just as grammarians complain about emerging writers. One difference, and it is a serious one, is that computer languages rely on strictly defined compilers. Curiously, French is con...

Learning to Code: Programming Books for My Cocoa Journey

To refresh my programming skills in C and begin my Objective-C journey, I am using the following books. These books are only the beginning of my trek through the Xcode jungle towards OS X and iOS apps. Learning Cocoa with Objective-C: Developing for the Mac and iOS App Stores . Apple. Sebastopol, CA: O'Reilly, 2001. 0596001606 Clair, Robert. Learning Objective-C 2.0: A Hands-on Guide to Objective-C for Mac and iOS Developers (2nd Edition) . Boston: Addison-Wesley, 2013. 0321832086 (pbk.) Hillegass, Aaron. Cocoa Programming for Mac OS X . Boston: Addison-Wesley, 2004. 0321213149 Hillegass, Aaron. Objective-C Programming: The Big Nerd Ranch Guide (Big Nerd Ranch Guides) . Atlanta, GA: Big Nerd Ranch, 2011. 0321706285 (pbk.) Kochan, Stephen G. Programming in Objective-C (Developer's Library) . Indianapolis, Ind.: Sams, 2004. 0672325861 Nutting, Jack, Dave. Mark, and Jeff. LaMarche. Learn Cocoa on the Mac . New York: Apress, 2009. 9781430218593 (pbk.) Perry, Greg M. Absolu...

Learning to Code: The Month (and More) of Cocoa Begins

This week I am beginning a month (and more) of intense "Cocoa" immersion. Cocoa, for those outside the OS X/iOS development realm of Apple, is the framework created by Apple's wizards to make programming for Apple hardware a (tiny) bit easier. Since I want to develop applications for Macs and iOS devices, I need to learn the Cocoa frameworks. It's going to be a long journey, and a fun one. On this blog, I'll be posting about programming as an educational experience. I'll also continue to explore programming as a form of writing. I'm surely not going to do the topic justice, but allow me an attempt to explain how computer languages and frameworks are similar to other languages. When we write in any language, we start with a core of basic words and grammar. Computer languages are more concrete and simplistic than living languages, but you might compare them to the languages children speak. I am not going to go über-geek in this post and explain the t...

Know the Job Market

I tend to answer questions when asked, often without pausing long enough to consider the best wording — or even if I should answer. This semester, I'm teaching a course that uses Wikis to explore collaboration. The students are struggling with the Wiki format and some of the concepts. You'd be wrong if you thought users of Wikipedia understood how the system functions. I mentioned that installing and maintaining any content management system (CMS) was a good skill to have. A student then asked about job skills currently in demand. He was told by someone that some specific tools were in demand, while others were not. The tools and skills he was told are valuable are absolutely, positively not highly-valued based on a simple search of tech-focused job sites. And, of course, I said so. Sorry, but Visual Basic isn't going to land you at the top of the field. (There are still companies using VB for database applications, but C# is a better choice in my view.) And while ...

Learning to Program

Late last night I installed the update to Apple's OS X programming tool suite, Xcode 4. This summer, in my "free" time I intend to work my way through my old copy of Teach Yourself C and the several Objective-C books I own. While I do play with various languages and tools, from AppleScript to PHP, I've never managed to master Objective-C — which is something I want to do. As I've written several times, knowing simple coding techniques is a practical skill and one that helps learn problem solving strategies. Even my use of AppleScript and Visual Basic for Applications (VBA) on a regular basis helps remind me to tackle problems in distinct steps, with clear objectives from step to step. There are many free programming tools that students should be encouraged to try. On OS X, the first two tools I suggest to non-technical students are Automator and AppleScript. These tools allow you to automate tasks on OS X, similar to the batch files of DOS or the macros of Wor...

My Personal Tech Biases

The surest way to get into an argument might not be a discussion of religion or politics. No, the real heated debates, at least online, deal with those really important matters of bias: Windows, Linux, or OS X? iOS (iPhone / iPad) or Android and Chrome (or maybe Windows Mobile)? XBox or PS3? (Sorry, Wii) FireFox, Chrome, IE, Safari, or other?  PHP, Perl, JavaScript, or ASP / .Net? Objective-C, C#, or C++ with Qt? You get the idea. If you really want to read arguments, read technology blogs. These are passionate people arguing vehemently over technologies that often come and go faster than an Italian national government. The lifespan of some fruit flies seems longer than the life of a cell phone generation. My students have grown up with the same attachments to modern technologies that I have for fountain pens and mechanical pencils. (I love a good pen or pencil.) Getting a student to switch from Mac to Windows or from Windows to Mac can be nearly impossible. I've had one...