

iPhone JavaScript Apps - tzury
http://ejohn.org/blog/iphone-javascript-apps/

======
markessien
Why waste time learning to use JS on the iphone, when you may as well just
write the app in C++ or Obj-C? At some point, you'll need to go native, and
then you've lost a portion of your time-investment. Instead, just learn it
properly, and you can always do things.

~~~
Tichy
Well to push the nasty programming aspects as far out to the edge as possible
and be able to do most of the programming in a pleasant programming language.

And the common code base for porting is another factor, too. I don't see a
great future for Objective-C, but being really good at Javascript seems like a
safe bet for a useful skill.

~~~
river_styx
What in particular do you find unpleasant about Objective-C? I find it quite a
nice language to work with, actually.

~~~
Tichy
So far I have only read the tutorials to some extent. I don't like that there
is no garbage collection on the iPhone, and that I have to write header files.
The pointer stuff looks suspicious, too, but I have not read far enough to
know how awful it will be.

I seem to remember that Joel On Software wrote once that garbage collection
gave one of the biggest productivity boosts modern languages provide.

Oh, another thing I don't like is the stupid hungarian notation of the API.

Also, it seems kind of pseudo-dynamic: if it is dynamic, what is the point of
header files and interfaces? It doesn't make sense to me.

~~~
jws
Header files are a blessing. They move many bugs from runtime to compile time.
The point of the header file is to make a contract. Sometimes that isn't
appropriate and there you can "go dynamic" if you need to, but you are moving
your errors to the runtime.

The retain/release model of object lifetime management in Objective C becomes
nearly automatic for the programmer. That being a dangerous "nearly", you can
still screw up.

Garbage collection is much nicer, but given the limited memory I can
understand why they didn't enable it on the phone.

Remember: You can screw up badly with garbage collected systems too, it just
doesn't result in a core dump on a desktop machine. You can accidentally leave
references to objects you will never access again (cache structures are
notorious) preventing it from being reclaimed. On a desktop that leads to a
bit of memory bloat and maybe some swapping if the app runs long enough. On an
iPhone you run out your RAM and get terminated.

~~~
Tichy
Thing is, I programmed (garbage collected) Java on mobile phones for years,
and those devices had far less memory than the iPhone. So the "it makes sense
for a mobile phone" argument simply doesn't fly with me.

Header files: Java doesn't have header files, and I am sure it provides the
same level of compile time error catching (or doesn't it?). I just deeply
resent having to write the same code twice, and I suspect the explosion of
files required doesn't make things easier, either.

There is also a personal preference: having coded Java for years, I would
simply prefer a dynamic language now, instead of Objective-C (which also has
the Java-style interfaces, I have heard - why do they need BOTH interfaces and
header files? One would be sufficient for the compile time checks, I would
think). .

