I am currently developing apps for the iPhone and iPad with Objective-C. I found some code related to using JavaScript in the iPhone.
Can we create apps more easily and accurately with the help of JavaScript?
Does Apple approve apps created at least partially with JavaScript?
How should one begin learning JavaScript?
Are there any tutorials that can help me to understand and learn JavaScript, particularly for iPhone/iPad programming?
Web Apps
Web Apps are highly optimized special websites that are accessed from any device but still look and feel like a full-fledged application. An early example would be GMail. Here is an old blog post by jQuery's John Resig on early web app development.
1. Can we create apps more easily and accurately with the help of Javascript?
This is a bit mis-leading as the intents may be different. The goal of web apps to hit the widest possible audience with minimal effort, however, you are restricted to non-native functions.
Native functions include use of the device hardware such as camera, gps, touching other apps, notifications etc. There are several libraries that provide a wrapper around your web app to expose these underlying calls but then you must do that for each device. Libraries include: Phonegap, Titanium.
2. Does Apple approve apps created at least partially with JavaScript?
Most certainly! They even have a special section. With most webapps it is just a bookmarklet the user drags to their home screen for quick access. If you want to do the true app in the store you will need a wrapper library as mentioned before to package your app together.
3. How should one begin learning JavaScript?
Out of scope for this question, but Douglas Crockford is one of the better teachers, he has a multi-part video series as well as a book to get you learning the "good parts".
4. Are there any tutorials that can help me to understand and learn JavaScript, particularly for iPhone/iPad programming?
Honestly, it would best to learn javascript first, as it is a prototypical object based puzzle then worry about how to utilize the various frameworks for best mobile performance.
Adding 5. What are some javascript mobile frameworks?
jQuery Mobile
Dojo Mobile
Sencha (Ext) Touch
Wink
iUI
These are just the most common but I would browse each of them a bit as jQuery, dojo and sencha have different approaches on how javascript should be used.
Can we create apps more easily and accurately with the help of JavaScript?. Yes and No. Javascript will allow you to write loose code and draw from a wealth of code floating around, it is less technical than writing in Objective C, however the UI will be less responsive than native and quite a bit more buggy. My advice is if you your not proficient in Javascript then "don't go there".
Does Apple approve apps created at least partially with JavaScript? Apple will frown upon this and you may find that if the App is entirely within the UIWebView you may be rejected, but I have not experienced this (they do sort of state this in their guide).
How should one begin learning JavaScript? Read material from Douglas Crockford first, I really don't agree with half the stuff he says, but to a complete beginner then he will enlighten you. Also start playing with jQuery. Manipulating HTML is painful and this will save you a lot of pain.
Are there any tutorials that can help me to understand and learn JavaScript, particularly for iPhone/iPad programming? You will be essentially be writing for a Safari browser (webkit). Your standard jQuery will get you along the way, but one very important piece of advice - Objective C isn't simple but that doesn't mean that Javascript is. designing UI interfaces for a mobile device will definitely cause you headaches - be under no illusions, even with mobile frameworks/libraries like JQTouch, Sencha and jQueryMobile you will feel the pain!
Good Luck :)
I cannot give you much advice on 1 and 2 except that I've worked on quite a few hybrid apps for iPhone where a webpage was displayed in an iPhone app.
As for questions 3 and 4:
A good place to start learning Javascript is:
http://eloquentjavascript.net/
More advanced sources are:
JavaScript: The Good Parts by Douglas Crockford (must read as mentioned above)
Professional Javascript for Web Developers 2nd Edition, Nicholas C. Zakas
Since the iPhone and iPad use the Safari browser (webkit) you can use Javascript to it's fullest.
Related
thanks kindly for your time and attention. I recognise this is a long shot but I'm hoping someone might be generous enough to relay some advice or guidance. I am in the beginning phases of researching how I might build an app for a mobile device, using javascript and related tools, libraries and packages. The concept for the app is that it will access the device camera, recognise faces, and overlay animated AR assets onto the device display. However, I want users to couple their phone with a wearable headset, and use the app through a split screen VR style display. I assume I'll need some sort of VR wrapper for the core AR application. At the moment, I am focussed primarily on the graphical display and UI aspects, so that I can build a proof-of-concept to test whether the idea is even viable. I recognise I may be misguided to attempt this in javascript rather than native mobile languages - if this is the case, I would welcome any opinions on the matter. I'm asking about javascript because that's what I know, basically.
Thus far, I've been reading about various libraries such as WebXR, Three.js and others. I assume I'll need to use React Native, though it's not easy to get a clear sense of whether I should even be trying to achieve what I want using javascript. I have no code to show as yet.
Additionally, I recognise there are similar questions already posted to the forum - for example, this one: VR+AR on mobile phone.
I haven't found any recent threads that address this specific set of requirements so I do apologise if I've missed something. If there is info on the forum, grateful if someone could point me to the relevant thread. At the very least, thanks for reading. Cheers, all.
I found Snap's Lens Studio extremely intuitive and powerful. It provides templates for feature recognition, tracking, and physics. It also provides advanced controls for custom creative. I would also expect it to receive future feature development support. It can be monetized.
...or do you want to expose yourself to more computer vision terminology and patterns? Try searching CodePen or CodeSandbox for features such as: MediaPipe, OpenCV, face detection webcam. But the overhead of a VR/AR app is probably best described in an O'Reilly book or John Carmack keynote speech. Topics like pupil distance, foot tracking, and predictive tracking.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am an experienced AS3 programmer, and I've done Flash apps and games on the browser and on mobile (via Adobe AIR, e.g., on Android).
I am about to start developing a game (basic 2D platformer with pixelart graphics. Think about Super Mario World) targeted to both web and mobile platforms. Thus I'm searching for easy deployment to these two kinds of platforms, having basically the same source code.
I'm divided between choosing ActionScript 3.0 (Flash) or HTML5/JavaScript for developing this game.
My main question is, for those who've experienced the same situation before:
What is the safest way to go?
In other words, are there serious disadvantages with one of these frameworks that disallows me to develop multiplatform 2D games?
Or am I just dreaming and practical multiplatform (web and mobile) game development is not so possible? (does someone know how Rovio did it with Angry Birds?)
Here are some pros and cons that I already know:
Pros for AS3/Flash:
The state-of-art for web games.
I'm experienced with it.
(Almost) concealed source code.
On the web, it's browser-independent.
Can run as a "native" app on iOS and Android through Adobe AIR. It's not the best performance experience ever, but I know that you can get playable performances with it.
Cons for AS3/ Flash:
Performance on AIR for mobile is not optimal, so I might end up having to abandon a really cool but expensive feature (or even several features).
People are saying HTML5/Javascript will substitute it.
Pros for HTML5/Javascript:
It's possible to do Flash-quality games using, e.g., engines like ImpactJS or Akihabara.
Seems to be more stable and well supported on mobile in the future.
Deployment as native app is possible through PhoneGap, appMobi, etc.
Cons for HTML5/Javascript:
I have some basic knowledge of this technology.
Source code is wide open exposed.
Performance/behaviour is browser-dependent.
Lacks a solid framework or engine which is free of co$t$.
I've decided to forget about HTML5 for cross-platform game development, and specially for deployment to mobile.
The cons I've pointed out for Flash are much lighter than the cons for HTML5. Basically, for the pixelart kind of games, Flash on mobile performs really well, specially if using some nice engine like Flixel.
For example, the Flixel game Robo Run has great performance both on Android and Flash Player in a browser. I don't have an iOS example for the same game, but I believe it would perform as good as on Android.
Plus, Flash performance on mobile shouldn't be an increasing problem since the hardware on these devices just gets better and better.
After thinking about this HTML5 vs Flash issue for several months, I think there's no point adventuring in HTML5 cross-browser compatibility since Flash has proven to be a sort of Java for 2D games.
I think you have outlined the pros and cons pretty effectively. If cross platform and mobile web development is your top priority, Flash is a good choice. You will have all of the drawbacks you have identified.
If you use javascript/HTML such as the impact engine, you will have a different set of problems, and far less compatibilty on the web side.
However, if having the game be the best it can be, you will need to look elsewhere, because as of the present, there is no code once publish anywhere solution.
Unity 3D has good 3D and 2d mobile capabilities.
Appcellerator may also be your cup of tea.
http://www.appcelerator.com/
But in the final analysis, nothing will beat making different versions for different platforms. in terms of performance, and being best suited to the device. Be sure to evaluate how well your chosen solution allows you to monetize your app as well. You'll likely be building multiple versions just to accomodate differences in revenue models and ad serving capabilities.
=== Update ===
In March of 2012 Adobe updated flash for iOS and Android to include support for OpenGL graphics, 3D and 2D graphics are now possible using flash as a single code base for iOS and Android. The speed is good, and you also can deply the same game to web. Its a great tool. The one drawback is that flash relies on "extensions" to connect to native OS capabilites such as Intents on android or Game Center on iOS. If you plan on using native capabilities extensively, look out for this as an obstacle to development.
As ScanPlayGames said, html5 sound is a big issue. There are some neat WebGL ports though. Dominic at Impact has been doing some amazing stuff. He's got the best framework out there.
Rovio did a port using Google Web Toolkit for the chrome store.
I work for AppMobi. We've got a tool called DirectCanvas for iOS (Android will be coming soon) that increases the performance of games in the webview. One of our partners is developing a game that has the concept of Angry Birds (object A is propelled to destroy other objects). So Box2d support is there (the main thing holding us up from releasing). The performance is awesome, and the average joe doesn't know it's a webview game.
And trust me, you wont' be wasting your time doing development on mobile first for desktop then. We've got some stuff up our sleeves.
I'm a Flash games developer too and did some research on how to migrate to HTML5. There are a lot of obstacles if you come from the Flash/ActionScript3 world. One of those things is JavaScript itself - i know many people like JavaScript, but if you are used to AS3 it is hard. Another thing is the problem with sounds (as mentioned above). The most important thing is that i don't want to start from scratch and i want to use my skills or even migrate code from the past.
To make a long story short i ended up with Googles new programming language called Dart. This language compiles to JavaScript in therefore runs on all modern browsers. The most important thing is that Dart is very similar to ActiontScript3! Then i did an open source library which provides all the Flash API you need for games (The Display List, Bitmaps, Sounds, ...) - i tried to make the library as compatible as possible with the Flash API to simplify the process of porting the source of a game. In the end it was pretty easy because you only need to change a few things.
The game i have migrated:
An ActionScript to Dart comparison:
Some other samples and the link to the source:
I think a big disadvantage of Javascript is that it cannot detect picture's transparent regions so that it can stop reacting while mice hover or click on it.
Since HTML5 was released, any new solution has been created?
I have worked with some people who did a very graphics intensive HTML5 application and the worst thing was doing the sound I remember...every browser had to be done differently. Go look for some open source html 5 game frameworks where people have already done the grunt work of testing across browsers...there are some pretty good ones I think. You dont want to have to be the one QA-ing across environments.
I wonder if anyone has successfully ported a javascript engine/interpreter to iOS. I'm writing an iPhone game that I would like to use Javascript as the high-level scripting language (AI, gameplay, etc.), but to do that, I need to compile the JS engine into a static library and link it against my objectiveC program for iPhone OS. There are some candidate JS engine I'm looking at but I couldn't find any successful cases for doing that.
Here're the js engine I was hoping to use for iOS
google's V8 javascript engine
mozilla's SpiderMonkey
The alternative is to use UIWebView's Javascript callback interface, but that requires loading the entire UIWebView into memory and the experiences I heard is that it is usually slow in performance.
Appreciate if anyone had similar experiences of do this or know any references for that!
[UPDATED] as Kostis mentioned, Apple introduced JavascriptCore in WWDC 2013
There are two projects you might be interested in:
JavaScriptCore-iOS
iMonkey
It is absolutely possible to build and ship a JavaScript engine with your iOS app, see http://www.phoboslab.org/log/2011/04/ios-and-javascript-for-real-this-time. Titanium does that, too: https://github.com/appcelerator/webkit_titanium/tree/master/Source/JavaScriptCore.
Also see http://www.phoboslab.org/log/2011/06/javascriptcore-project-files-for-ios.
I've also made a small app that shows how to use JSC on iOS: https://github.com/jfahrenkrug/AddressBookSpy
Enjoy.
For future viewers, now there is the JavaScriptCore framework, introduced in the new iOS 7. It does magic! Wrapping, unwrapping values from/to JS/Objective-C, calling functions, callbacks, everything!
Unfortunately, documentation is really poor at the moment. You can find a presentation from the WWDC 2013 event and some more info in the header files (cmd+click on the header file name in Xcode). There are also some tutorial around the internets which just copy what the guy in the WWDC presentation does.
I've used it for one of my projects, it's really powerful. The only think I didn't like is that it passed objects from JS to ObjC by value, i.e. reference was lost. There might be a workaround for this, but I couldn't find anything without proper documentation.
Hope this will help someone :)
Take a look at the open source project Ejecta, which embeds JavaScriptCore. It provides the HTML5 canvas API, and uses OpenGL & OpenAL.
If you eventually want to port your game to something other than iOS (or you have other reasons to avoid Apple's proprietary interfaces) you can use MuJS. It's a small library providing a JavaScript interpreter that is easy to embed and extend.
There are alternatives to developing for iPhone besides the native Objective-C API. In particular, there are CSS/Javascript based solutions such as the iUi Framework.
Can you write successful iPhone apps with CSS/Javascript? Does Apple approve such apps? What are the advantages and disadvantages of using this approuch?
Thanks in advance.
(1) You can write successful apps with CSS/Javascript. The first generation of iPhone apps were all CSS/Javascript.
(2) Apple routinely approves such apps.
(3) The advantages are that you can leverage your existing knowledge of CSS/Javascript to write apps without having to learn a new language and a new API. The disadvantage is that such apps are not as fast, flexible and powerful as compiled apps. It is exactly the same situation as on a non-mobile platform. Webapps do not compare to apps written with the system specific API.
However, in some cases they can be almost as good. For example, if the main purpose of your app is to interact with a specific web site, then a CSS/Javascript app will probably perform just as well as a compiled one.
There's not really any question as to the "best way". There's just a way; that is, using UIKit and Obj-C, with OpenGL ES for games.
There are some other approaches, but they are generally, well, not so good. Developing applications for the iPhone using CSS/JS is a bit half-assed; but doesn't really require apple approval; seeing as how they are just web apps.
If I were to write a commercial (=sold for money) app for Mac OS X (not iPhone) would it be wise to do so in Javascript with JSCocoa? I know Javascript by heart but next to nothing about Objective-C and it scares me. Any thoughts?
OTOH, I can always dive into Objective-C. But still, this looks like a nice shortcut. Or is it too good to be true?
Objective-C is such a relatively small part of learning Cocoa.
Most of the challenge of learning Cocoa is learning the patterns and APIs of the framework. Doing so through a language bridge -- be it JSCocoa, MacRuby or PyObjC -- just adds a layer of complexity and impedance mismatch that will ultimately cost you time and incur bugs.
If I were you, i'd be thinking about the costs of each approach. If you take the JSCocoa route, you save time not having to learn Objective-C. Conversely, if you take the Cocoa approach, you burn a bit of time learning the new language, but will likely save a fair bit of time simply because you are using a mature, well integrated development platform for the whole development process. Also, it seems likely that it will be at least moderately harder to debug Cocoa issues, as you've got an extra less-proven framework abstracting you back from it.
I asked a similar question on here a few weeks ago - QT and C++ vs Cocoa and Objective-C for native application development - Qt4.5 vs Cocoa for native Mac UI.
I decided to go with the learn Cocoa & Obj-C route, and have been pleased with the outcome. X-Code is a strong development environment, and it's integration with Interface Builder is excellent. The Apple documentation is great, and there are a heap of tutorials floating around on the internet for all of the more off-the-beaten-path bits.
I was also concerned with learning Objective-C, and initially tried to avoid it by pushing calls back into C++, but it turns out that it's additions to the C syntax are easy to get your head around, and again, the Apple documentation on the language itself is top notch.
Hope this helps!