segment-pixel
For the best experience, try the new Microsoft Edge browser recommended by Microsoft (version 87 or above) or switch to another browser � Google Chrome / Firefox / Safari
OK
brand-elementsbrand-elements brand-elements brand-elements
brand-elementsbrand-elements

Technological innovation has given rise to many new languages, each offering specific features and advantages. Being in the field of software engineering, teams continuously feel the urge to upskill and get updated with the latest computer language, new-age technology and tools. Skill development in any language is a time-bound investment requiring knowledge, practice and experience. How about gaining proficiency in one language while developing skills to be able to work or understand the development cycle of different platforms? Sounds interesting? This blog covers the possibilities of using Swift on Server-side for application development.

The Evolution of Swift for App Development

Initially, Apple used Objective C to create applications. However, Objective C had some drawbacks on performance, complexity, syntax and maintenance. To overcome the drawbacks, Apple introduced Swift in 2014 WWDC (Worldwide Developer Conference).

Keeping the important aspect of performance in mind, Swift, a modern type-safe programming language was created. Swift language is among the fastest growing programming languages within the software engineering industry.

When a major update of Swift 2.0 was introduced in WWDC 2015, people thought the new language was designed to replace Objective C. But no, the language was supposed to stay long. 

Moreover, modern digital products and application development isn't just about building for one platform. With growing time, engineering teams need something that can be molded to work on different platforms. 

Having an architecture which uses a single language to build an application’s frontend as well as backend increases code reusability, saves development time and provides development interoperability through cross platform collaboration. Also, maintaining an application would become much easier. Apart from this, engineering teams, especially developers, can expand their capabilities on different platforms without having to learn a new language.

In December 2015, Swift Language, its supporting libraries, debugger, and package manager went open-source. This gained traction from many programmers. This charted the pathway for Swift usage on Linux, Android, and other platforms. Swift.org is the dedicated site to the open source Swift community, where developers can contribute and interact with each other to help evolve Swift.

However, when working on an application, it's quite often that the need for a server-side component would arise. Whether it's to store data, perform analytics, or provide levels of communication, servers become an integral part of the application’s ecosystem. Usually, when working with server-side components, it requires working with different languages. Besides having to continuously iterate and translate your ideas from one language to another can cause frustration and downtime. 

Need for Server-Side Swift

In WWDC 2016, Server-side Swift was first introduced. Now why Server-side Swift? 

Speed: One of the significant advantages of using Swift on Server is speed. It allows calling C code directly. If we compare this to Java, there is a requirement of JNI wrappers or Node.js/Python. This may require binary wrappers for any Objective C based interaction.

Server-side Swift is 2.6x faster than Objective C and 8.4x faster than Python.

The-Need-for-Server-Side-Swift-Xoriant

Type-safe:
Swift on Server promotes strong type which reduces errors and crashes at run time. Its syntax encourages engineering teams to write down clean and consistent code which can feel strict sometimes. But this provides safeguards to prevent errors and improve readability.

Memory Footprint:
Swift on Server requires just half the memory occupied by Java, and delivers the same performance. Node.js requires less memory than Java but is still more compared to Swift. It can get more containers for an equivalent amount of cash, and thus run more instances of your application. Swift is the ideal language to run on the server.

Foundation kit, Dispatch Queue and XCTest:
While developing web applications, we can make use of asynchronous libraries. 

Xcode:
Software development engineers (SDE) can step through it, add breakpoints, and have type checking, code coverage, profiling, and all those tools work on backend Swift.

Compiler Command Line Tools:
Xcode uses command line tools, so we get to know errors upfront unlike web applications like JavaScript. It is also type-safe language, that way we can handle crashes upfront.

Non-Blocking Architecture:
Apple developers have been working on SwiftNIO (a non-blocking IO architecture). It's been a base for all web frameworks available on Server-side Swift. It is an async protocol where rapid development can happen. It can handle multiple requests at a time and be very fast to provide information.

Memory Management:
Swift has efficient memory management without the overhead of garbage collection. Swift's memory management is predictable and deterministic. Compare this to Java/JVM and the other garbage-collected language generally, during which the runtime might initiate a garbage pickup pause at the foremost inconvenient moment and freeze everything when you're serving a customer request.

Since the inception of Swift on cloud, programmers are coming out with different frameworks to write web application, API, server application in swift.

Key Server-Side Swift Frameworks

Vapor

  • Vapor is the most used framework created by Taneer Nelson & Wright and introduced in Feb 2016.
  • It uses Fluent ORM framework which provides support for PostgresSQL, SQL, MySQL, MongoDB databases.
  • Leaf is the native templating engine provided by Vapor. Apart from leaf, it also supports Mustache and Markdown.
  • It uses SwiftLog for logging output.
  • Vapor is more developer-centric when compared to other frameworks as it tends to move aggressively to provide the latest update whenever a new Swift version is launched.
  • Vapor APIs and supporting libraries are majorly developed considering Swift. Hence, it appeals more to developers working on Apple products.

Perfect

  • Perfect was released on 23 November 2015 by Canadian company PerfectlySoft with years of experience in Server-side technology.
  • Perfect uses StORM framework which is built on the top of Perfect framework. It supports database PostgresSQL, SQL, MySQL, MongoDB, CouchDB, MariaDB, FileMaker, Redis.
  • It uses Mustache and Markdown for templating.
  • Apart from mentioned tools, there are a plethora of third-party tools supported by perfect for routing, templating, and email support.
  • Its libraries are closer to Vapor but do not have native route type validation and command line extension support. But it allows developers to explore Server-side Swift with third-party integration.
  • Also, updates provided by Perfect community are slower compared to Vapor.

Kitura

  • Kitura is developed by IBM. It also provides other cloud application services which can go with Kitura. It was first introduced during WWDC 2016.
  • It uses Swift-Kuery ORM framework built over Swift-Kuery, which is pluggable SQL database. It supports PostgresSQL, SQL, MySQL, MongoDB, CouchDB.
  • Mustache, Markdown and Stencil can be used for templating as Kitura does not have any native templating engine.
  • Helium logger is the library used for logging output in Kitura.
  • Kitura uses a traditional development approach. Its APIs remarkably remained stable given Swift’s own aggressive evolution over the last few years.
  • Web developers are likely to appreciate Kitura as it also has a glimpse of JavaScript, Node and Express. For example, Stencil.

In spite of having enough contents and frameworks to help initiating the use of Swift on cloud, why is Swift not yet extensively used as a server-side language? Because, Swift on Server has some pain points like:

  1. Asynchronous architecture with callbacks and async calls is a tedious part to learn. 
  2. There are no good documentation/guidelines when it comes to performance.
  3. A tool like Xcode which is unavailable in Linux.
  4. Swift on Server has basic packages but does not have advanced packages. It has a lot of things to catch up with as there are packages unavailable or abandoned.

Way Forward for Server-Side Swift

There are definite advantages on safety and performance while using server-side. But Swift still has a long way to go to be compared with more mature languages like JAVA, Node or Erlang. Apple ought to improve on certain points in order to gain a stable position amidst server-side players.

Swift on Server isn’t yet a clear winner. Although the Server-side Swift community is very open and available to help developers where needed. 

Apple is using Swift in production for services. Sponsors of Vapor framework such as Skelpo are also the most active users. Considering that those sponsors are consulting businesses, we could expect their clients to be using Server-side Swift in production for a while. So technologically, adopting Swift on Server in a small capacity, is an effective choice.

From concept and blueprint to release and end-of-life support, Xoriant teams help design and develop innovative products that run anywhere, anytime – and deliver results on spec and on budget.

Discuss App Product Development with Xoriant

Get Started

Your Information

1 + 16 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Your Information

1 + 0 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Your Information

1 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
Globally Presence
Across Americas, Europe, and Asia
All Locations
Asia
Europe
North America
global-map
16 Locations
6
8
2
asia-map
8 Locations
map-pin
Singapore
70 Shenton Way,
#13-03,
Eon Shenton,
Singapore 079118
map-pin
Gurugram
5th Floor, Tower B,
Golf View Corporate Towers,
Sector 42, Golf Course Road,
Gurugram- 122002
map-pin
Hyderabad
5th Floor, Smartworks, Block 3, DLF Cybercity, Survey No. 129 to 132,
Gachibowli Village, Serilingampally, (M) Ranga Reddy District,
Hyderabad, Telangana 500032
map-pin
Bengaluru
3rd Floor, Karle Town, Building No. 5
Nagavara Village Kasaba Hobli,
Banglore North,
Bengaluru, Karnataka 560045
map-pin
Chennai
8th Floor, Smartworks,
Olympia National Tower
Block 3, A3 and A4, North Phase,
Guindy Industrial Estate, Chennai 600032
map-pin
Pune
Smartworks 43 EQ, 14th-15th Floor,
Sai Chowk Road,
Opposite Bharati Vidyapeeth School,
Laxman Nagar, Balewadi Pune,
Maharashtra 411045
map-pin
Mumbai - Thane
8th Floor, 315 Work Avenue,
Ekatva Olethia Building,
Opposite Ashar IT Main Gate,
Wagle Industrial Estate,
Thane West, 400604
map-pin
Mumbai
7th Floor, Redbrick,
Oberoi Commerz-1
Oberoi Garden City,
Goregaon East 400063
europe-map
2 Locations
map-pin
Ireland
Grove, Fethard,
Co. Tipperary,
E91 E282, Dublin, Ireland
map-pin
London
c/o SPACES,
12 Hammersmith Grove,
London W67AP, UK
north-america-map
6 Locations
map-pin
Canada
55 York Street, Suite 401
Toronto, ON,
Canada M5J 1R7
map-pin
Mexico
Tomas A. Edison 1510-201
Ciudad Juárez,
Chihuahua, Mexico 32300
map-pin
Dallas
5800 Granite Parkway,
Suite 480
Plano, TX, 75024
map-pin
Troy
6915 Rochester Road
Suite 300
Troy, MI 48085
map-pin
Sunnyvale
1248 Reamwood Avenue
Sunnyvale, CA 94089
map-pin
New Jersey
343 Thornall Street
Suite 720
Edison, NJ 08837
All Locations
global-map
16 Locations
6
8
2
asia-map
8 Locations
map-pin
Singapore
70 Shenton Way,
#13-03,
Eon Shenton,
Singapore 079118
map-pin
Gurugram
5th Floor, Tower B,
Golf View Corporate Towers,
Sector 42, Golf Course Road,
Gurugram- 122002
map-pin
Hyderabad
5th Floor, Smartworks, Block 3, DLF Cybercity, Survey No. 129 to 132,
Gachibowli Village, Serilingampally, (M) Ranga Reddy District,
Hyderabad, Telangana 500032
map-pin
Bengaluru
3rd Floor, Karle Town, Building No. 5
Nagavara Village Kasaba Hobli,
Banglore North,
Bengaluru, Karnataka 560045
map-pin
Chennai
8th Floor, Smartworks,
Olympia National Tower
Block 3, A3 and A4, North Phase,
Guindy Industrial Estate, Chennai 600032
map-pin
Pune
Smartworks 43 EQ, 14th-15th Floor,
Sai Chowk Road,
Opposite Bharati Vidyapeeth School,
Laxman Nagar, Balewadi Pune,
Maharashtra 411045
map-pin
Mumbai - Thane
8th Floor, 315 Work Avenue,
Ekatva Olethia Building,
Opposite Ashar IT Main Gate,
Wagle Industrial Estate,
Thane West, 400604
map-pin
Mumbai
7th Floor, Redbrick,
Oberoi Commerz-1
Oberoi Garden City,
Goregaon East 400063
europe-map
2 Locations
map-pin
Ireland
Grove, Fethard,
Co. Tipperary,
E91 E282, Dublin, Ireland
map-pin
London
c/o SPACES,
12 Hammersmith Grove,
London W67AP, UK
north-america-map
6 Locations
map-pin
Canada
55 York Street, Suite 401
Toronto, ON,
Canada M5J 1R7
map-pin
Mexico
Tomas A. Edison 1510-201
Ciudad Juárez,
Chihuahua, Mexico 32300
map-pin
Dallas
5800 Granite Parkway,
Suite 480
Plano, TX, 75024
map-pin
Troy
6915 Rochester Road
Suite 300
Troy, MI 48085
map-pin
Sunnyvale
1248 Reamwood Avenue
Sunnyvale, CA 94089
map-pin
New Jersey
343 Thornall Street
Suite 720
Edison, NJ 08837