Saturday, February 20, 2010

Day 2

I didn’t leave on a very good note at the end of day 1 of this journey – that’s bad news. The good news is that I have some good stuff to report today. I found an Apple computer to play with. It has Mac OS X Leopard (version 10.5) installed! A nice thing about my occupation is that we might not have much of anything (yes, that’s including money), but we won’t be short of computers: any kind and any make. If I set my heart on and my eyes opened wide, I will find one – at dark corner of someone’s cube - dust coated, abandoned and desperate for attention.

I fired it off and the machine came back to life. I am so excited. I haven’t touched a Mac computer for a long time. Last time when I used a Macintosh, I was still in grad school in different major and PC a new kid on the block. Looking back, it is interest to see how things have evolved and fortune has been changing hands from one to another and back for a few times. It is always exciting to see something old come back anew.

Oblivion of the nice GUI in front of me (some claimed this is the first time Unix and GUI are coming together), I go to hunt down something mundane and banal but infinitely powerful: the console box – for people familiar with Unix, the shell. Under Go/Utility menu, I found it. The default is a bash. Just type a few commands (actually my finger clicks the keyboard out of its own muscle memory, outside neurological command from my brain). They all work! Now I feel much comfortable. It seems I am quite familiar with this terrain.

Well, looking around I also saw something peculiar: something incongruous with the rest of landscape. It is very much like seeing a lush green willow tree popping out of sagebrush in the middle of a desert – questioning your own sanity at the sighting. Here is what I actually see: the command and file names are case insensitive! So “vi” is the same as “VI”, or “vI” or “Vi” for that matter. It is so un-Unix like. Case sensitivity is a piece of holy grill held by Unix devotees, dearly to their heart. I am sure Apple’s practice had made a lot of people uneasy about its intent and conformity. To them, “apple” is different from “APPLE” (Apple – macintash, APPLE – golden delicious, aPPle - granny smith, and so on). Using case sensitivity, we can encode 32 different species under a single pronunciation – is there anything more graceful than this (kidding)? But for normal user, case insensitivity makes more sense, I have to admit. Later I find out that Apple does provide a way to keep the case sensitivity (under political pressure from die-hard Unix programmers, I supposed), at time of installing Mac OS. I, indeed, re-install the OS with that option chosen.

Another oddity I found has something to do with how Mac OS marks the line ending in an ASCII text file. As we know, Windows (and Dos) uses CRLF (0x0d 0x0a) as the marking. Most Unix (Linux included) uses LF. When I saved a text file from vi on Mac, I found “vi” ended the line with CR. Not clear to me is it a choice of the vi program itself, or the rest of Mac OS demand the CR as the standard end-of-line marking. I guess I will soon figure that out – when I download some of my popular scripts from my Linux box. It seems everyone wants to do things in slightly different way – causing problem and headaches for everyone else to endure and suffer. That’s one of the problems that have plagued Unix development since its early years: lack of conformity (and respect) to each other. I heard Google gonna release its own OS, let me put a dollar on the table that Google will use LFCR as the line breaker on its OS as it is only combination of CR,LF left unused.

With all the familiarity I enjoy, I am still hindered by my lack of knowledge on some basic operational skills to get me around on this new platform. I have stumbled on as simple/trivial task as how to eject a CD out of the CDROM drive. It drives me nuts to find myself immobile in front of the new toy – all my existing knowledge serves me no good and has to be cleansed, all educated-guess are approving wrong. So I start to compile a list of how-to’s here. The list is dynamic. I will add more as I go.

Boot from DVD - Press C key while the system booting up

Eject CD/DVD - Drag n’ drop the CD/DVD icon to the waste basket

Boot to single user mode - CMD + S (Press command key and S key at boot up)

Boot to verbose mode - CMD + V

Boot to firmware(the bios on PC) – CMD+OPT+O+F

That’s all for today…

Monday, February 15, 2010

Day 1

Today is the first day on this project (or the metaphoric “trip”). It is time for some research first. In our wonderful age of Internet, the information is readily available from a few googles away. I quickly discovered the site for iPhone development and signed myself in (free):http://developer.apple.com/iphone. The iPhone SDK even includes a simulator! But the SDK requires an Intel based Mac running Mac OS. Well, I don’t own a Mac machine in the first place. So I have to solve that problem first before I can get any further. I do not intent to buy an Apple Mac – priced much higher than other non-Apple product line with similar hardware configuration, at least not now. So I decided to investigate a software solution: running Mac OS on Windows or on Linux. Obviously it has to run under a simulator or in a virtual machine environment. I went back to google for direction.

Just entered “How to run Mac OS X on Windows XP”, I found the PearPC emulator solution. There is even a YouTube video (http://www.youtube.com/watch?v=XD2F_S-zsuw) to guide me through to install PearPC on my Windows XP and Mac OS Tiger on the top of PearPC. Later on, according to the plan, I will install iPhone simulator on top of the Mac OS X – I am stacking a lot of things on top of each other here. A few notes on PearPC: it is a PowerPC emulator and an Open Source project. That means it is free (it accepts donation to fund the project and I would say we should open our wallet to show our appreciation to those unsung heroes behind the scene, if the product really helps us – that is). A quick look at the PearPC website. It is not very clear how reliably it runs Mac OS X. I don’t have the warm and fuzzy feeling on the product that it matures and be sophisticated enough to allow me to set up a cross compiling environment and run an iPhone emulator on the top of that.

Another route to take is to run Mac OS on Intel-base PC hardware – have a number of those unused PC box lying around in my house, collecting dust and waiting to be called into action. There is also a YouTube video for helping me out as well. After viewing that video, I don’t feel very comfortable on taking that route either. First of all I don’t own a copy of Mac OS X software – legally. If I go to buy one, it almost costs as much as buying a Mac computer. Frankly I don’t see much reason for anybody to buy a Mac OS software alone. I am probably better off just to buy a low end Mac (I can get one around $500 – here goes my budget) and be done with it. Apple does not like anyone going free to run Mac OS on a computer that is not pre-approved by Apple – in other words, no Apple clones. To load a Mac OS X on the un-sanctioned PC is a violation of the agreement you signed (unknowingly for most of us) with Apple Computer Inc. at time you purchased the Mac OS X operating system. I have a feeling I am heading down a treacherous road – a path laden with legal land mines and unknowns (sigh).

Not very good start. Let me think about this a bit more...

A few comments I would like to make on virtual machine architecture that is quite in vogue nowadays - before I leave today in despair and defeat. Internally, virtual machine is no different from that of emulation software – both are duplicating the functions of one system using a different system (Wiki definition of “emulation”). The technology has been around since very early days of digital computing. IBM (who else but the good old big blue?) first released a software emulator in 1957. However, virtual machine architecture does realize the benefit of emulating something of its own! Under that architecture, one can create a number of machines (of cause virtual) out of a physical one. According to VM enthusiasts, it utilizes the hardware better. I don’t know on what base the conclusion was drawn, frankly. Two separated services (or computer programs in layman’s term) operating in their own VM environment run two copies of OS image instead of one. How can you call it utilizing hardware better? Yes, it creates better segregation for security and stability, easy deployment, mobility. But not more efficient usage of hardware!

Sunday, February 14, 2010

Day 0

Maybe as part of new-year resolution or just being caught in the iPhone frenzy, I decide to make myself familiar with programming on smart phone devices. Being a veteran computer programmer, I have a decade and half experience under my belt. However I have not done anything on cell phone devices (neither smart nor not-so-smart ones). So I set off on this journey to write a little (hopefully useful) program running on one of the smart phones on the market (iPhone or/and Android phone) and blog my experience along the way. In the process, I hope I can have some ones on the Internet find it worthwhile to read for gaining some technical knowledge or even finding some entertainment value out of this blog. At the very least, blogging provides me the incentive to keep myself going on this project, knowingly there might be someone waiting to see it through as eager as I am – no matter that how illusionary the existence of that someone might be J.

A few words on the format of this blog: it is similar to that of a typical travel log. Each post represents a write-up of events that take place on a “day” of this imaginary field trip. The “day” is, of cause, figurative and has no relationship to the real calendar days. I have a day job that takes most of my waking hours during the week – contractually and thankfully (in the middle of deep recession) so. I have to spend my evening hours or weekends to work on this project. Each post may span a few calendar days or more. But it is very much in my own interest and eagerness to get it done in a timely fashion.

As in any project, there exists obstacle (technical and non-technical) that seems insurmountable initially, testing my knowledge and will, and requires time to search/research, learn/unlearn to get around or get over the hurdle. I am sure I will come across some of that on this endeavor as well. I will document my setback and despondency with as much willingness as I do on success and felicity, in the hope of soliciting help from the greater viewing community of the Internet.

Now, before I set my foot out of the door, let me clarify the destination of the trip further. As fuzzy as it is now, I want it to be as challenge as it can be. There is no fun to document a trip to the neighborhood pharmacy. Is there? I want to climb a mountain on an exotic continent I have never set my foot on before and getting to its peak is venturous even for the locals. Technically speaking, the final product has to have a “kernel” component that alters/enhances some basic functionalities of the device. I will not declare victory if I just manage to get a dummy hello world program running. Those are for juniors and rookies. I want get deeper into the smart phone technology and come out claiming an expert on it. Further more, phone is a communication device first and foremost (well, a lot of people use it as a game console). I want to uncover the inner working of digital communication on those platforms. TCP/IP is my cup of tea for quite a while. Maybe I should take a sip at that first. Anyway, I will have better idea once I reach the continent, see with more clarity after I get inside the mountain…

I quoted the word kernel above. It is because the very concept of kernel v.s. user space in regular operating system might not be applicable here. I have no idea how iPhone OS looks like, at this moment. If it is a strip-down version of Mac OS, the same way Android is related to regular desktop Linux, the concept still applies. There are a lot of embedded devices running one space OS, by the way.

There is some money I have to spend on this learning expedition – I came to realize. But it should not be much (< $500 by my estimation). For now, I don’t even own a smartphone. But that expense can be postponed as I can work on a simulator - a software-based virtual phone on my laptop computer. I don’t think it has interface to receive/transmit cellular signals unless I have to install some special device to enable that. Or maybe the simulator becomes so advanced, it can simulate that as well.

As you can see, there are a lot of questions than answers at this moment. Enough introduction and self-motivation. Today is the first day of Chinese New Year of tiger (Feb. 14, 2010) – a good day to start to fulfill a New Year resolution after it was missed from the Gregorian one. Let the journey begin.