Swift code will run on Google's Fuchsia OS

copy from: Swift code will run on Googles Fuchsia OS

A few days ago, there was a flash-in-the-pan controversy over Google "forking" Apples open-source programming language Swift.

After a few minutes of speculation over whether Google was going to make its own special flavor of the language for its own purposes, Swifts creator Chris Lattner (who now works at Google) helpfully clarified the situation:

Google just wanted its own working copy of the code so it could make changes and then contribute them "upstream" to the official Swift repository. No funny business.

Whats more interesting is that one of those changes has already landed as a pull request to the main Swift repo: Fuchsia support (via Android Police). Google developer Zac Bowling, who helped port Objective-C to Android a few years ago, even shared the news as a reply to Lattner』s tweet:

You can also stalk Google』s code review system to check out an example Swift app for Fuchsia, which prints out some emoji and the Chinese characters for 「hello world.」 Once Google』s suggested changes to Swift are merged, that code should run.

Fuchsia is Googles not-at-all-but-kind-of-secret operating system thats being developed in the open, but with almost zero official messaging about what its for, or what its built to replace. (Android? Chrome OS? Both? Neither?) The operating systems core is written in mostly C and C++, with Dart for the default "Flutter" UI, but other languages like Go, Rust, Python, and now Swift have also found a home in

the project.

Of course, just because youll be able to compile Swift to run on Fuchsia doesnt mean youll be able to instantly port any iOS app to Googles new OS when or if it ships. While Apple has open sourced the Swift language itself, much of the iOS platform (like the UI stuff, for instance) is closed source, so code that relies on those closed Apple libraries wont be portable.

One possible future in a world where Fuchsia is an important and relevant platform for apps is that you write the "core logic" of your app in your language of choice — Swift, Go, Rust, JavaScript, etc. — and then you build a custom UI for each platform — Android, iOS, Fuchsia, Linux, Windows, the web — using the appropriate tools for each.

The alternative path could be the continued adoption of tools like Googles Flutter, or Facebooks React Native, which allow you to target multiple platforms with a single language like Dart (Google), or JavaScript (Facebook). Theres even a cross-platform framework called SCADE that allows you to build iOS and Android apps in Swift.

Its a fun time to be a language nerd, and maybe someday it will even be a fun time to be an app developer.

推薦閱讀:

Tensorlang:基於TensorFlow的可微編程語言
如何理解Scala中的借貸模式(loan pattern)?
你見過哪些令你瞠目結舌的 Scala 代碼技巧?
Scala 是一門怎樣的語言,具有哪些優缺點?

TAG:编程语言 | Swift语言 | Fuchsia |