
Pushing Swift to the Server - bezalmighty
https://www.skilled.io/u/swiftsummit/pushing-swift-to-the-server
======
Entangled
For Swift on the server you only need an editor like Sublime, Atom, or
whatever suits your fancy. That's it, nothing else. Get one of the most
popular frameworks like Kitura, Vapor, Perfect, Zewo or the dozens of smaller
ones and be ready to deploy to Heroku, Bluemix, AWS, Google Cloud, Digital
Ocean in no time.

It is that simple, tested, proven, it works, it simply works. In just a couple
of weeks I developed a couple of apps in Swift and they're up and running
unattended:

[http://swiftforums.herokuapp.com](http://swiftforums.herokuapp.com)

[http://pokerduel.herokuapp.com](http://pokerduel.herokuapp.com)

Repos here:

[https://github.com/kuyawa](https://github.com/kuyawa)

And the fact that you can also develop for the desktop, mobile, tablets,
watch, TV and IoT in one language is a huge advantage.

Swift is here to stay.

~~~
PSeitz
you always need at least compiler/interpreter to execute your code... unless
write bytecode in your editor

~~~
astrodust
Yes, but you don't need a compiler/editor, you can separate those.

~~~
PSeitz
If your editor is your compiler, then something is seriously wrong.

------
regularfry
Wow. That "same language connected by an interface schema would have prevented
Mars mission loss" thing is a _really_ thin stretch.

~~~
aub3bhat
This submission reminds me of "Satirical hacker news post"

""" The Muskonauts figured out why their shit exploded. Hackernews, literally
all of whom are actual rocket scientists, wonders if unit tests could have
helped. """

Also conveniently forgetting that Computer Scientists are yet to solve types
<===> physical dimensions mapping in practical programming language.

[https://hackage.haskell.org/package/dimensional](https://hackage.haskell.org/package/dimensional)

~~~
jahewson
F# units of measure are pretty cool - types for units!

------
echelon
Is Swift on the server a good idea? I don't own (or plan to own) a Mac. Does
Apple support cross-platform tooling? I honestly don't know, but given their
history, my default assumption is to be skeptical.

Why would you choose this over Go or Rust? (Rust is totally sweet for server
dev, and I've spun up a few Rust servers for things.)

~~~
wmil
While Swift will compile on different backends now, XCode is still the
premiere Swift dev environment and will be for a good while. So a non Mac
Swift dev won't be having a great time.

The target market is really iOS devs who want the same language on the back
end.

That's a perfectly reasonable engineering goal for an iOS-first shop.

But they're a vocal group and like to hype up server Swift as the next big
thing for everyone. That's just not going to happen.

~~~
jstapels
[https://www.jetbrains.com/objc/](https://www.jetbrains.com/objc/)

~~~
JimDabell
AppCode only runs on macOS and requires Xcode to be installed. It's no help to
people who aren't running macOS.

------
pier25
Swift is fast and the language is nice and all, but this feels more like
propaganda. Let's not forget IBM and Apple have become friends recently.[1]

I really don't see Swift becoming a popular full stack solution outside of
environments invested in iOS and macOS.

Swift can indeed _run_ on a multitude of systems but that doesn't mean it's a
good option. For example it's not even close to being ready for Android. It
can run, but that's it. Other than that you are on your own. No UI libs,
nothing.

This leaves you with iOS if you need to run on mobile which is extremely
restricted. Want to freely distribute an app among your colleagues on the lab?
Fuck you. You have to do all sorts of acrobatics with testing devices,
provisioning certificates, etc.

In Android you just compile an .apk and send the link to your colleagues to
install it, like in any other platform on Earth except iOS. Even macOS.

[1] [http://www.apple.com/ipad/business/work-with-
apple/ibm/](http://www.apple.com/ipad/business/work-with-apple/ibm/)

~~~
coldtea
> _Swift is fast and the language is nice and all, but this feels more like
> propaganda. Let 's not forget IBM and Apple have become friends recently._

Let's not forget it. How does that make presenting their product propaganda
any more so than any other product presentation? Heck, they even use it
themselves for their backend.

> _I really don 't see Swift becoming a popular full stack solution outside of
> environments invested in iOS and macOS._

Doesn't Apple becoming friends with IBM ensure that it will be used at least
by many IBM customers? Which is quite a large potential base (and not all are
happy for how Oracle moves with Java).

I also don't see why a top notch, statically compiled, very fast language,
with automatic memory management, and support from a huge vendor AND a huge
community AND open source, wont catch up.

> _Swift can indeed run on a multitude of systems but that doesn 't mean it's
> a good option. For example it's not even close to being ready for Android.
> It can run, but that's it._

That's because the work for porting properly there hasn't been done yet. But
it's more or less the same with Google's own Go, which is much older than
Swift, Rust, D, etc.

~~~
pier25
> How does that make presenting their product propaganda any more so than any
> other product presentation? Heck, they even use it themselves for their
> backend.

There is that aspect, sure.

But what I wanted to point out is the irony of IBM promoting Swift since there
isn't really any obvious advantage of using it full stack unless you are using
iOS. Which happens to be the product of their new friend.

That is all.

~~~
jstapels
IBM has already ported Java over to the z Systems platform. So why is them
also supporting Swift a bad thing here?

~~~
pier25
I'm not saying that's a bad thing.

What I'm saying is that moving to swift full stack is only beneficial if you
are using iOS or macOS on your clients.

------
geodel
IBM, the purveyor of Rational/Websphere suite of Java tools and appservers
talking about Java memory usage is sign of changing times. I hope they do
better job this time with Swift tools and frameworks.

~~~
pjmlp
The times are changing, hence why Java 10 has better support for some form of
value types, improved generics, JNI replacement and AOT compilation on its
roadmap.

~~~
geodel
All good stuff. But I have heard JNI is already multiple times faster than
Go's cgo stuff so I wonder what could be improved there.

~~~
pjmlp
According to Mark Reinhold, Sun designed JNI to be hard on purpose, to
discourage developers to write native code.

He has repeated this a few times at his JavaONE presentations, a bit hard to
track down which ones.

Thanks to the work of Charles Nutter on adding FFI to JRuby, and the pressure
from FinTech to improve Java's mechanical sympathy, a new project was started,
project Panama, where binding to native code from Java should be something
like P/Invoke on the CLR. Similarly calling into Java APIs from native side
should have less ceremony setting up what to call.

Additionally there should be a standard support for integrating GPGPU into
Java.

As it was deemed too complex to be ready by Java 9 timeframe, it ended up
being scheduled for 10+ roadmap.

For the latest status check "Going Native" at JVM Language Summit 2016.

[https://www.youtube.com/watch?v=JR1zI5gLhRM&index=13&list=PL...](https://www.youtube.com/watch?v=JR1zI5gLhRM&index=13&list=PLX8CzqL3ArzUY6rQAQTwI_jKvqJxrRrP_)

~~~
geodel
Interesting talk. Go folks also probably want cgo similarly difficult to use.
Though for them I guess it will work, as they have already written
compiler/GC/runtime/ssl etc in Go plus some asm.

~~~
pjmlp
I never understood why cgo was an option instead of doing what most languages
do.

The only reason I see, was having an easier way to parse header files.

------
maxpert
I recently rewrote a server that I had in Kotlin and really happy with the
results. With this I am pleasantly surprised! I already liked the syntax, and
now it gives me another reason to try it out. I am not sure though how would
it compare with Go.

------
rndmio
I'd be interested to know if any developers are investing in swift outside of
the Apple ecosystem. Given that the language still seems to be in flux (the v2
-> v3 transition didn't appear seamless), why would you pick it?

------
Perignon
Why? Why choose Swift over a language with an established framework ala
python, ruby, ASP.NET, Node.js ?

~~~
mixmastamyk
Speed, types, etc.

~~~
oblio
Python, Ruby, maybe.

Node.JS with Typescript or ASP.NET with C#/F#... I doubt it :)

~~~
mixmastamyk
Compiled langs are usually somewhat faster than node also, see golang, etc.

------
fetbaffe
No, I don't want to share models between the client and the server. I want an
API dependency between them, a code dependency is actually worse.

Why should the frontend change when the backend changes it´s abstractions? I
want to change them independently, because they have different constraints and
dependencies.

If you are implementering your database schema in the frontend, you´re doing
it wrong.

An API is a view against a domain, which in turn is an abstraction above the
database. However the client is not aware of the entire domain and shouldn´t
be.

Only thing that is a good idea to share is the domain language and the API
interface, but can be solved easily by other means than share code base.

And as soon you throw in another client with an other programming platform,
all the benefits is lost anyway.

~~~
bsaul
I completely agree with the general point, however at the minimum this lets
client and server share the same exchanged models ( what the server sends to
the client is defined once, as well as the opposite).

There may be technologies like protobuf to define those structures in one
place, but i can still imagine there are cases where it could be useful (
business rules and validation, etc).

~~~
wtetzner
Yeah, the most obvious benefit is being able to share validation logic across
front-end and back-end. All validation is necessary on the back-end for
security reasons, but it's convenient for users if it also happens on the
front-end, because they don't have to send data to the server before finding
out it's invalid.

------
aranajhonny
This repo demonstrates deployment of the Kitura web framework using Node.js
and Now.

[https://github.com/aranajhonny/now-swift-
example](https://github.com/aranajhonny/now-swift-example)

------
stevehiehn
How many projects really have just an ios client? If the argument is to have
the client and server the same language then isn't that also an argument for a
Java android & Java server?

------
TurboHaskal
It looks like we're getting Swift EE before Go EE.

------
ssscommunity
Perfect team is writing an article for Native iOS and Android development
using Swift. To be release soon.

------
always_good
Ctrl-f for "So,". 24 results.

You can sound much more professional and less juvenile by dropping the "So,"
prefix when you speak or write.

~~~
unit91
Wow! I was shocked to see no matches for "also", et al.

------
omouse
Why. Seriously. Why. Whatever happened to _domain-specific_ languages.

