Thursday, February 22, 2007

Cocoa: First Screens


Here's a lil' screenshot of the application nib. No logic behind it yet, but it's coming.

The application uses Core Data, though I've got to do some pre-filtering against it, so I can't just hook it straight to the GUI. Bummer.

For the first time, I'm really understanding the architecture of a well-constructed Cocoa application. It's actually pretty fun.

Maybe I'm just biased (okay, I know I'm biased), but it all seems to lay out better than your typical .NET application. The inheritance-model just makes sense. Delegate objects make sense. Notifications make sense. These things took me days to figure out in .NET 2.0. Here? About twenty minutes.

Or maybe I'm just purposely making .NET difficult so I have an excuse to stay in the Cocoa world.

Hey Readers! I'm sure some of you have experience in either the .NET or Cocoa worlds. What say you? Why do you develop with Cocoa? What have you developed?

One of the things which kind of scares me as I delve into these technologies is the job market. You never hear about people looking for Cocoa developers. While I'd like to believe it's because every Cocoa developer is just so happy with his job that he performs perfectly and never wants to leave, the Rational Me says, "No, it's because there isn't demand."

But then, the Optimist Me says, "Hey now. There are plenty of small Mac-soft shops around." And he's right. Right now, tons of highly-motivated, highly-passionate teams are creating small, specialized applications for the Mac.

Take, for example, Loopware. I'm sure David is tired of me asking him questions and annoying the hell out of him on AIM, but this is a one-man shop who caters to a specialized crowd of equally devoted users.

It's happening everywhere. Textmate is another perfect example. That's probably the coolest part about the 'Net. With millions of users, you only need a percentage of a percentage to stay afloat as a one-man developer.

Crazy.

Cocoa: Diving Right In

I've decided to make an effort in the area of Cocoa Development. I picked up a few books about six months ago, and even managed to work through the lil' tutorials.

The problem with tutorials, however, is that without the right mindset, you'll end up with a working something with no concept of how you got there. Without personal involvement in the project, it's harder to maintain attention, and therefore retain the information presented to you. I still recommend reading through the tutorials, however, so that you can make a mental index of where to find things later.

My primary resource is Cocoa Programming for Mac OS X, by Aaron Hillegass. Hillegass has been developing for Cocoa since its creation at NeXT, and now does workshops at the Big Nerd Ranch. If I had the cash, I'd fly out there in a heartbeat. For now, I'm content reading his book.

Objective-C is a very nice, clean, and organized language. In my mind, it's (nearly) everything that C++ should have been. The only area that people will probably complain about is garbage collection... because... well... it's manually done. You maintain your own reference counts, and take care of allocating and deallocating memory. Apparently that's set to change in Objective-C 2.0, which should make its appearance soon.

The concept of message-passing, a thing it borrows from Small Talk (apparently) is brilliant, in my opinion. It's the same thing that makes me such a big fan of Ruby. You ask tell an object, "Hey, do you respond to this?" and it will tell you. This feature makes things like the Observer Pattern that much more intuitive. It's even provided out-of-the-box through the NSNotificationCenter. Badass.

Many things on my plate right now. Client work, school work, fun work. If anyone wants to join the Co-Op as a PHP developer, let me know. =)

Labels: , , , ,

Friday, February 16, 2007

From Scratch: Part I - Setting Up Your Mac

I use a Mac for development. It's a beautiful thing. Before you start calling me a Mac-zealot, I'll throw down the disclaimer: This is probably the only time you'll have to worry about me ranting about the Mac. After this, it's platform-neutral.

The process is pretty painless. If you're running a different platform, just make sure you've got the following running on your box:

  • Apache 1.3 or later
  • MySQL (or your preferred DB... be forewarned, I'm sticking to MySQL)
  • PHP5.2.1 or greater
Apache
I'm going to assume that most of you Mac users already have Apache, and that it's version 1.3. That's a fairly safe assumption, as it's what currently ships with the Mac. The only thing you'll probably have to do is enable it.
  1. Go to System Preferences
  2. Go to Sharing
  3. Click "Personal Web Sharing"
  4. Turn that bugger on
*Poof* - Apache 1.3. Gee, Macs are great. Linux, too!

MySQL
Download the Mac OS X version of MySQL 5. Install it. Bam. You rock. I'd suggest having MySQL start startup if you're going to be using this machine for heavy development. It's annoying to have to start it manually all the time. Details in the download.

PHP
If you're running Linux, you might already have PHP5 installed. If not, you can probably snag it using your distro's package manager. Users of Mac OS X can either compile and install it themselves, trying to figure out what flags do what, or they can download the Entropy package. Yeah. Good idea. N-i-c-e and simple.

Testing!
So, how can we tell if it worked? When you enabled Personal Web Sharing, you turned your Sites folder (located in your user directory) into a document root! Throw this file (test.php) into that folder, get rid of the ".txt" extension, and navigate to http://127.0.0.1/~yourusername/test.php

You should be greeted with a page full of sweet variables and settings in tabular form. If not, uh, see me.

Building Ajax-ified Web-Applications with Mac OS X, PHP, Code Igniter, Prototype, and Scriptaculous

This series will henceforth be known as the "From Scratch" collection. Today's writing (as well as unofficial title) is "From Scratch: Overview."

With all the hoopla over Rails, Django, and (Insert Other Popular Framework Here), people are starting to become curious about how they, too, can start building neat web-applications. Many of our web-hackers, however, are too busy to sit down and learn a proper language to facilitate this. "We were raised on PHP," they say, "And we're sticking to it!" Fair enough.

People are always comparing X vs Y. Looking over my logs, I see a lot of the traffic generated to my old blog had queries like "PHP vs Django" or "Code Igniter Ruby". The problem with these queries is they're mixing lingo.

  • Code Igniter is a framework written in PHP.
  • Django is a framework written in Python.
  • Rails is a framework written in Ruby.

If you happen to be one of those poor souls who has been flamed for mixing up the terminology, have no fear. They're flaming to compensate for something. Like running Windows.

Moving on.

Everyone seems to have their favorite framework, language. They usually have good reason. Ruby is a beautiful language. Django is an amazing framework. PHP runs everywhere. Everywhere.

So, I'm focusing on PHP, both because it's still everywhere, and because I have the most experience with that particular language. Yes, it's verbose and ugly and there are no namespaces and sometimes I want to cry and... hey, it works.

This collection will cover the following:

  1. Setting up your Mac OS X box with PHP and MySQL
  2. Creating a local, virtual domain for development
  3. Setting up Code Igniter on your virtual domain (pretty URLs included)
  4. Hello, World! Hello, Papa Ajax!
  5. Techniques for Ajax-based development
  6. How to conquer the world in three easy steps
Of course, we'll also run into the usual fare: data modeling, MVC-separation, and things which I do because I think they're right.

Here we go...

Wednesday, February 14, 2007

A Challenge, A Task

For those of you who hate having to enter a five-letter sequence of characters to post your blog comments:

If a form is as the bottom of a page, wouldn't a user have to scroll down to submit that form? If a field has no focus, doesn't the user have to either click that field or tab over to it? If a form has fields hidden from view in a browser, will it not be blank?

Why doesn't someone create a system that uses metrics of human-browsing behavior to determine of a post is spam or not? If 99% of 10,000 visitors had to scroll down, give focus to the fields, and entered values only in text fields that are visible (i.e., don't have an extra div cleverly hiding them from human-view), then it's safe to assume those 99% are human. If, on the other hand, a request is made, a response is posted, but there is no intermediate activity (scrolling, focus, gradual field-value change, pauses, etc), and fields which shouldn't be visible are filled out, isn't it safe to assume that the post should be marked as spam?

I'm just saying... Someone should make this thing. Yes, it involves several components, but it'd be damn cool.


Thoughts?

Tuesday, February 13, 2007

Play MP4 on your LG VX9800

It apparently works out of the box. If you try copying an MP4 to your mini-SD card by putting it in the my-flix folder, it will show the clip, but say it's unavailable. Lies.

Steps:

  1. Convert your favorite movie to MPEG-4.
  2. Create a folder called "media" in the root of your mini-SD card.
  3. Copy your movie to this folder.
  4. Insert the card into your phone.
  5. Make sure you're on the phone's "Desktop"
  6. Press "OK" (Menu).
  7. Press 0 (that's a zero).
  8. Press 0 six more times.
  9. Scroll down to "Get It Now Settings" (or press 9).
  10. Scroll down to "Get It Now" (or press G).
  11. Scroll over to Media Player.
  12. Hit "Play File".
  13. Select the folder called "fs:/card0/media".
  14. Select your movie file.
  15. Press 2 to start playing your file. You can find additional key settings under "Help".

That's right. Those tricksters put a hidden Get It Now application on your phone that plays MPEG-4! It might even play other files! I'm not sure what a Sequence is, but it plays those, too. It also Pesudo-Streams, whatever that is. You can even turn on KDDI HTTP EXTENSIONS (again, no idea, but it's all-capped in the Settings menu, so I have faithfully recreated it here).

Hens forth (if you don't get "hens forth", you should watch Amelie), you can skip to Step 6. There are also a whole bunch of other menus to play with... just don't break anything.

Happy Hacking!

Tuesday, February 6, 2007

The Obligatory First Post

So I was sitting at home, probably feeling bad for myself (or whatever else I do on Tuesday nights), when I started to think about this whole "Web X.0" thing.

Those of you who have heard the proper version of the term and are equally tired of it, praise ye. For those of you who have no idea what that means, follow the white rabbit.

No, I'm not going to sit here and rant about "the new bubble", or "the social web." There are plenty of those sites sitting around. In fact, I kind of like some of the things labeled "Web 2.0" - I'm just not particularly fond of the container we're trying to fit it all in. People are already starting to talk about Web 3.0 - the bright and shiny web of tomorrow. The problem is, people are assigning version numbers to something which is characterized as being largely versionless. (On a side note, a quick Google-search shows that James Kobielus apparently agrees with me. Notice my proper use of the phrase "a quick Google-search", as opposed to "a quick google". Someone should send me a T-shirt. Hint hint.)

So What Do I Have To Offer You?


As I said, I was sitting at home (feeling sorry), thinking about the "new web", when I realized, "Hey! I kinda know a lot about all this new stuff! In fact, I've been tracking the greatness for the past six years! Maybe I should write some of this stuff down!!!!!!!!!!!!"

So here I am.

On what authority, you ask? Well, typically I like to downplay my experience, mostly because I believe it to be true. In the back of my mind, however, I'm basically a pompous ass just waiting to tell you how I can make something better. In my mind, I'm like that old boxing coach - even though I can't fight, I'm more than willing to make you fight better. Something like that.

So, my new readership, what would you have me write on? Bear in mind my area of expertise lies in web site and application development. Should I write on my humble beginnings? Early development? The learning process?

P-p-p-post it in the comments!