News for hackers. Stuff that matters.
Re:Swift Server Work Group Annual Update by echelon on Thursday October 31, 2019 @03:01PM (#21412371)
Swift isn't comfortable to use on non-Mac platforms. Because of this I can't see it taking over from Go or Rust in the server space. (I mention Rust because the language type system feels similar to Swift's and Rust is gunning for the same server space.)

If the Swift folks want adoption, they're going to have to think about the broader developer ecosystem. There's also an inherent mistrust in Apple that I think a lot of engineers have. It feels a lot like Google Dart in this respect.

Re:Swift Server Work Group Annual Update by Tainnor on Thursday October 31, 2019 @03:48PM (#21412897)
In my case, the mistrust in Apple comes from the fact that in the almost two years I've been working on server side Swift I've seen the Swift core team constantly prioritising things that are mostly relevant for app developers (like SwiftUI and the associated function builders changes, or ABI stability), while not caring at all about things that are relevant for server side developers such as:

- support for platforms beyond Ubuntu

- fixing the myriad weird bugs on Linux (here's two particularly bad examples: https://bugs.swift.org/browse/SR-10613, https://bugs.swift.org/browse/SR-10344)

- coming up with an error handling solution for when your app crashes on the server that is better than "just have your load balancer restart the instance"

- improving compile times for large applications

- improving modularisation concerns (e.g. submodules)

- creating an alternative to Foundation (recently, foundation on Linux was split into different modules, which makes the code that compiles fine on a mac break on Linux until you add additional imports ... go figure)

Re:Swift Server Work Group Annual Update by skohan on Thursday October 31, 2019 @04:51PM (#21413604)
> improving compile times for large applications

Have you tried breaking up your project into more, smaller modules? Incremental builds with small modules tend to be very quick.

I agree with you though regarding the priorities of the core team. I tried to reach out to several people a few months ago to get involved in contributing to improve the Linux situation, and nobody answered my messages.

Re:Swift Server Work Group Annual Update by Tainnor on Monday November 04, 2019 @06:56AM (#21440808)
Hey yes, we have a number of modules by now. Unfortunately, the reality seems to be that while splitting up reduces incremental compile time, it increases the compile time of full builds, which is especially annoying on CI (but also basically every time we update some very core module).

Also, Swift is just really not designed well for very modular apps. There are no qualified imports, there are naming conflicts, inlining stops working, etc.

Re:Swift Server Work Group Annual Update by favorited on Thursday October 31, 2019 @03:19PM (#21412562)
I'm not sure why the discussion is always framed as Swift vs. Rust vs. Go. It's not like any of them are the dominant backend languages.

Swift can be a great choice for backends for lots of reasons (shared code between client and server, client devs become full-stack devs, etc.), and it has its drawbacks as well.

This idea that for Swift to thrive as a server language it has to win some contest against Go and Rust makes absolutely no sense to me.

Re:Swift Server Work Group Annual Update by wlesieutre on Thursday October 31, 2019 @03:25PM (#21412623)
If anything, the comparison I'd make is javascript. Just like Node, it's a nice notion that you can take your client language and use it on a server. Aside from that, does anyone think that javascript is a good language choice for backend development?

Swift has a lot more redeeming aspects than javascript does, but like this post acknowledges, they don't have its package ecosystem.

Re:Swift Server Work Group Annual Update by skohan on Thursday October 31, 2019 @04:22PM (#21413299)
> they don't have its package ecosystem.

I think in some ways this is a chicken-and-egg problem. If people start working with Swift in the server space, that ecosystem will quickly evolve.

Also, Swift has great interop with the C FFI, so you have access to every C library, and every Rust library with a C API to boot.

edit:

> Aside from that, does anyone think that javascript is a good language choice for backend development?

I write a lot of swift code for personal projects, largely because it's so nice to program in, and I actually think it could be a great choice for back-end development.

I think Swift offers many of the same advantages of Rust in terms of a robust, powerful type system, and the feeling that if your code compiles, you're probably not going to have too many runtime errors (as long as you followed the rules).

Swift makes tradeoffs in favor of developer ergonomics where Rust chooses in favor of performance. In the vast majority back-end cases, Swift's performance will be good enough, and it's ease of use lets you have many of the advantages of a language like Rust but with the improved productivity of working with a higher level language.

Re:Swift Server Work Group Annual Update by eptcyka on Friday November 01, 2019 @05:10AM (#21417201)
>Also, Swift has great interop with the C FFI, so you have access to every C library, and every Rust library with a C API to boot. I can think of maybe 3 Rust libraries that I'd want to interface with through their C api.
Re:Swift Server Work Group Annual Update by eecc on Thursday October 31, 2019 @03:50PM (#21412925)
I’ll burn a candle in favor of giving Node the Adobe Flash treatment it deserves.

(Burn karma burn!)

Re:Swift Server Work Group Annual Update by nielsbot on Thursday October 31, 2019 @03:34PM (#21412719)
TypeScript makes a big difference here...
Re:Swift Server Work Group Annual Update by Eric_WVGG on Thursday October 31, 2019 @04:00PM (#21413063)
I spent the better part of last winter developing in the article author’s Vapor server-side Swift project, which I found to be absolutely delightful (shout out to Tanner and the crew, you guys are amazing!)

The following summer I got a gig doing Typescript on both client and server; mostly the experience has highlighted to me how well designed Swift feels, and how stapled on and hacked Typescript feels. Do not like.

Re:Swift Server Work Group Annual Update by vosper on Thursday October 31, 2019 @08:06PM (#21415086)
> how stapled on and hacked Typescript feels

It is stapled on, though, right? Typescript is stapled onto Javascript. There's only so much they can do. I don't mean that as an argument for Typescript, more just that there are real constraints for the language developers.

Re:Swift Server Work Group Annual Update by ElFitz on Thursday October 31, 2019 @05:15PM (#21413777)
There is a world between the two when it comes to types. Even more so at run time.
Re:Swift Server Work Group Annual Update by echelon on Thursday October 31, 2019 @03:23PM (#21412604)
> This idea that for Swift to thrive as a server language it has to win some contest against Go and Rust makes absolutely no sense to me.

That's not the point! It's that engineers have to use Mac machines to develop Swift because they're tied to a development platform. Go and Rust (simply called out as nearest neighbors) do not have this limitation. Even Microsoft has made great progress in making their tools available on other platforms.

It would be foolish to choose Swift for this reason. You're tied to Mac machines until it's been proven other platforms will have full support. It's a real handicap for Swift as a language and platform for anything beyond writing Apple software.

Re:Swift Server Work Group Annual Update by wlesieutre on Thursday October 31, 2019 @03:37PM (#21412748)
The language server runs on linux and works with VS Code. Is there something in particular you're missing?

You don't have XCode on linux, but I've never heard of someone being disappointed about that.

And does Apple have to be the source of all tooling? Is that how it is for Rust and Go? It's certainly not for Javascript and Python tools.

Re:Swift Server Work Group Annual Update by Tainnor on Thursday October 31, 2019 @04:23PM (#21413315)
I can't even get sourcekit-lsp running without errors.

"failed to create SwiftPMWorkspace: could not find executable for 'xcrun'"

Until such time as there is a working installer that is as simple as "download XCode from the app store", I don't really consider that to be an alternative. I certainly can't recommend it to anyone on my team.

Re:Swift Server Work Group Annual Update by mickael on Friday November 01, 2019 @03:14AM (#21416796)
Re:Swift Server Work Group Annual Update by Razengan on Thursday October 31, 2019 @03:27PM (#21412648)
> It's that engineers have to use Mac machines to develop Swift

That is patently untrue.

Re:Swift Server Work Group Annual Update by Tainnor on Thursday October 31, 2019 @03:37PM (#21412747)
As it's written, this is untrue. You don't need a Mac to develop Swift. However, you really ought to have one, because the development experience is subpar on Linux:

- there is no free IDE (XCode is only for macOS, and CLion costs money - plus, it has its own bugs)

- a lot of tips and tricks on the internet (e.g. about profiling your application, etc.) heavily rely on XCode. Actually, even Apple's own documentation usually references XCode settings (or other apple tools) instead of exposing a good cross-platform interface

- the code just behaves differently on Linux than it does on the Mac (especially with Foundation)

Re:Swift Server Work Group Annual Update by scarface74 on Thursday October 31, 2019 @03:43PM (#21412839)
This is server side Swift. It supports the LSP and is supported by Visual Studio Code.
Re:Swift Server Work Group Annual Update by Tainnor on Thursday October 31, 2019 @04:24PM (#21413334)
Apart from the fact that you ignored the other two arguments I made, the LSP is not production ready. It even says so on its very own github page: https://github.com/apple/sourcekit-lsp#status
Re:Swift Server Work Group Annual Update by scarface74 on Thursday October 31, 2019 @04:28PM (#21413376)
The XCode profiling is mostly for iOS apps - not server side code. You wouldn’t really be better off using a Mac for profiling server side code.

And what server side code “behaves differently”

Where does it say it’s not “production ready” on the GitHub link?

Re:Swift Server Work Group Annual Update by Redoubts on Thursday October 31, 2019 @06:11PM (#21414297)
> Behaves differently

For me, lots of string and substring operations throw NotImplemented exceptions on Linux, when they just work on Mac. This kinda sucks because there’s no compiletime or linttime warning for this.

Re:Swift Server Work Group Annual Update by saagarjha on Thursday October 31, 2019 @06:01PM (#21414193)
> The XCode profiling is mostly for iOS apps - not server side code. You wouldn’t really be better off using a Mac for profiling server side code.

Instruments, which ships with Xcode, is quite powerful.

Re:Swift Server Work Group Annual Update by badrequest on Thursday October 31, 2019 @05:03PM (#21413693)
Your response to "there's no good tools for profiling Swift apps on Linux" is "you only want to do that for iOS apps anyway?" I profile server code all the time, it's simply unacceptable to think I'd ever use a language that didn't facilitate it. Go does (https://blog.golang.org/profiling-go-programs). I've not used Rust, so I can't speak to that.
Re:Swift Server Work Group Annual Update by scarface74 on Thursday October 31, 2019 @05:07PM (#21413720)
You mentioned specific profiling in XCode and how that makes it necessary for server development. XCode doesn’t have much of any profiling that would be beneficial to server development - the entire topic of the submission.
Re:Swift Server Work Group Annual Update by Eric_WVGG on Thursday October 31, 2019 @05:06PM (#21413719)
> And what server side code “behaves differently” [mean]

Spend a bit of time on the Vapor Discord channel and read about all the quirks Linux users have to deal with that the rest of us don’t.

(My impression is that it’s due to Foundation libs.)

Re:Swift Server Work Group Annual Update by scarface74 on Thursday October 31, 2019 @05:08PM (#21413726)
So instead of a specific example you want us to go to a random discourse channel?
Re:Swift Server Work Group Annual Update by veidr on Thursday October 31, 2019 @06:24PM (#21414406)
But that _is_ true: the Foundation library — which because Swift has a super small core library is really kind of critical to basically any kind of program — behaves differently on Linux.

I write Swift code that runs on Linux and also on macOS or iOS, and we frequently have to have sections of "if Linux, run this code, else run this other code".

And while that's trivial to write, it's not trivial to find all the places where you have to do that.

(Nevertheless, I like Swift a lot and am using it on Linux.)

Re:Swift Server Work Group Annual Update by pjmlp on Thursday October 31, 2019 @04:25PM (#21413348)
On Ubuntu...
Re:Swift Server Work Group Annual Update by mamcx on Thursday October 31, 2019 @04:45PM (#21413554)
> I'm not sure why the discussion is always framed as Swift vs. Rust vs. Go

Because all three are in the spot of "what If I want C/C++ but better?". Even if are not direct competitors are in the space that a lot of folks wish to be (ie: Productive as scripting languages yet more performant)

Re:Swift Server Work Group Annual Update by pjmlp on Thursday October 31, 2019 @05:31PM (#21413901)
Just like OCaml, Java (AOT compiled), C#/F# (AOT compiled), D, Nim, Ada, FreePascal.
Re:Swift Server Work Group Annual Update by mamcx on Thursday October 31, 2019 @06:38PM (#21414502)
Maybe not the ones with GC?
Re:Swift Server Work Group Annual Update by pjmlp on Thursday October 31, 2019 @07:22PM (#21414806)
Swift also has a GC by CS definition of automatic memory management algorithms.
Re:Swift Server Work Group Annual Update by skohan on Friday November 01, 2019 @09:27AM (#21418503)
Swift's ARC is also really slow compared to a lot of GC implementations, largely because it relies on a lot of atomic operations in order to work in a thread-safe manner.

It does have positive characteristics in that it's much more memory efficient than a lot of GC solutions. Also it's deterministic, which will be appreciated by anyone who's had to deal with Stop-the-world garbage collectors. It's also possible to avoid a lot of ARC overhead by avoiding reference types, which is often quite tenable due to Swift's robust support for value types. Also there's a lot of low-hanging fruit for how ARC could be optimized to cut into that overhead.

Anyway, not quite sure what I'm getting at, but the memory management story with Swift is interesting.

Re:Swift Server Work Group Annual Update by mamcx on Friday November 01, 2019 @11:54AM (#21420134)
What you say, in other words, is that swift is biased to run on iOS. I think the tradeoff are rigth and work well in practique.

Probably if swift get more traction in server side, is where the difference from GC (that in other words, are BATCH ORIENTED memory managers vs SCALAR ORIENTED) then the need to improved things will show up.

Re:Swift Server Work Group Annual Update by mamcx on Thursday October 31, 2019 @04:43PM (#21413533)
I agree. I even asked https://www.reddit.com/r/swift/comments/8zb9y1/state_of_swif....

For me, swift will be the ideal language (for syntax/style and performance ok for me). But is a deal killer that is not good on windows and no starter for android (that sadly, I need to support because is the dominant platform in my country).

If at least swift was great for backend/logic (ie: no UI on win/android/linux) it could be enough...

Re:Swift Server Work Group Annual Update by NobodyNada on Thursday October 31, 2019 @04:51PM (#21413606)
For what it's worth, that Reddit post is from last summer, and Swift on Linux development progresses extremely quickly. It's become pretty mature on Ubuntu by now.

It's definitely more rough on Windows and Android, but at least CI is set up and passing on both platforms (which wasn't the case a year ago): https://github.com/apple/swift/blob/master/README.md

Re:Swift Server Work Group Annual Update by pharaohgeek on Friday November 01, 2019 @09:10AM (#21418309)
I develop Swift on Linux all the time and have no issues. The only thing I don't like is that Ubuntu is the only officially supported platform. We've had to roll our own packages to support CentOS/RHEL. In spite of that, it's still quite easy to develop server-side apps using Swift on Linux. The Jetbrains CLion IDE supports it with no problem, as does VSCode.
Re:Swift Server Work Group Annual Update by melling on Thursday October 31, 2019 @03:10PM (#21412463)
I imagine if there’s a demand, AppCode could be made available on other platforms:

https://www.jetbrains.com/objc/

Re:Swift Server Work Group Annual Update by endorphone on Thursday October 31, 2019 @04:24PM (#21413324)
The fact that Swift is at all usable on other platforms is pretty amazing, really, and it's a recent but quickly accelerating initiative.

As far as taking over from Go or Rust, I don't see someone with a greenfield project picking up Swift as the basis of some arbitrary project. Instead I see someone working on a Swift-based app -- say for iPadOS or macOS -- and needing a server-side component and deciding that it enables better skill and code re-use to implement the server-side in Swift as well.