40 ms·
Swift Ported to Android
- manojlds 11y agoInteresting, in the context of Xamarin acquisition by Microsoft. Swift can very well spoil C#'s steam.
- nbevans 11y agoF# is already spoiling Swift's feathers. And F# has first class support in Xamarin.
- nbevans 11y agoIt seems two people here were left thinking "I'm going to down vote this because the truth hurt me :(" So I am sorry for that :)
- Touche 11y agoI would say that React Native is the biggest threat there.
- mixedCase 11y agoDoesn't perform well enough outside of high-end devices.
- mwcampbell 11y agoDo you have anything to back that up?
- seivan 11y agoRun some lists with images on them on iPhone 5. Anecdotal, and I am sure you can dig into metal to improve performance, but out of the box, it's kinda poor. I still like React and I'm hopeful React-Native will improve.
- mwcampbell 11y agoThanks. I wonder how much of that is due to the fact that JavaScriptCore can't use JIT compilation when running in an iOS application other than Safari.
- andrewjl 11y agoAs of iOS 8 that's no longer the case. JSC JIT compilation can be used in native apps. (It's also used by WKWebView.) http://trac.webkit.org/wiki/JavaScriptCore http://trac.webkit.org/wiki/JavaScriptCore "JavaScriptCore is an optimizing virtual machine. JavaScriptCore consists of the following building blocks: lexer, parser, start-up interpreter (LLInt), baseline JIT, a low-latency optimizing JIT (DFG), and a high-throughput optimizing JIT (FTL)."
- DerekL 11y agoApps can use JavaScriptCore, and JavaScriptCore can use JIT, but these can't happen together, because third-party apps aren't permitted to execute writeable memory. http://stackoverflow.com/questions/22281265/is-javascriptcore-framework-on-ios-7-using-jit-compilation http://stackoverflow.com/questions/22281265/is-javascriptcor...
- andrewjl 11y agoThis is good to know. Looks like the only way to make use of JIT (by someone who isn't Apple) is to use a WKWebView to execute the JS.
- ewmailing 11y agoI haven't used React Native, but I've done quite a bit with native bridging with JavaScriptCore and v8. If your performance bottlenecks are crossing the Javascript-to-native boundary, JIT can't help you. And crossing the bridge boundary isn't the cheapest operation.
- mwcampbell 11y ago
- fotidim 11y agoAs long as React Native requires the developer to use Javascript to write his code this is a no go for the sane of us.
- miguelrochefort 11y agoSwift isn't a significant improvement over C#. Also, keep in mind that C# benefits from the whole Microsoft ecosystem, which includes Visual Studio. Beyond the language, what's even more important is the application model. That's where frameworks like React Native have the edge. This might change if Microsoft upgrades Xamarin.Forms into full-blown Universal Windows App support (think WPF on iOS and Android).
- untog 11y ago> C# benefits from the whole Microsoft ecosystem, which includes Visual Studio. Both good and bad. Visual Studio isn't cross-platform, for example.
- kbenson 11y agoWell, Visual Studio Code[1] is, so it may be coming in the future. 1: https://www.visualstudio.com/en-us/products/code-vs.aspx https://www.visualstudio.com/en-us/products/code-vs.aspx
- untog 11y agoThey're entirely different products, Code is built from the ground up. So I'm not sure it makes a cross-platform Visual Studio more likely.
- kbenson 11y agoI would say the fact MS is shipping products on Linux, considering their historical stance, makes it more likely, but your sentiment is probably correct in that it may not mean it is likely. Ten years ago I would have laughed at the idea. Today, I have to think quite a bit more about whether it's likely.
- st3v3r 11y agoI would not use the existence of an editor built on web technologies as opening the possibility that something as entrenched in Windows as Visual Studio would be leaping to cross platform.
- wsc981 11y agoI would expect this just to be basic Swift support including -perhaps- the Foundation library (String, Array and other "low level" functionality). I don't think this Swift port has currently any easy way to create apps with a graphical user interface using some sort of Java bridge. So compared to Xamarin, using Swift for Android apps would be pretty limited. But please correct me if I'm wrong.
- stormbrew 11y agoSwift String, Array, etc. are not part of Foundation, they are part of the swift runtime library. They have mechanisms for converting to and from NSArray/NSString representations, though (and because of that, their internal structure is quite similar). But that mechanism is disabled in Linux (and obviously I assume Android).
- JonathonW 11y agoThat's correct-- Swift's native String/Array/etc. are part of Swift's native stdlib. NSString/NSArray and friends (along with the bridging code to go between them and the Swift stdlib types) are part of the open-source Foundation, though. Eventually, that should be present in any reasonably complete Swift runtime environment-- it includes APIs, like networking and date/time handling, that would typically be considered essential but aren't part of Swift's stdlib.
- wmil 11y agoPeople focus far too much on different languages. The fact that Android and iOS have very different UI libraries is usually a much bigger problem. Xamarin's big selling point is a cross platform ui library.
- leonatan 11y agoLowest common denominator. Terrible for UX for everything but the most basic UI designs, sorry. Each platform requires UI work to make it really fit the platform in question.
- Harimwakairi 11y agoTrue, but Microsoft is such an enterprise company that it fits their customer base really well (e.g. "I don't care if it's pretty, I just need an inexpensive-to-build app for my 3,000 workers that runs on either platform").
- leonatan 11y agoI get that. But I also think that companies are slowly understanding that UI and UX matters. Even in the enterprise sector.
- systems 11y agobut i would say for writing business apps, this isnt really an issue most business users would accept that their apps, look slighly ... unlike common apps on the platform
- LeoNatan25 11y agoWhich users? Admins don't care about UX, they care about ticking checkboxes to appease management. End users are people like you and me, they want quality from their software. They may be forced to work with less then stellar software, but that does not mean they accept it.
- josephearl 11y ago
- partiallypro 11y agoWhy? Microsoft will likely offer Swift support in the UWA platform soon, they already support Objective C. I suspect they will announce Swift is now supported under project Islandwood at Build.
- manojlds 11y agoMy comment was on C#, and not Microsoft.
- skrowl 11y agoC# devs like myself are interested in Xamarin are interested because they don't have too learn new language / tooling to do mobile dev. Learning Swift isn't any more appealing than learning Objective C.
- michaelwww 11y agoI care about syntax so Swift is far more appealing to me. Compare print("Hello, world!") in Swift to Hello World in Objective-C, which the article jokingly calls "gibberish." https://www.binpress.com/tutorial/objectivec-lesson-1-hello-world/41 https://www.binpress.com/tutorial/objectivec-lesson-1-hello-...
- Aleman360 11y agoIt would be great if Swift could target .Net Core.
- michaelwww 11y agoI did a little googling because you sparked my curiosity and it's happening. “Silver” brings Apple's Swift language to .NET and I found at least one mention of Silver and .NET Core.
- V-2 11y agoFar from likely. For those fed up with Java, Android has Kotlin already.
- insulanian 11y agoJust my thought.
- akerro 11y agoInteresting, but even Apple doesn't use switf on iOS. So is there really a point?
- rimantas 11y agoWhat?
- Smudge 11y agoWasn't a very useful comment, but what I think he/she meant was that Apple doesn't actually use Swift much in its own apps: http://appleinsider.com/articles/16/01/18/apple-making-sparse-use-of-swift-in-its-own-apps-engineer-claims http://appleinsider.com/articles/16/01/18/apple-making-spars... A lot of devs take this to mean Swift should be avoided for now. Edit: To be clear, I don't agree with this sentiment! Swift is awesome. Just trying to clear up the parent comment's confusion!
- atemerev 11y agoThere is a difference between "starting a brand new app on Swift" and "porting a long-existing Apple app to Swift". How many new apps Apple had started after Swift announcement?
- alblue 11y agoSwift 3 is expected later this year with a fixed ABI. Once that happens we will start to see Swift-only APIs being made available for iOS frameworks. Most of the existing apps aren't written in Swift because they predate Swift's creation. The balance will change over time.
- leonatan 11y agoDon't count on Swift-exclusive APIs anytime soon.
- rimantas 11y agoWWDC app was done in Swift, IIRC. Not the core app by any means, but still.
- ungzd 11y agoWhy Android requires special support? Isn't it just linux with quite standard libc and ABI to interact with Java counterpart?
- krschultz 11y agoAndroid uses Bionic libc which has its quirks. The Android kernel also has several patches that were at one time quite controversial, though many have moved upstream to the mainline.
- blasteye 11y agoIts not just quirks, but bionic doesn't support all the libc apis. For example, bionic does not support pthread_cancel.
- sspiff 11y agoIf you look at the changes, you'll see most things are pretty simple: * CMake files are expanded to handle an Android target. * Code that checks for specific defines or values like __FREEBSD__ || __LINUX__ now have an added condition to also check for __ANDROID__. * Some tooling scripts to integrate adb into the Swift SDK. * Some minor fixes elsewhere. So, special support is a really minimal set of changes that any platform would need.
- ewmailing 11y agoIn addition to the Bionic short-comings already mentioned here, there appears to be other work to deal with the fact that things must be cross-compiled in a way that you can build a compiler for your host machine, but generate Android binaries (and for each architecture). Also, there are also a bunch of support things for libICU which is not an official component on Android we are allowed.
- pjmlp 11y agoNo, for example UNIX IPC isn't available. Google has ripped most of the stuff they see as fluff for Android. Edit: Any C and C++ API not listed as stable and public on the NDK docs is not guaranteed to exist in all devices.
- deleted 11y ago[deleted]
- bsimpson 11y agoUI in Swift is heavily tied to Cocoa, right? What tools exist to draw UI in Swift on another platform?
- mikeash 11y agoSwift doesn't have the slightest concept of UI. If you want to do UI work in Swift, you use whatever UI frameworks are available on your target platform. Since Swift interoperates very nicely with C and Objective-C, those frameworks can be written in those languages and still be usable from Swift. On OS X the framework happens to be Cocoa, but Swift isn't in any way tied to it. On Android, Swift will likely be in the same position as the NDK, which isn't a great place to be for UI, but it's doable. You'll be able to make the same UI calls you'd make from C code.
- azinman2 11y agoAnd that there in is an issue. Android will never have a complete ndk API parity with Java. They've made this clear, and would be difficult since the Java API is implemented in Java (it's not a wrapper of ndk).
- fotidim 11y agoDon't expect to write entires Android apps in Swift. The best thing we can hope for is sharing crossplatform code among iOS, Android etc. And with Foundation ported this is fair amount of code.
- h8er4fun 11y agoYeeey! White shit ported to green shit!
- V-2 11y agoSurprised noone mentions Kotlin. It's quite Swift-like, backed by JetBrains (Android Studio is based on their IntelliJ Idea), and 1.0 has only just been released. It has full interoperability with Java. Given the above, I don't see much point in using Swift, unless it's one of these projects that are about proving a point (nothing wrong with that and often very interesting).
- kennywinker 11y agoTwo points for using Swift on Android: 1) shared code between your ios, mac, and android apps. 2) you already know swift. That said, there is always a cost to using a non-standard language to develop for a platform. Things like having to translate documentation as you read it, friction between system libraries and your languages standard library, etc. I've not looked at Kotlin in detail, but I wonder how much that friction is reduced because it's java-based, or if you'll experience just as much friction using Swift on Android as you would using Kotlin on Android. Worth evaluating if you're starting a project 6 months to a year from now as the Swift tooling for Android starts to mature. As it stands now, I would have a look at Kotlin, but almost definitely write any projects started today in Java. Swift is nowhere near ready, and the advantage of writing in the platform's "native" language usually outweighs any benefits there are to using a "better" language.
- izacus 11y agoThe alternative of course being C++14 with first party support for each OS out there and maturer ecosystem.
- on_and_off 11y ago>friction between system libraries and your languages standard library Well, that's the thing : Kotlin emits bytecode. It is entirely interoperable with Java. All the Java APIs of the platform are accessible in Kotlin. Swift on the other end can only target the NDK, which limits it to a very specific niche on Android.
- drdaeman 11y ago
- V-2 11y agoSurprised noone mentions Kotlin. It's quite Swift-like, backed by JetBrains (Android Studio is based on their IntelliJ Idea), and 1.0 has only just been released. It has full interoperability with Java. Given the above, I don't see much point in using Swift, unless it's one of these projects that are about proving a point (nothing wrong with that and often very interesting).