Eight months after Apple debuted Swift, a new third-party implementation is extending the programming language beyond iOS onto Android and .NET.
As new programming languages experience rapid spikes in popularity and adoption, the development communities around them often emerge to fill gaps in the tool chain the creators hadn’t yet addressed. It’s a natural cycle in language ecosystems that’s birthed companies like Xamarin, whose Mono implementation filled the gap in cross-platform .NET and C# tooling, and the same process resulting in Silver: a compiler and development environment for writing code in Apple’s Swift language on Android, Java, Mono, .NET and the OS X Cocoa APIs.
Developed by RemObjects Software, Silver is currently in beta, but the free compiler and tool chain are built on existing RemObjects infrastructure, such as its Oxygene language and C# compiler tool chain, both currently at version 8.0. According to RemObjects chief architect and CEO Marc Hoffman, the idea for Silver materialized soon after Swift said “Hello, World.”
“We were intrigued and excited by Swift pretty much the moment that Apple announced it last June,” he said. “Given the kind of adoption Objective-C has seen in the past purely by being Apple’s language of choice, often in spite of many people not liking it as a language, it was clear to us that Swift would be important and take off.”
RemObjects has been developing cross-platform languages and compiler technology since 2002, and Silver represents the third language implementation in the company’s Elements compiler tool chain, which integrates with Visual Studio 2013 and 2015 for Windows developers. Silver comes with RemObjects’ custom Fire IDE for Mac developers.
In a similar light to Mono, Hoffman said Silver allows developers to focus on one language and one development environment that they can use beyond Apple’s platform alone.
“Apple’s Swift tool chain is great if you’re developing for Apple’s ecosystem only,” he said. “These days, many developers need to target multiple platforms in some shape or form, whether they’re also building an Android or Windows app, or have an iOS app that needs a back-end service. And for their non-Apple projects, developers need to learn a different language, and a different IDE and tool chain.”
A cross-platform implementation that’s not cross-platform
The Silver website makes a point of stating that while the implementation supports multiple platforms, it is “decidedly not cross-platform.” Hoffman said that in addition to being a rich, full-featured language, Silver would be especially interesting to developers who want to leverage shared code between applications for different platforms.
“While we explicitly discourage people from writing ‘cross-platform apps’—that is, one single app that just gets built for each platform and runs everywhere—there’s still a lot of ‘business logic’-type code that can be shared when building dedicated apps,” he said. “For example, if you are writing a mobile app for iOS, Android and maybe Windows Phone, Silver would encourage you to design each app from the ground up for the respective platform. But back-end code, for example for communicating with your servers, modeling your internal data, or performing calculations—depending on the purpose of your app—can easily be shared between the apps. You don’t need to rotate between different programming environments. For example, you might be writing an iOS app and the back-end server in ASP.NET—both using Swift, both in the same IDE.”
In Visual Studio, Silver acts as a Swift language option within the existing code editor, but extends Swift code capabilities with additional tooling. Silver integrates deployment support to Android devices, iOS devices and Mac OS X machines from within Visual Studio, and provides debugging support for Android, Java and native Cocoa.
“It’s just a different language, and different target platforms, but a lot of the core knowledge developers have will carry over,” Hoffmann said. “As a developer, you need to learn, understand and appreciate each platform individually. And then you need to design an application for that platform with that in mind. Silver is designed for developers who work in this mindset.”
Silver also includes an abstraction library called “Sugar” that provides APIs for common tasks to be shared across platforms. The library provides what Hoffman described as “toll-free bridging” between platform-specific classes, to connect shared code with platform-specific code.
Keeping pace with Swift
In developing more advanced capabilities for Silver, Hoffman said RemObjects plans to reproduce the Swift language as it is defined by Apple as closely as possible in the same way the company treats its C# compiler.
“We’re not trying to redefine what Swift is, or drive the language forward on our own,” he said. “That’s not really our place to do. Our goal is to improve these compilers mainly along the lines set forth by their owners—Apple and Microsoft, respectively. C# 6.0 is coming soon and has many exciting features, most which we already support. And Swift is evolving rapidly as well: Apple just shipped the first beta for Swift 1.2, and we already have support for the changes and new features in our compiler.”
(Related: Apple’s Swift gets major release)
One beta feature RemObjects is working on for Silver is exception handling, a feature iOS doesn’t currently support, in order to improve .NET and Java integration. The company is currently focused on fixing front-end bugs and testing its full tool chain against Silver support, along with expanding Silver’s Swift base library with additional classes and functions. The library will be fully open source upon release.
Hoffman stressed that ultimately Silver gives developers more choices, without complicating the code of whatever language Swift compiles to.
“We hope that developers will accept Swift as a valid language choice for the .NET and Java platforms,” he said. “People often conflate .NET and C# as a set of choices that go together. But working on the .NET platform never meant you had to necessarily use C#; .NET has always been very language-agnostic. The same goes for the Java/Android platform. There are many languages available for the JVM already, and now Swift is as well. Writing an Android app doesn’t have to happen with the Java language.”
More information about Silver is available here.