homepageimage100584141orig

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

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.

IDG Insider

PREVIOUS ARTICLE

« Electric cars of the future could charge batteries while driving, using Qualcomm tech

NEXT ARTICLE

How this Indian CIO got way ahead in the fight against DDOS attacks »
author_image
IDG News Service

The IDG News Service is the world's leading daily source of global IT news, commentary and editorial resources. The News Service distributes content to IDG's more than 300 IT publications in more than 60 countries.

  • Mail

Recommended for You

International Women's Day: We've come a long way, but there's still an awfully long way to go

Charlotte Trueman takes a diverse look at today’s tech landscape.

Trump's trade war and the FANG bubble: Good news for Latin America?

Lewis Page gets down to business across global tech

20 Red-Hot, Pre-IPO companies to watch in 2019 B2B tech - Part 1

Martin Veitch's inside track on today’s tech trends

Poll

Do you think your smartphone is making you a workaholic?