8 ms·
Building OS X Apps with JavaScript
- warcher 12y agoYou know, I understand the urge, once one has really gotten deep and mastered their first language, to try to apply it everywhere. But I really must strongly encourage the kids on the come-up to continue mastering new tools. It's not that javascript is a bad language (although that helps), so much as the industry doesn't allow any of us to rest on our laurels. This year's rock star is tomorrow's dinosaur.
- marknutter 12y agoGreat. Now master Java, C#, and Objective-C to build the same app on multiple platforms. JavaScript is the only language that let's you target every platform.
- MrScruff 12y agoThe overhead of learning a new language is pretty small. The overhead of learning a new framework is much bigger.
- zoomerang 12y ago> JavaScript is the only language that let's you target every platform Ironically, the three languages you listed - Java, C#, and Objective-C are all available on all major platforms. I could write code in any of those languages and have it run on - Windows - MacOS - Linux - Android - iOS Furthermore, the apps would all be native. That closest Javascript can come is to use the uncanny-valley of HTML5 without native widgets or performance. Frankly, Given that the burden of learning a new language is tiny, I see no reason why we should try and cram Javascript into every nook and cranny. It's a fairly mediocre language at best. tl;dr The three languages you listed are all capable of better cross platform support than Javascript.
- radmuzom 12y agoCan you write Java applications for Windows Phone 8? (without buying a third party software which allows you to do so)
- pjmlp 12y agoNo, but you can in C and C++. Not only that, certain APIs are only available if you use them.
- zoomerang 12y agoYes. Java can be compiled to native machine code via GCJ, and can expose a normal C++ Api. Whether you'd want to do this or not is another story. C# and Xamarin would be a far better choice for a one-size-fits-all cross platform codebase.
- taf2 12y agoReally? Seems like HTML/JS is the best choice for cross platform application development. These days with Chrome, Firefox and even Safari you can create really full featured applications. The new HTML5 API's are incredibly full featured. Just the other day I created an App for my daughter to helper her login to her school computers - so I decided to create a login screen and then I realized with HTML5 audio API, I can also read aloud each key press as well as an intro text so even though she can't read yet she can use the App. It's 100% JS and HTML/CSS for UI. At my job we spend thousands of hours building our native App for Android and IOS for work and it's painful - when I can open the browser and nearly all the capabilities are in browser and the browser already cleanly abstracts the process of editing UI via HTML/CSS. I've yet to find another UI framework as powerful or quick to develop in as HTML/CSS - and the performance is looking really good in the browser. Native app performance is a myth unless maybe you're writing a video game?
- vertex-four 12y ago> I've yet to find another UI framework as powerful or quick to develop in as HTML/CSS - and the performance is looking really good in the browser. Really? Until a couple of months ago with the advent of flexbox, you couldn't reliably do columns that fit dynamically to the browser window (frameworks like Bootstrap simply define three different window sizes and switch between them, rather than allowing for fluid resizing) as well as you can in every other UI framework I've used, never mind vertical layout. (See all the hacks for "sticky footers" over the past decade.)
- pjmlp 12y agoWell, C and C++ come to mind.
- tomjen3 12y agoYou are looking at a wrong problem. This isn't one language beginners as much as it is a desire not to write code twice for two platforms. Even cheap software developers are expensive, so it make sense to not make them do the same work twice.
- rattray 12y agoWhat's great about this isn't just that you can do it with JavaScript, which is much easier than ObjC, and probably also easier than Swift. It's that it's also essentially natively supported. Having futzed with PyQt and PyObjC to build a medium-sized desktop application, I never want to go back to dealing with bridges to low-level libraries again. But this looks much more manageable. Reading this code makes me think I just might write an OSX app again some day. And if CoffeeScript can compile down to it - no idea why it couldn't - even better.
- city41 12y agoWhy is this easier than ObjC or Swift? I'm a huge JS fan, and I'd still choose those two over this. The API is still very much Cocoa, and now in JS form it's even more tedious. Not sure how you'd truly debug an app written this way, and not to mention almost all docs, examples, blog posts, etc that you ever find will be based on ObjC and Swift.
- rattray 12y ago"Easy" and "hard" are always relative terms. If someone doesn't already know ObjC or Swift, they may be considered harder for that person. Not necessarily harder in absolute terms. But I'll take that as a serious recommendation!
- city41 12y agoObjC is a very small, simple language. The hard part is Cocoa. The JavaScript bindings don't address the hard part at all.
- AlexeyBrin 12y ago> ObjC is a very small, simple language Objective-C is a small language only if you already know C. Otherwise you will have to learn C first.
- 12y ago
- nnx 12y agoWill Apple allow apps written with this to be distribued on the Mac App Store? I don't see why they wouldn't, but I couldn't find a confirmation either way.
- thegaw 12y agoI haven't seen anything official, but I think you can. Mavericks introduced Code Signing for applets http://macosxautomation.com/mavericks/codesign/02.html http://macosxautomation.com/mavericks/codesign/02.html so you can at the very least distribute JS Apps. The first time someone tries to push one up to the app store for review will be interesting.
- benihana 12y agoLearning Objective-C was never the limiting factor for me writing native OS X code. The hard part about it was always figuring out the APIs. It's one of those things where if you have someone to teach you it's great, but learning on your own is time consuming and tedious and frustrating. As much as I like using JS for scripting purposes in the OS, I feel like with this, I have the same problem: namely that the cocoa APIs are massive and I have trouble understanding what's going on, even after trying to learn them three or four times in the past decade.
- FreakyT 12y agoWhat I wonder is: can this style of development be used with Interface Builder?
- sjtrny 12y agoWhy would you want that? You can programmatically defibe your interface with Swift/objective-C. JavaScript feels like a step backwards to me.
- Alphasite_ 12y agoBecause defining constraints in code is more of a faff than just doing it visually? Its also more immediate since (as far as I know) Xcode doesn't support anyform for edit and continue outside of Playgrounds.
- fatboy 12y agoIt's been possible to develop AppleScript-ObjC applications using Xcode and Interface Builder for several years. I think you define properties in the AS code that Interface Builder recognises as IBOutlets to allow you to connect it all up, so I'd expect there to be a similar thing set up for the new JS stuff.
- thegaw 12y agoYes, you can! Which is totally cool. There is a sample app written in JS that uses Xcode. They have it set up with a main.js file, they use the same ObjC.registerSubclass to create an AppDelegate. Then they have .xib for the interface. You can make the same connections from IB to the JS as you're used to. If you have an Apple Developer account, you can download the sample project here https://developer.apple.com/wwdc/resources/sample-code https://developer.apple.com/wwdc/resources/sample-code It's listed under "JavaScript for Automation Cocoa Application"
- lemming 12y agoThe really cool thing about this is that you can also use alternative languages which compile to Javascript. I develop Cursive, an IDE for Clojure and Clojurescript, and one of my users has a native app written in Clojurescript published on the App Store. He had to jump through a few hoops to get the REPL working but once he got it going he could edit code on his device live. It's really cool to see. I'm hoping to add debugging support using the Webkit Remote Debugging Protocol, which will make it even nicer.
- nowayjorge 12y agoNice!
- petercooper 12y agoThat pipe is a C bitwise OR operator. I’m not gonna pretend to know what that means. I'm honestly not being sarcastic, but I think there's something interesting about reading an enjoyable programming article by someone who doesn't know what bitwise OR is. It sorta feels like a huge reminder we've moved on to a whole new generation/level of abstraction where competent developers no longer need to understand binary. I gave a talk the other day about the future of code (think 2024 and on) and one of the biggest things out of my research was that we'll eventually not need to think about intermediate data structures in code anymore as AI profilers, VMs, compilers, etc. will be able to optimize and profile almost everything away with developers working more with specifications and constraints. I wonder if in 10 years' time a programmer not knowing what a linked list or a binary tree is will not be considered unusual either.
- peterjmag 12y agoA couple links for those who, like me, want to learn more about bitwise operators: http://www.cprogramming.com/tutorial/bitwise_operators.html http://www.cprogramming.com/tutorial/bitwise_operators.html (A decent intro to the concept of bitwise operators and what you might use them for.) https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators https://developer.mozilla.org/en/docs/Web/JavaScript/Referen... (Their use in JS.) And Peter: I'd love to watch that talk! Was it recorded? A quick search for "peter cooper future of code" brought up some references, but no videos (at least not yet).
- protonfish 12y agoI've been a programmer for 15 years (web dev, self-taught) and I don't know what those are. I think a linked list is like a JSON object, right? Yes, I am a real developer but the technologies I use don't have those paradigms. I doubt it this is good or bad, just different.
- Igglyboo 12y agoA linked list is an actual data structure, whereas JSON is just a format for storing data. The computer actually has to lay the json out in memory somehow. JSONs have keys that are strings so a hashmap or hashtable is probably more likely. http://en.wikipedia.org/wiki/Linked_list http://en.wikipedia.org/wiki/Linked_list http://en.wikipedia.org/wiki/Hash_table http://en.wikipedia.org/wiki/Hash_table