Friday, October 03, 2008

iPhone dev 9 - got the hardware

Today all the hardware arrived. An iPhone, a WLAN box and a Mac Mini. This stuff really was disruptive to getting things done -- I haven't felt this much like a child since... well since I was a child! Walking to the post office to get the iPhone almost turned into a run because I couldn't wait to play with it. Then when I had everything, stuff worked really well right from the box. Noticed though that I accidentally got a 2G iPhone instead of 3G one, but that doesn't really make any difference for development (good bye to my plans on starting to use VoIP w/ Asterisk though). I feel like I joined some cult now that I have this stuff. I even read the holy texts of Apple -- namely the folklore about pirate flags and Woz's pranks. I have truly joined the dark side.

I have tried to get back to reading the cocoa fundamentals documentation even while I feel a bit giddy and would prefer to just play around with this stuff. I have to remind myself I got these for a purpose -- to develop an app for the iPhone which will then pay for this expensive hardware. So with this in mind I've muddled through the fundamentals documentation, but it's getting awfully abstract. Well of course it is abstract, because I just reached the design patterns part. Fun to read about abstractions in something which in itself already feels abstract to me at this point (Cocoa programming). I think for my motivation's sake I should try to get something going with Xcode while I read forward.

Thursday, October 02, 2008

iPhone dev 8

My iPhone and Mac Mini will arrive today. Might be disruptive to my Cocoa study.

"Sometimes using a protocol can avoid subclassing". Not sure what that means, not sure what "delegates" are. Code is in .m files, headers in .h files. Saw how to declare classes. Instead of C-style "#include", "#import" is used instead. It's like require_once in PHP.

#import
-- function and data type declarations --
@interface ClassName : Superclass {
-- instance variables --
}
-- method and property declarations --
@end

The .m file could then look something like this:

#import "ClassName.h"
@implementation ClassName
-- stuff --
@end

If I see "IBOutlet" in code later, that is somehow related to "nib files" and the Interface Builder synchronizing with Xcode. Vague at this point. Documentation mentioned that on the iPhone the applicationWillTerminate method gets called when the app shuts down and is the place where state should be saved.

Getters and setters can be automatically synthesized. "copy" and "retain" tell whether object variables should be copied or if the pointer should be stored instead and retain count incremented. Something very strange was mentioned about "KVB", "KVC" and "KVO" that I had no idea about.

Cool thing: in printf strings you can say %@ and then provide an object, and at that point any string returned by that object's "description" method will be inserted. There was a page about threads. Said exceptions should be handled by each thread, cannot be thrown away from thread. Talked about how error-prone thread programming is, that I should copy data and try to minimize possible conflicts arising from shared data. Events should just be handled by main thread, also UIKit objects should only be used in main thread. I imagine I may use threads with socket programming. Said not all Cocoa classes are thread safe.

iPhone dev 7

There is a windows style event loop. On Mac it lives in NSApplication and on the iPhone it's in UIApplication. In AppKit.h there is a method NSApplicationMain that creates the application object, sets up an autorelease pool, loads UI from something called a "nib file" (apparently a file that contains files, maybe even directories?) and starts handling events. On iPhone the equivalent method is called UIApplicationMain.

@"test" is shorthand for creating an NSString that contains "test". In some cases empty string @"" can mean no value / default value. String literals shouldn't be used as dictionary keys? Setter methods are called setSomeVariable, but getters are just "someVariable". Typical framework usage: create subclass, override methods to implement own functionality. Cocoa uses MVC.

Wednesday, October 01, 2008

iPhone dev 6

Init may return a different object than was allocated. For example in singleton case it may return the already existing object. For this reason should always use the one returned by init. Objective-C seems to support exceptions (or is it a Cocoa feature? I'm confused about the distinction). Self, super. Strange plus and minus signs near method declarations. Maybe plus signs have something to do with factories? Noted in explanation about the "respondsToSelector" introspection method, that it tells if an object responds to a certain method -- so "selector" does indeed mean a method? "autorelease" was mentioned many times, but don't know what that is. Section about class clusters: public superclass with many private subclasses, you instantiate the subclasses through factory methods in the superclass. For example Number superclass which can create Ints, Floats and so on. Skipping sections about class cluster details and "creating a singleton instance". I'll return back to them if the need arises to create my own cluster objects or singletons, just too tiring to read about them now.

iPhone dev 5

SEL is data type of a selector, but couldn't really understand selectors are. Are they methods? Reference counting is called "retain counting". On alloc the retain count is 1. If the retain count reaches zero, the "dealloc" method gets called on an object and after that the memory is released. If you "copy" an object the retain count (usually?) becomes one for the copy. There are things called "autorelease pools", but their use is discouraged in iPhone. Somehow everything in the pool gets released at the same time, and somehow objects can be added to such a pool without directly referencing the pool by name (at least the sample code looked like that). App kit on Mac has some kind of autorelease pool already created in the beginning. There are some conventions on when to call release on objects. If an object is created by you, then you should also release it. If you get an object from somewhere else, you shouldn't. There was something related to class factory created object releasing that I didn't understand. alloc -> init -> usable object. In addition to allocating memory, the alloc method also sets a cool explicit "isa" property for the object, that points to the object's class. Also zeroes all properties.

iPhone dev 4

@property is syntax for declaring class methods that automatically create getter and setter methods. Enumeration of sets can be done with the nice "in" syntax as in some other languages. Calling object methods has a bit strange syntax, [object method]. Also possible to give some named arguments, but not sure if the first before : is a method name or an argument name. [object keyword1:something keyword2:somethingelse]. Where is the method name? Is it "something"? Not sure. NSObject is root class of everything, and defines some methods like init (constructor?) and reference counting (retain, release).

iPhone dev 3

NSObject is the root class for Cocoa classes. Stuff starting with UI prefix is UIKit related. Objective-C has garbage collection after version 2.0, but it cannot be used on the iPhone because of performance. Cocoa classes seem cleanly designed. Didn't encounter a regexp class, although didn't check if it's in NSString methods. Event mechanism in iPhone UIKit differs from Mac Application Kit. Looked at Objective-C example code, saw lots of weird square brackets. "id" datatype can hold any Cocoa object, so convenient for enumeration. Dynamic typing, binding, loading. New feature: "categories". By dropping mysterious @ marks in strategic places in your code, you can add methods to existing classes without subclassing. Protocols are like Java interfaces.

Tuesday, September 30, 2008

iPhone dev 2

There seem to very cool tools for debugging and coding. The "Instruments" application seems impressive, creating data porn from your app as it runs. It isn't mentioned whether that can be used when developing for iPhone. I learned for iPhone there is a different compiler, on Mac gcc is used. The iPhone simulator needs to be compiled for, so it really is a simulator and not an emulator. The iPhone needs some special configuration to start development on it.

iPhone dev

I have never used a mac. Once I sat at one in a computer room because other computers were taken, but I couldn't figure out how to turn it on! So with this background let's see how far I can get with iPhone development. I started off by ordering a Mac Mini, buying a jailbroken iPhone from an auction and signing up for the developer program. While waiting for the hardware to arrive I can use the time productively by reading the documentation. Stuff I've learned in the first hour:

"Aqua" is probably what the UI is called on a Mac and "Quartz" is some kind of rendering system for it. You develop software with "Cocoa", which historially comes from NeXTSTEP. The docs talk about "Darwin", which according to Wikipedia is a flavor of UNIX (isn't that Mac OS X? I'm confused). "Carbon" is something I should ignore. Apparently Cocoa also comes with an IDE, which is perhaps called Xcode. When developing for the iPhone my app will take over the whole device -- only one program is running at a time + some background daemons. SQLite and OpenGL are used somewhere by something. On the Mac Cocoa consists of "foundation" and "application kit", but on the iPhone the app kit is called "UIKit". Foundation does non-gfx things. The language stuff is developed on is "Objective-C", which is some kind of superset of ANSI C but with additional OOP features inspired by Smalltalk. Some lower levels use just plain C, but in Cocoa there are OOP wrappers for them.

Let's see if I have the energy to continue, or if I decide to auction off my hardware when it comes :)

Thursday, August 07, 2008

Dead-end stocks?

It's funny how some companies seem to be riding on trends that seem doomed to me. I've been going alphabetically through Scandinavian stock listings, and so far I've encountered three such companies: AudioDev, Anoto and Cash Guard. AudioDev makes testing equipment for optical media. Anoto makes system to read hand-written forms. Cash Guard makes cash handling systems.

In my image of the future all content is accessed through the Internet, therefore there will be no optical media, and so there won't be any need for testing equipment for it. All official forms, questionnaires, multiple-choice exams etc. will be filled electronically, so there won't be so much need for OCR / choice-reading machines. Cash will be phased out gradually, where it might always exist but will be used less and less.

These three companies don't seem to be riding on very good trends :)

Media circus has arrived

Finnish media companies have gotten excited about "social media". They see it as a trend, and they must report trends. To support trend reporting, they want to raise individual examples, hopefully ones that people can relate to. I happen to be one of the few serious Facebook developers in Finland, so I tend to be that example.

It's been fun. First I was featured in some magazine called "Happi". I'd never heard of it, and even with numerous requests they never sent me the issue that my interview appeared in. But apparently someone read it, because next I was contacted by another magazine called "Image". Now this one I had heard of, it's a very high profile magazine. I got my face filling an entire page, it feels unreal. Seems that stories in media inspire more stories in other media, because next I was contacted by "YleX" radio channel and "Helsingin Sanomat", the largest circulation newspaper in Finland. Just wow.

Friday, April 11, 2008

Silly Facebook apps are keeping my stomach full and a roof over my head

This is a long post, but lots of exciting things have happened since the last one!

The Facebook melody composing app I was making in August 2007 didn't take off. Perhaps it just wasn't a very good app for making melodies, or perhaps people just aren't creative enough for it to become viral. I abandoned it and carried on making other ones.

Boy, was that a good decision! It's been a jumble, so I can't even remember the proper chronological order of things, but I think the next app I made was "Your Japanese Name". I thought it would have a very limited appeal, but actually half a million people have installed it now! Wow. Also, it's now making enough money for me to pay my rent.

This got me thinking that perhaps other easy-to-use things that let people express their identity on their profile would do well also. Therefore I started adding to my list all kinds of other apps that fit that description. Some people are looking down on these apps and calling them "badge apps" with no real value, but I believe that ultimately it is the users who decide what is entertaining for them.

I made several. Lots failed. I think failure is good too, it's great to know what doesn't work and try to ponder why. I made one which comes up with a description of the past life of the user. Like it might say that you were a cave explorer in your past life, and that's why you are so adventurous now. Perhaps that was a bit too random, showing that off in your profile doesn't really tell anything about your identity. I'm happy that it failed, because it raised my belief in humanity a bit, that people won't accept just any crappy app :)

Just to make sure though, I had another app made which is similar, but it shows you what you will be reincarnated as in the future. That failed even harder. Strangely though later someone else made a past life app similar to mine, except it was a huge huge success. I believe it was because of the forced invite system though, and not because the app itself had some merit above mine. Well, the author got away with that and made a lot of money, so maybe I should have put such a system in place too.

There are about a dozen failed apps which I made. I'll describe more of those in other posts. Let's talk about one success for a change. It's called "Name Analyzer", and like "Your Japanese Name" it displays your name in your profile, but just in plain english, with some adjectives attached to explain what each letter in your name means. I can't claim it's an original idea, but it hadn't been done for Facebook yet. Basically it has the merits of "Your Japanese Name", but doesn't limit the userbase to only those with an interest in Japan.

It took off like a rocket and now has nearly 7 million installs, with a hundred thousand people using it every day. I wrote last year about my scalability and bandwidth worries, but now in retrospect that hasn't been an issue. I'm not paying significantly more for hosting now, and just one server has been enough to handle the load, and even that server has been mostly idle, even though the server logs are really flying.

Oh, I lost a lot of impressions though because the logs are REALLY flying, and I hadn't realized how large they would become! I had 8GB of space left, so I thought I would be OK. However, with 100k people each doing several page loads and causing longish lines to be appended to ever growing log files, I actually ran out of space. Many times. Every time the velocity of the expansion of the server logs took me by surprise! Running out of space is a bit nasty though, because it corrupts MySQL tables. Luckily the repair worked!

After seeing that people have an interest in it, I have added more features to make the app stickier, with pretty good success. Now there is functionality to decide analyses for your friends, change colors and fonts and backgrounds, make your own themes that others can use etc., all ever so slightly increasing the frequency of people visiting the app and the length of time they spend in it. Not a big difference, but with user numbers this large even a small percentage difference can be significant.

With monetization, I believe I have signed up for the best advertising network, which is Social Media. I do feel that I haven't really tried out all the other alternatives, but they pay so well that it's difficult to imagine that the others could be better. From discussions on the developer forum, there seems to be a consensus that Social Media pays the best. Only other options I have tried are Google AdSense and selling merchandize through Zazzle, but both of them paid an order of magnitude less than Social Media. Perhaps I should properly try out Cubics, VideoEgg and the others though, just to be sure.

Even though the merchandize (mug cups with your name on it) failed, I'm not sure that it was because the idea itself was flawed. Maybe the product, or having a link to an external site was the problem. Maybe if there was something that could be easily purchased while on Facebook, I could monetize better. Only ideas I've had so far are mobile phone background images or premium SMS subscriptions to get your name analyzed for your phone. That's something I might explore more.

So, how has this increased ad inventory affected my life? Well, I already told you that "Your Japanese Name" has allowed me to pay my rent, so you can guess that "Name Analyzer" has been even more significant in that respect. I won't make any big purchases though, only major thing is that I'll probably travel a bit more, still on a shoestring budget though. I'd like to think I'm pretty responsible when it comes to my spending. I don't have a car, I live in a normal sized shared apartment. I eat pea soup out of a can for dinner. I even have a spreadsheet with an inflation-adjusted plan for until I am 74, the age at which an average Finnish male tends to die. I don't have enough to live until then, so I'll keep saving. Couldn't resist getting a projector and a Nintendo DS though ha ha :p

I've gotten some very VERY interesting requests to appear at job interviews, but I don't really feel comfortable letting others decide what I should be making, now that I'm having so much fun thinking up new apps :) And I do have a lot of ideas! That list I started last year is getting really long. Lots of them are obviously stupid ideas when I look at them now, but for some it's hard to say! I hope I'll have success making some other type of app, I wouldn't want to be a one trick pony!

Wednesday, September 19, 2007

Five US citizens seeking asylum in Finland

This news was ignored in foreign media, so I guess I have to translate it.

"Finnish border officials were amazed when five US citizens applied for asylum status yesterday evening at the Helsinki-Vantaa airport.

The applicants had arrived to Finland from inside the Schengen area and informed The Border Guard of their desire for asylum status. From here on the actual application process will be handled by Directorate of Immigration.

- In near history this is the first time adult US citizens have applied for asylum status in Finland, major Janne Piiroinen told reporters.

According to the information made available to reporters, the US citizens are part of the same group. Officially the reason of the asylum application is still unknown, but it is not related to protests of Iraq war."

Wednesday, August 08, 2007

Decided which Facebook app to make .. NEXT =)

This post is mainly meant for myself to organize my thoughts.

I finished my composing app mostly. I got around 200 people to install it, now I am waiting to see whether it is viral at all or not. Currently it is showing growth of 2% per day, but I'm not sure if it's really spreading at that rate, it could just be chance. Would be wonderful if it were true, because 2% increase per day is over a thousandfold increase per year. Personally I think the app sucks, but I've seen other apps get popular which suck even more, so I guess it's not totally impossible ;)

My friend made a great suggestion for the subject of the next app -- one which would let people take and make tests. It seems extremely viral, because it has two ways of spreading. Firstly, if a user creates a test, it seems very likely they would send it to their friends. Secondly, people always like to share with friends their test results and encourage them to also take the same test, so that the results can be compared. I'm amazed nobody has made this kind of app yet. I might feel paranoid about sharing this idea, but luckily nobody except you reads this blog.

There are tons of different types of tests, so I am now trying to decide which ones to include and which not. For example there are IQ tests where the question and possible answers are images ("which picture comes next in this series?"). Then there are knowledge tests where the question and answer are text ("what is the capital of Japan?"). Also there are image recognition quizzes ("which Simpsons character is this?") where the answers are text. Rarer, but possible would be reverse image quiz, where the question is text and the answer a multiple choice out of a set of images. Then there are multivariable quizzes which are a bit more complex ("answer this set of questions to discover which 24 character you are"). I think I came up with a way to create even multivariable quizzes that isn't all that confusing ...

Those were the different quiz types I could come up with, but there are also some features that could be included or left out. When answering a question, sometimes in quizzes additional information is provided about the correct answer ("what is the capital of Japan?" - "Tokyo" - "correct, did you know Tokyo is blah blah"). There could be time limits when answering. In addition to getting how many percent were correct, sometimes there is textual feedback ("80% - very good"). The questions could come in a predetermined order, or at random.

On implementation side the normal way to do this would be a straightforward HTML (well FBML) interface, but to make it faster it could be done with Flash or javascript. It's kind of annoying to wait for page loads after each question. I have done some scripts like these before, and the biggest problem I had was keeping track of which questions have already been displayed to the user (when random order) and making sure that no duplicate options are included in multiple choice questions. Why is that tricky? Well suppose there are two questions "what is the second largest city in the state of New York?" and "what type of animal is the wild Arni?". Both of the answers are "Buffalo". This means that randomly chosen multiple choice answers could contain two identical answers with different meanings, which should be avoided.

Friday, August 03, 2007

App mostly finished

Alright, I worked hard for a week straight and managed to finish the Mini Mini Melody application for facebook. Please follow that link and install it if you have a Facebook account, then send me some feedback!

Wednesday, August 01, 2007

Tay Zonday, tour for us!

Dear mr. Tay Zonday. You rule. For now. People want to see you, but soon they will forget. That's the fate of an Internet star. So go along with this, live your "Internet dream". See the world. Make a zillion dollars in the process.

Let go of the hesitation.

Monday, July 30, 2007

Totally tired with this app

I'm exhausted! I've been working on this melody Facebook app for around a week now. At first it was very exciting. I had big dreams of making a hugely popular app, but now that the app is becoming more concrete it is starting to become obvious that this will be marginally popular at best. Why? Well, turns out it's a lot more difficult to express yourself with music than by drawing!

Currently in the app you can selected between a piano, a cat's meow, a dog's bark, human voices or drums. The app allows you to make a very short composition, around 30 seconds at the longest perhaps. There is a staff on which you can place notes to make your tune. I haven't done the sending part completely yet, but the idea is that you could send these tunes to your friends.

The path from an idea to reality is always less smooth than one would hope. An idea is very vague. Even if you try to work out an UI on paper, it's still vague, even if you don't know it. There are just so many little details that you will never be able to think about until you make the app. And that's fine, because making the app is all about describing those little details to the computer anyways. I'm struggling to provide a concrete example here, but for example in this case the idea was "a graffiti-like app for sending melodies". Then in the paper UI mockup I realize that there has to be some way to put different instruments on a staff. Then when really trying to make it, I realize that when you are placing those instruments, there has to be some kind of indicator of what you are selecting. But that indicator shouldn't be shown if you are outside the area ... and if you select drop-down menus they should appear ABOVE all the notes, not below. And a million details like that.

After you spend days just basically tangled with these small details, you become very exhausted even though from previous experience you knew that it would be like this, while of course secretly hoping that this time would somehow be different. There is some satisfaction in seeing your idea become a reality, to interact with what you have created, but at the same time you have to face the depressing reality that perhaps your idea wasn't as great as you had hoped. What seems like a fun idea often isn't as much fun in reality.

A tale of two Graffiti

If you use Facebook, you have probably used or at least seen the Graffiti app, which makes it possible to send doodles to your friends. But did you know that there are actually two different Graffiti apps? One wildly popular (5,713,050 users and counting) and another more obscure one (mere 11,367 users). Surely the one with less users is just a clone? No, according to the creators, the more obscure one came first.

I remember installing the more popular one and instantly writing graffiti to my friends, which was kind of fun for a while. Out of curiosity I installed the more obscure one as well, but the thing is that I can't figure out how to use it. It keeps showing error messages. The lesson here of course is that it doesn't matter how cool your idea is -- if it doesn't work or the users can't figure it out (which amounts to the same thing) then it will never be popular.

The creators of the original graffiti must be kicking themselves now...

Saturday, July 28, 2007

Melody app progress

I have been actively working on the melody app lately. Learned basic Facebook API usage and started making the UI part in Flash. Progress is nice, I can already arrange piano and drums on the tracks. A surprisingly difficult thing has been trying to find the different sound samples to use.

I need at least a basic piano sound, a guitar sound, drums and some funny sounds. The temptation is great to go to one of those "free samples" sites to grab something, but I want to be sure that any sounds I use are properly licensed. So instead I have been trying out sites where you can download sample packs. I am really surprised at the poor quality of the sites and the sounds they provide. For example some drum hits might have an audible hiss in the background, in some cases almost to the point of being static. Finding drum loops is easier, but I want single hits, not loops.

Come on, I just need around 28 different sounds, hopefully for under $100 total. How hard can this be?

Wednesday, July 25, 2007

Decided which Facebook app to make

The idea that found its way to the top of my ideas list (it's a long list!) is a music composing app. Basically like Graffiti, except that instead of drawing stuff, you can compose little musical pieces and send them to your friends. You would do this by arranging notes on a small staff (the classic "like X except Y" pitch). Taking Graffiti as the inspiration, everyone would have a wall of composed musical pieces.

What I am concerned about a bit is the bandwidth. I wouldn't even be doing this if I didn't intend it to be popular. So assuming it is popular, perhaps people would be loading the composing/playback Flash application about 100k times per day. I did some calculations in my notebook (in a section titled "slimy biz talk corner") and this could mean a bandwidth cost of about $600/month. From my prior experience 100k page views per day for random people isn't necessarily greater than $600/month, so it might be that initially this makes no sense. However bandwidth is getting cheaper, and with Flash 9 there are things that would let me cut the size of the player/composer down A LOT so perhaps it would make sense in the future if not right away.

Oh yeah before settling (at least for now) on this idea, I spent two days basically pondering nonstop about which Facebook application to make. I wrote a long list of ideas that occurred to me, then ranked them based on how promising they seem. It's funny how many ideas for social apps you can find by reading a book containing playground games for children. For example there was a game where you must come up with something that you have done, but none of your friends have done. That would make a nice app as well. Anyway the point is that playground games books are a great resource =)