

Show HN: Our first iPhone app, built entirely in JavaScript - yosho
http://ravn.com/getapp

======
stevenou
Hi, I'm the CTO for RAVN. When we decided to jump into the mobile dev game no
one in our company had any experience with Object C or Android dev. We knew we
wanted an iPhone app for sure, and probably an Android app eventually. I had
taken a brief look at Objective C previously, and coming from Ruby/Rails, it
looked less than trivial (memory management?! I hadn't done that in 10 years).
I had heard about frameworks that would allow us to use JavaScript to write
our app, and also allow for cross-platform development, so I started
researching.

I looked at PhoneGap and Titanium primarily. We ended up going with Titanium
for a few reasons:

\- As you may or may not know, PhoneGap works by creating a sort of Safari
"wrapper" that lets you write your app in HTML5 and JS. But the performance is
crappy relative to native rendering. Titanium also _used_ to work the same
way, but more recently it actually compiles code written in JavaScript to
native Obj C and Java. Clearly the benefit is speed.

\- Even though Titanium only supports iOS and Android, we didn't really plan
on ever developing for other platforms (e.g. Windows Phone, BlackBerry,
webOS).

If you're looking into developing a mobile app, I would recommend taking a
look at Titanium. To be fair, I had to write a little Obj C to hack geofencing
functionality into Titanium (if you're interested in that:
[http://stevenou.com/post/17623116547/how-to-hack-
geofencing-...](http://stevenou.com/post/17623116547/how-to-hack-geofencing-
into-titanium)).

There were lots of pros and cons to using Titanium and I'd be happy to answer
any questions.

~~~
silverlight
It's been 4 or 5 months since I switched from Titanium to writing native
Objective C myself, so things may have changed since then (but I don't think
they have). It's a misnomer to say that Titanium "compiles" Javascript to
Objective C.

Titanium lets you write Javascript that executes using JavascriptCore (a
Javascript processor that is part of iOS) on iOS, and I believe V8 on Android,
but I could be wrong on that. Then, they have bindings in Objective C (and
Java). So when you call in Javascript Titanium.window.create();, the relevant
Objective C is executed by the bridge.

This is all fine and dandy until you start doing something more complicated
than displaying a few windows. For example, our app needed to have some
complicated TableViews with highly customized rows that needed to be re-
generated on each draw. Executing the logic for that in Javascript has a huge
penalty hit.

So while I would recommend Titanium over PhoneGap any day, it is not true that
it is a "compiled to Objective C" sort of thing (again, at least it wasn't 4
months ago, and I was using at that time 1.80 which was the super-bleeding-
edge-dev build, because I had a ton of issues with random crashes in the 1.7x
series due to the Titanium Database module not being completely thread-safe at
the time).

Sorry to hijack.

EDIT: Just to confirm, 1.81 is the current "stable" release, so what I was
using 4 or 5 months ago is what is the standard now. So it does not compile
Javascript to Obj. C.

Also, for an example of the random crashes we were seeing, see:
[http://www.juliusbuss.de/web/youatnotes/blog-
jb.nsf/dx/quick...](http://www.juliusbuss.de/web/youatnotes/blog-
jb.nsf/dx/quick-tip-for-titanium-developers-use-1.8-sdk-instead-of-1.7.5-to-
avoid-random-crashes.htm)

A lot has been fixed in the 1.8x series, but at the end of the day you're
still depending on someone else's middleware to behave and not crash your app
for no reason.

In case anyone decides to go down the learning Objective C route, learning
with the excellent "Programming iOS 4" book took me about 1 month from the
first page I read to having the whole app re-written, so it's really not too
terrible. You don't have to do any of the memory management stuff anymore with
iOS 5 and ARC, either.

~~~
sjs
Titanium was a nightmare. The edit-compile-debug cycle is so slow. I ran back
to ObjC after two weeks. Development is faster and the resulting apps are
better.

It has good points too but for me it was a net negative. You couldn't insert
rows into a table view without it crashing, you had to reload the entire thing
(that was in May).

I'm amazed at the results some people get with Titanium. Maybe I was doing
something wrong, but I'm very familiar with web dev and found it intolerable.

~~~
trabianmatt
One trick that really helped with the edit-compile-debug cycle, especially on
iOS, was to run the app from the command line instead of using Titanium
Studio. I set up a Rake task that would run the app and then listen for a
timestamp change to tmp/restart.txt, at which point it would restart the app
within seconds. I already had a vim command for touching that file (it's used
by Passenger for a similar purpose) so all I do while developing is press a
key combination and wait for the simulator to pop back up. Very fast.

------
d2ncal
I am the founder of <http://theicebreak.com>

We have built our app ( Icebreak for Couples -
<http://itunes.apple.com/app/id476063944> ) using Titanium.

When we started building it, Titanium was very very buggy. It has since
improved, but still has a lot of really basic stuff that is broken. Their
forums have a lot of questions that have been unanswered for over an year.

Our reason for picking Titanium was basically to have an app that is just like
a native app on both iPhone and Android without writing the code twice.

We have found out that porting a Titanium app to Android is taking a ton of
effort, lot more than we originally thought. I would be curious to hear what
the RAVN team has to say regarding their Android version.

Its just not as cross-platform as we thought :(. I would be extremely careful
before picking it in the future.

Basically, if you build native apps:

Native App: iPhone=1X, Android=1X. If you want both Android and iPhone: 2X

Titanium App: iPhone=2X,Porting to Android: 0.7X. Total effort: 2.7X

Native Wins.

~~~
stevenou
Exactly the same sentiment. That's the reason we did not launch with an
Android version today. We will probably write it natively when the time comes.
Titanium has proven to be a nightmare with Android.

~~~
grobolom
Boy, do I feel you there. I've been working with Titanium since last March and
I've yet to develop some semblance of a cross-platform application. It's a
bloody mess in there.

------
gpmcadam
Care to expand on the "built entirely in JavaScript" part? Sounds interesting.

~~~
lobster_johnson
Presumably it's a "single-page web app", where the HTML page is essentially
empty except for JavaScript.

This JavaScript then performs the rendering by dynamically constructing an
HTML page with the DOM, as well as fetching data from the back end, and so on.

It's a fairly common application model these days.

They probably use PhoneGap or something similar to glue into the mobile OS
environment. (Edit: They use Titanium.)

My company is developing a very similar events app, also written entirely in
JS (PhoneGap, Backbone, etc.). There are so many challenges in making it a
smooth user experience comparable to a native app, but we've finally gotten
there.

~~~
d2ncal
They are using Appcelerator Titanium, which is a cross platform app SDK.

You write your code in Javascript, and Titanium actually generates native code
that is then compiled into an app.

------
flixic
What framework did you use?

------
draggnar
The landing page is fantastic. Super simple initially, more info if I want it.
I wish the features section was more visual.

------
bwm
I'm pretty impressed with what you can achieve by running JS in a WebView,
that said, it still is not as responsive as a native app. This is one of the
better attempts I've seen though at bridging the gap between HTML5 and native,
perhaps it just needs another year? keep up the good work!

~~~
d2ncal
It's not a HTML app, but built using titanium which is a cross platform app
sdk where u write the code in JavaScript.

One day we will be able to do this using just HTML... But that day is not here
yet :(.

------
romefort
The app looks great, congrats on that. The thing that bothers me though is
that it posts stuff on my FB timeline without my approval first. This does not
sound like a good practice.

------
joezhou
Though with titanium and phonegap you still cannot tap into the full capacity
of the phone.

~~~
catch23
they both have plugin systems that allow you to write normal objc code to do
anything that wasn't available in their apis... so if you ever needed to call
opencv code from javascript, you can do that.

------
paisible
Is there any way we can add our own events ?

~~~
hack_edu
And, either way, what is the source of the events? Are you really doing them
all by hand?

~~~
tejaswiy
I'd like to know this too, considering you have stuff coming up in Orlando
which none of the SV startups care about usually.

