Apple’s iOS7 Native JavaScript Bridge
strongloop.com
strongloop.com
Since when is Objective-C proprietary? Apple's given it a few non-standard extensions (i.e. blocks) but that doesn't make it a proprietary language. GCC and Clang are open source.
And proprietary doesn't mean narrowly used. Also open doesn't mean widely used. Bringing Cocoa was a good trial, but doesn't make the text correct.
It's true that ObjC itself isn't what's proprietary, but Cocoa and Cocoa Touch are.
AFAIK, the only difference to Safari was JIT compilation support. Because iOS doesn't allow executing dynamically generated machine code in 3rd-party apps for security reason.
Does iOS7 support JIT compilation on JSC embedded in any app? If it supports JIT, that could be a big news, because it means Apple finally allowed dynamically generated code in 3rd-party apps, but I don't think the day will come.
And personally, I don't see any benefit from JavaScript apps. If someone claims JS or any third party frameworks are better than Objective-C for iOS app, I would like to ask these things. (could be offensive, but these are actually how I feel from those claims)
Does it offer better auto-completion? Does it offer better syntax/semantic/type checks? Does it offer better debugging aid? (like GDB's execution rollback) Does it offer better accessibility to any platform features? Can I use new features immediately? Shouldn't I wait for 3rd party patch? Profiler for device and simulators? How's low-level access? If I have some trouble, how can I fix it without knowledge for lower-level (Cocoa/Darwin)? If I want to use C-based DSL? Is it safe for AppStore approval? What's the benefit of using open language on proprietary platform?
I mean, what's better with JS than Objective-C with Xcode?
If it can't offer any of those stuffs, it means it's at least 10 times less productive = 10 times more cost.
Well, it could make sense JS app for an Android app because ADT is too sucks so some extra wrapper can bring extra productivity. But for iOS, JS stuffs only degrade productivity by extra abstraction, debugging hardness and inferior toolsets.
Not sure exactly how that would work, because permissions to allocate executable memory is given per process on iOS. But I guess they could inspect the call stack to see if the allocating call indeed comes from the built-in JSC lib?
http://oleb.net/blog/2012/10/remote-view-controllers-in-ios-6/But I doubt what will drive Apple to improve JS performance. Because making people to use Objective-C is a lot beneficial to Apple.
But I don't think it is true that this strategy is actually more beneficial to Apple. Developers want to support multiple platforms, and the least expensive way to do that is often HTML5. That's why PhoneGap is popular, despite the poor JS performance. The extra cost of doing separate apps is ultimately paid not only by third party developers, but by Apple as well. To make a long story short, encouraging a cross platform environment would allow good developers to make higher quality apps.
Much as I dislike Apple these days, the difference between iOS and Android is such that I have trouble maintaining a straight face when I hear them compared. They don't need to compete on app availability.
There is no reason not to have JIT or WebGL in a WebView other then apple not wanting you to, even though this was the original vision of the platform.
Though I have used Eclipse for a while a few years ago, now I really can't go back to there.
Cross-platform portability, for one. I know it's a long way off, but being able to use JS as a first-class language on all mobile platforms would be a fantastic step forwards.
And why should we step to a language which cannot offer any benefit? Even if it happen, it seems just a huge step backward.
For portability, I don't think JS is portable. Because portability doesn't come from a language. It comes from implementations by platform vendors. It's purely up to how platform vendors support the compatible language and feature set implementation. JS itself has nothing special in portability. Though all the browser vendors are supporting JS, it doesn't mean native platform vendors are interested in JS.
For the real serious portability, I think the only choice are C/C++ which are the CURRENTLY AVAILABLE de facto portability layer on ANY platform while keeping most of the benefits I mentioned. Including mobiles, desktops, servers, game consoles, embedded devices and even on web-browsers. And also for any new unknown future platforms. C/C++ support is virtually promised due to its superior range of existing portability.
And intermixing them with Objective-C is literally natural, and far easier then JS.
Near the end he sets up a scene, physics and tap events to create new objects on the screen with a few lines of JavaScript. All of the heavy lifting is handled natively in iOS SpriteKit and it runs at 60 fps.
It's worth noting that there are some discrepancies between that codebase and the actual behavior of the public iOS 7 framework, but if you're not doing anything too crazy it probably won't be an issue.
It is a command line tool that parses Objective-C header files (using llvm) and generates the needed intermediate "bridge" files. Internally it uses the SpiderMonkey VM (instead of JavaScript Core) The source code and the documentation can be found here: https://github.com/ricardoquesada/jsbindings
I just had a horrifying thought: Aren't apps that download code banned from the App Store? If so, would this include JS downloaded at runtime to be evaluated with JavaScriptCore? What's the conceptual difference between this and a UIWebView opening a page that has <script> tags embedded?
I take this to mean that the javascript has to be downloaded by the webkit/uiwebview as part of an web page and you can't supply the javascript externally if you get if off the network.. There is a lot of confusion online on this point(some people disagree) but that is my understanding.
It looks like there is a way to get the JavaScriptContext of a UIWebView using KVC, but it's not clear if that is "undocumented" and therefore private, because the whole framework is basically undocumented.
GamePress, a drag-and-drop game editor does this. Featuring an "Arcade" where you can download others' games.
And Editorial, a Python-based writing tool allows one to download and execute "workflows," which include Python scripts.
We were asked by Apple to remove code sharing features from our own app. I am hoping that they are no longer enforcing this policy.
http://iao.fi/myposts/uiwebview
The author is claiming the difference would be about 5x. I think that's reasonable.
It reminds me of a Java programmer I used to work with who constantly said he was "hydrating" his objects. I kept wanting to tell him he wasn't sounding as cool as he thought he was.
It's quite sad that this comment is currently the top comment, in an article that raises quite an important topic for the JS and iOS developer communities. As much as I loathe the "hn is turning into reddit" crowd, this is much worse. HN is turning into a criticism machine that when it can't find anything worthwhile to criticise, will literally criticise anything at all rather than elevate a positive comment to the top.
I feel like this happens when people find the basic idea of the article (JS is now a first-class language on iOS!) interesting enough to upvote, but the article itself isn't anything exciting beyond that. The top comments are people's reaction to the articles. Right now, they're "the article keeps calling Obj-C proprietary, but it's totes not"; "that's cool and all, and here's some history, but how is this better than Obj-C"; and "here's a talk about it on youtube".
If there's more interesting conversation to be had, someone would have submitted it. You could have submitted it! I read through every other top-level comment, and didn't find any of them were particularly interesting. Is there some conversation that you think is worth having?
(But yeah, surface is a totally legit verb, makes sense in this context (bringing an Obj-C object into JS), and it was only used twice anyway.)
And I wasn't criticizing. At least that wasn't my intention. Though now I'm amused that you lament HN turning into a criticism machine by criticizing my inadvertent criticism ;)
I was just trying to understand what the author meant by "to surface" an object. Still wondering...