Tag Archive for 'Mac'

Is it possible to create a perfect tool with AIR?

Since there’s no perfect tool for me I decided to create one myself.

If you want something done do it yourself.

Right now the only platform I can create application for without additional training is Flash/Flex/AIR. AIR looks perfect for this purpose, but I doubt flash can handle some of the features I need. Here’s the list of features from my previous post.

  • Be able to create rich text nodes,
  • Insert images, movies, audio files and PDFs,
  • Have everything searchable,
  • Tag everything,
  • Be able to sort nodes to folders and smart folders,
  • Be able to crosslink files,
  • Add small notes (as clouds) to everything,
  • Annotate PDFs,
  • Have a usable intuitive interface,
  • Run on a mac offline.

AIR can run on Mac, with Flash I can create any interface I need, I can show images, movies and mp3 files, I can edit text in a WYSIWYG mode (though I have yet to find a good one, and not only me), I can store data locally and online with full search index. But there’s huge problem with PDF support. Seriously, Flash PDF support sucks.

The plan.

First, I need to research a lot more about handling the PDF issue. If I fail to find a good solution I should probably stop and spend time learning Objective-C for native OS X programming. Right now there are several possible ways to go:

  1. pdf2swf library. It comes with C source code. The easiest way is to invoke it from command line from AIR application but this is not right. I might be able to modify it a bit and compile to SWC using Alchemy. The problem is that I don’t know C and have never tried to do anything with Alchemy. pdf2swf has some issues too, especially with fonts.
  2. Port a Java PDF library. With Flash 10 it is much easier to port a Java library to AS3, there’s even a special syntax converter and there should be AS3 implementations of core Java classes. This should be much easier than rewriting from scratch. This is what PDFCase has done, but I can’t contact its author. It is a port of PDFBox Java library. I played a bit with it but am not sure still what exactly it parses PDFs to. I am getting a lot of COSObjects and don’t know what they contain and how to work with them. Also, it takes 20 seconds to parse a 60 pages PDF file with several images. So in a port there must be a way to break the whole task into small subtasks not to hang the player. And I still have to understand how PDFBox works to start porting it.
  3. Write my own PDF parser. From what I saw PDF format is complicated. And I couldn’t find a free format spec.

Another question is what to do after I parsed a PDF file to simple instructions. I need to render them with Flash. This might be a problem too, especially with fonts.

Well, if I find a solution to the problem above the rest is pretty straightforward: prototype the interface, use Flex and Swiz to code it, fix bugs.

Afterthoughts.

I think that AIR might be not the tool of choice (see the irony?) for this type of project. I might need to learn Objective-C and code this application as a native OS X app, because there are frameworks to work with PDFs for Objective-C. For example PDFKit and SkimNotes. This might take some time but I am an experienced programmer after all. How Objective-C can be so different from ActionScript? Doubt it.

Why there’s no perfect tool around?

I like collecting stuff. Not collecting stamps or coins just for the sake of it, but gathering stuff I might need in the future. I got many topics I can research from time to time downloading PDFs and saving links. I’d say that I’m getting more pleasure from preparing to some activity than from this activity after I got all preparation done. This is my first problem.

My second problem is that I tend to forget stuff. It makes researching mostly a waste of time. Sometimes I download a file only to find that I have 3 copies of the same file in several tmp folders.

That’s why I was trying to sort everything I download… It takes a lot of time and gets complicated. Much better principle is tags. I used Leap a bit, but tags it’s using break when restoring files from Time Machine (from NTFS drive) and it is not flexible at all.

I tried Evernote and other similar apps for mac, honestly, Evernote is close enough to what I need but it lacks text formatting and crosslinking functions, it can’t create nested notebooks and can do nothing with PDFs apart from importing them.

I recently installed a beta of DEVONthink, I must say that it is more interesting than Evernote but it is indeed beta because it doesn’t even have a good WYSIWYG editor, PDF annotation bugs, but at least you can link PDFs from text notes. “Similar documents” AI function doesn’t have much use. Looking that it have been beta for a year or so we will probably have to wait another year for release.

People advised to try a Wiki. I did, but no Wiki can work fine with PDFs. Though, the whole idea of Hypertext is probably what I need. Sorting, tagging and connecting documents with ideas to form a single big idea. The problem is that I read a lot of scientific articles which are in PDFs and it’s not a case to save text to HTML for example… But, actually, I’ll try to research around converting PDFs to HTML with images. I checked how Adobe Acrobat exports PDFs to HTML and RTFs and it’s horrible. I’m not saying that it takes whole 5 minutes to export one book.

In conclusion, I still haven’t found any software which would fully satisfy me. There are applications which have several features from the set of features I need, but none does everything I want, not that I wanted too much:

  • Be able to create rich text nodes,
  • Insert images, movies, audio files and PDFs,
  • Have everything searchable,
  • Tag everything,
  • Be able to sort nodes to folders and smart folders,
  • Be able to crosslink files,
  • Add small notes (as clouds) to everything,
  • Annotate PDFs,
  • Have a usable intuitive interface,
  • Run on a mac offline.

Are these features so hard to make?

Prolog for Mac

Let’s assume that you need to set up Prolog for OS X. If you are still here let’s continue.

After reading some book from 80s about Prolog I found that language to be interesting and I decided to write some simple things in it. But I had to install it somehow on my Mac preferably without any stupid virtual machines. So here’s what I ended with.

  • All crossplatform solutions are based on Eclipse, so first of all you need Eclipse. There are a lot of versions, but I chose the one with less stuff I don’t need because I won’t use anything related to Java development.
  • The first plugin I tested was PDT which is too old and doesn’t work with Eclipse 3.5, I downloaded 3.1 but haven’t tested it because I got another plugin which works — ProDT. This is just what I need. From Downloads you should choose the smallest file.
  • For ProDT to work you need SWI-Prolog — some kind of opensource Prolog.
  • I’m not sure if SWI-Prolog requires MacPorts, but anyway I recommend you to install it. It’s useful.
  • Extract ProDT to eclipse/dropins/prodt/eclipse/plugins, run eclipse which installs it automatically.
  • After that in ProDT preferences ( Eclipse -> Preferences -> Prolog -> Compilers -> Swi Compiler ) set compiler path which is at /opt/local/bin/swipl.
  • Switch to Prolog view Window -> Show Perspective -> Other… -> Prolog.

That’s it. Now you can test if it actually works:

yes( one ).
yes( two ).

Run and write in console:

yes(X).
x = one ;
x = two.