Saturday, March 14, 2009

Objective-C

I switched over to Apple in 2003/2004 ish, and I've never really done any programming on it. Because of the iPhone, my intrest in apple development has peaked. So these last few days I've been looking into it and building some sample apps in XCode.

I'm intrested in building a Visual Novel of sorts. As a kid I loved choose your own adventure books and I've played a few VN that I liked. I've also played a bunch that I hated.

But being the writer & programmer that I am. I thought it could be fun to build my own.

There are a number of ways I could build this, the easyest being HTML and JavaScript (another AIR app). But I kinds want this to be on the iPhone (partly becuase if it successeds I could sell it).

So now I'm looking at how it can be done in objective-c and cocoa. To be honest I haven't programmed in C (or C++) in over 7 years. Looking over samples rings some bells, but Cocoa is a new beast all together. Anyway, I think I'm going to try this objective-c programming.

I know this isn't very zen of me. I could have something up and running in a matter of hours if I stuck with JavaScript or C#. I don't even have a story or graphics yet. I just have a vage idea of a zombie survival story.

I really should write the story first, then worry about programming.

Still, I find myself here even when I know I shouldn't.

Monday, January 12, 2009

Ideas

For years I've been toying with different ideas for thinking or evolving software. The concept where you give the program a goal, some starting information, and some rules; and the program figures out the best way to reach the goal.

My favorate so far is the evolving method. The program created thousands to millions of little randomized programs and makes them surive or die. Maybe I'm just fasinated by the idea that something intelligent can derive from randomness. One of my favorate demonstations is where clocks evolve out if random parts (YouTube clock evolution).

If I could harness this idea, then there would be no limit to the problems it could solve. With enough time and prossessong power, it could solve anything.

So I was thinking today of how to build said program. My first instinct was to build it in C# because that's where I'm strongest. Then I thought I should build it in python because the language is a lot more flexible and would lend it's self easer to this kind of project.

Both have good points and both could be argued for my zen method. But which one is the right one? Speninding too much time on that question is very anti-zen. It's better to just pick one, even the wrong one, than to spend to much time debating the choices.

Back to how the system would work. I was thinking something like a table structure. The first column would be the input. The seciond would be the rule or function. The third would be the result.

The input could come from any of the sesory inputs, any random number(s)/letter(s), or the result from any row above it. This table would then be the programs DNA so to speak. It would be evaukated in order and the last row would contain the final result.

The rules would have to defined to the specific problem being solved. Over time universal rules that apply to almost any (if not all) problems could be defined. I think the more general the rules are, the longer it will take to find the best solution.

With enough random creatures, a very small percent will have some sort of solution. Then the winners go on to round two and new random children are created. Some of the new children will get random sections of the winners DNA. This process is repeated umtill the best solution is found.

A Question.
How do we know who was close to the correct solution? It would be easy if some of the found the solution, but I fear that that would take an impossible number if starting creatures.

Tuesday, December 30, 2008

Knit Project Completed

I finished the Knit Project application in time for xmas. My girlfriend loved it and said it was everything she needed. I need to find some cheap hosting so that I can share the program with the world. Cheap hosting would probably come with a database and I'll probably end up modifying the program to use it.

That's okay though. The point is to keep things simple for as long as possible. If I have to revert on a decision I made previously, it doesn't mean I made the wrong decision. Things are always in a flux and the right decision now isn't necessarily the right decision in the future. If I would have tried to use a database the first time around, I probably wouldn't have been able to complete the program on time. So not using the database was the right decision even if I add one in the future.


Thinking about the flash card program. I came across an idea. I'll need a way to store the flash cards on the internet, but I won't necessarily have a database. So I wonder if I could pull the information from my blog. The blog supports ATOM feeds. In theory I could just tag posts with the flashcard data, and the program could just get pull form the ATOM feed. I'm not so sure blogger would approve of it. But if it's only a few posts with just me and my friends, I don't see the problem.

Friday, December 19, 2008

Knit Project

I've been working on the Knit Project application because I need to have it done by xmas. I ran in to a problem once I started to run it as an Adobe AIR application. (It's stupid to call it 'Adobe AIR' because AIR stands for Adobe Integrated Runtime. So I'm really saying Adobe Adobe Integrated Runtime. That's just stupid, but google won't return anything usefull if you just call it AIR. So you have to specify Adobe AIR. Thus, I am going to continue to call it Adobe Adobe Integrated Runtime.)

Adobe AIR uses Webkit to render HTML. Apparently, Webkit doesn't like "for each()" in javascript. So I had to change all of my "for each()" to just "for()".

I also notice that the placement of the controls, which looked OK in firefox, looked like ass in Adobe AIR. My inital thought was to break the controls into their own windows like Photoshop/Illistrator/etc. I've never used windows or popups in my webdesign before. Opening the window was easy, trying to get the windows to comunicate proved difficault.

So I was thinking about how to solve this problem, and I asked myself. Do I need the controls in a seprate window? Does it add anything significate to the program? The answer was a restounding "No." So I threw out the idea and asked, "What would be the fastest/easyest way to group these controls?" Tabs of course! Within a few minuetes I had the controls broken up into tabs at the top of the application. Not only did this look nicer, it make easer to work with the grid. Which is the entire point of the application.

Loading and saving to a file proved to be dead easy. I was able to copy some code from Adobe's API refrence and adapt it to my program. It took less than 10 minenutes.

I did run into another bug with Webkit. I have a table of all the knitting symbols the user can click on. When you click on one of these symbols, it updates the Marker cell. This worked fine under firefox. But for whatever reason, Webkit will only show the image properly if I double click on the symbol. I set the 'src' to the image, which works fine, but when I resize the image. Webkit stops showing the image the first time. Once I've seen it in the marker once, it'll always work properly on the first click. I spent a half and hour or so trying to fix this bug. I couldn't get it working so I just remved the code that resized the image. I can always go back and fix it later if I need to.

I'm thinking I might have to rewrite the zoom function again. If you zoom all the way in, and then zoom out, the knit symbols are tiny. I want to fix it, but I'm not sure about the best way.
I thought about making all of the image one specific size. (right now they are all diffrent sizes). Another way would be to store the orginal size somewhere (probably in the symbol JSON) so I could refrence it. If I do that, I need to keep better track of the "zoom level" so I know how to adjust the image size.

Another bug: In the grid it's self, if there is an image, the user can click on the image and not the table cell, which won't cause the cell to change to the current marker.

Monday, December 15, 2008

Welcome!

Welcome to Zen Software.
*note: I know that some may dissigree with the way I am using the word "Zen" I am using it in the meaning of simple and without excess.

My goal is to develop simple applications that focus on getting the job done. I want to move away from all of the features and bloat. Every decision in designing the software should first ask, "Does this contribute to mission of the application?"

I have two projects right now. One is a knit pattern application that I am making for my girl friend. The other is a flash card program. Both of these applications use Adobe AIR.

Why Adobe AIR?
After playing around with Adobe AIR, I found that it does what I need without making me do anything I don't want to. I can create a page in HTML/CSS/Javascript and it will just work with Adobe AIR. If I don't want anything else, I don't have to use anything else. If I want some extras, like the ability to load and save to a file; it's there. If I want to use jQuery, I can. It just works and stays out of my way. That is why I am using Adobe AIR for these projects.

Does using Adobe AIR contribue to the projects?
Both projects require some way to save and load data. The knit project needs the ablity to save and load patterns. Otherwise it doesn't achive its purpose of allowing my girlfriend to easally view/edit/print knitting patterns. The same deal with the flash card program.

There are many options I could take to solve this problem. The solution that comes to mind first is to use a database. Save the knit patterns in the database, then she could access them anywhere and we open up the possiblity to having people share patterns.

The downside to useing a database is that I would need some kind of server side scripting. And a database. There may be ways to talk to a database without serverside (I didn't look.) But that still doesn't elminate the need for a database. And the need to maintain that database. I'm not saying that these are terribaly difficault tasks, but they don't really fit the zen concept. That's more work that I'd have to do that doesn't really focus on the purpose of the application. There is no real need that anyone other than my girlfriend use the program. There is no real need to allow people to share patterns over the internet. There are other ways to provide those same features (like email) without me building something specific.

This is why I choose Adobe AIR. I can easly save and load the patterns to files on the hard drive. No server side script is required. The only requirement is that the computer has Adobe AIR, or at lest Flash. Everyone has flash (except my iphone) so that's not an issue. (More specifically, my girl friends old laptop has flash.)