Paul Krill
Editor at Large

Ruby on Rails-style development comes to Apple’s Swift

news
Feb 25, 20162 mins

The Swifton framework shares the model-view-controller development pattern with Rails

Apple’s trendy Swift language is getting a Web framework inspired by the popular Ruby on Rails MVC framework.

Open source Swifton, running on Mac OS X and Linux, is in an early stage of development. But it’s already picking up traction, attractibg more than 1,200 stargazers on GitHub within a couple of days of its release this week, said Swifton’s main developer, Saulius Grigaitis, founder and CTO of Ruby on Rails and Swift consulting firm Necolt.

Swifton shares the model-view-controller development pattern with Rails. For the model aspect of the framework, Swifton is ORM-agnostic. “Swifton comes with simple in-memory MemoryModel class that you can inherit and use for your apps,” Swifton’s Github documentation states. Similar to Rails, Swifton features an ApplicationController class. A controller in Swifton inherits from ApplicationController, which in turn inherits from the Controller class.

For views, Swifton backs Mustache-like templates via the Stencil template language. The view is rendered with controller’s method render(template_path, object), according to documentation. Views are loaded from the views directory by default, with developers able to change the default setting. “Currently, views are not cached, so you don’t need to restart server or recompile after views are changed,” the GitHub page notes.

With Swifton, Grigaitis said he wanted to build a framework inspired by Rails because he is a big Rails fan. “I [have used] Ruby on Rails for 10 years to build large-scale systems for successful startups, and I don’t think there’s something significantly better then Rails currently. Sure, one can try to invent something really new, but chances are really low to build something as successful as Rails.”

Grigaitis added that Swift, Apple’s successor to Objective-C that was introduced in June 2014, reminds him of Ruby but is still very different. The biggest obstacle he has come across in building Swifton has been Swift’s static and type-safe nature. “Web development is more like gluing inconsistent real-world things together — information in database, external APIs calls, data representation templates, etc. Unfortunately, Swift doesn’t help here a lot.”

Swifton is offered via an MIT license, supports JSON, and features the Currasow server, a Swift Nest HTTP server. The framework also comes with a router, although developers can use other routers. Use of Swifton requires installing the latest development snapshot of Swift from Swift.org or swiftenv.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author