News for hackers. Stuff that matters.
Re:Swift Static Linux SDK by Vt71fcAqt7 on Tuesday June 11, 2024 @05:06PM (#40651486)
Genuine question: is there any reason to use Swift without iOS/SwiftUI? (Outside of devs who are primarily Swift developers that want to use something they already know for a small project or similar.)
Re:Swift Static Linux SDK by Mandelmus on Tuesday June 11, 2024 @05:08PM (#40651503)
It's a beautiful language that's a joy to write. It's safe and ergonomic, and has an extremely powerful type system. I'd say those are good reasons to use Swift.
Re:Swift Static Linux SDK by oddevan on Tuesday June 11, 2024 @05:34PM (#40651818)
I'm really interested in exploring it for building web app backends because of this. Being able to have a drag-and-drop distribution is even better.
Re:Swift Static Linux SDK by dlachausse on Tuesday June 11, 2024 @06:03PM (#40652137)
I haven't used it yet, but I've heard really good things about Vapor as far as server side Swift goes...

https://vapor.codes

Re:Swift Static Linux SDK by OKThatWillDo on Tuesday June 11, 2024 @06:34PM (#40652434)
Thanks. What is a "protocol server?"
Re:Swift Static Linux SDK by potatolicious on Tuesday June 11, 2024 @07:01PM (#40652657)
Not a super-expert but I've used Vapor on some personal projects. Do you have a link to the mention for "protocol server"? I'm not familiar with the concept but might be able to help.
Re:Swift Static Linux SDK by Redoubts on Wednesday June 12, 2024 @04:56AM (#40655997)
I'm guessing they clicked onto the Built with SwiftNIO link and saw this at https://github.com/apple/swift-nio.
Re:Swift Static Linux SDK by OKThatWillDo on Wednesday June 12, 2024 @06:58PM (#40664118)
That's right. I did a search but this term does not seem to have a trendy or thorough definition.
Re:Swift Static Linux SDK by dlachausse on Thursday June 13, 2024 @09:40AM (#40669519)
In this instance they're talking about implementing network protocols, such as HTTP, where one end is the client and the other end of the connection is the server.

It's confusing because the Swift language also has the concept of "protocols" which are basically the equivalent of Java and C#'s interfaces if you're familiar with those languages.

Re:Swift Static Linux SDK by e63f67dd-065b on Tuesday June 11, 2024 @05:09PM (#40651510)
The main reason is that Apple has effectively deprecated Objective-C for ios/macos development going forward. It's not going away for probably another decade+, but all documentation is now in Swift, new APIs are written with Swift in mind, etc.

Think of it this way: in 5-10 years, ObjC will be the python2 of Apple development.

Re:Swift Static Linux SDK by hbn on Tuesday June 11, 2024 @05:31PM (#40651776)
The GP was asking specifically about non-Apple development
Re:Swift Static Linux SDK by airstrike on Tuesday June 11, 2024 @05:21PM (#40651651)
No language feels more pleasurable to write in. It's incredibly expressive and things are just dead simple 99% of the time

It's not perfect, but I hope it continues to flourish because it gets a lot right

Re:Swift Static Linux SDK by jimbobthrowawy on Tuesday June 11, 2024 @07:40PM (#40652938)
Has nobody made a polyfill for swiftUI on other platforms yet? Or is it too tied to apple OS-level APIs? The language itself is pretty nice, last I used it. Even if some of the method (argument?) names in most SDKs are absurdly long.
Re:Swift Static Linux SDK by robertjpayne on Wednesday June 12, 2024 @06:42PM (#40663997)
You can implement the same syntax for a renderer on other platforms but all of SwiftUI is closed source. So the diffing engine etc… all would need to be re-created from the ground up.

SwiftUI, like react uses some language constructs to make it look really fancy but in reality it's really simple nested data structs.

The real hard part is what the "DOM" provides for React and likewise what UIKit/iOS is doing with those data structs.

Re:Swift Static Linux SDK by BodkinsOdds on Sunday June 23, 2024 @08:07AM (#40766825)
There's a couple:

https://github.com/stackotter/swift-cross-ui (Linux + Windows)

https://github.com/TokamakUI/Tokamak (WASM + MacOS + some Ubuntu support)

They both had to rewrite the entire backend from scratch, because SwiftUI is very, very closed source. But Tokamak does have an import that just forwards to SwiftUI on Apple platforms.

Re:Swift Static Linux SDK by righthand on Tuesday June 11, 2024 @05:13PM (#40651556)
Not really no, there are far better languages with better cross platform support.
Re:Swift Static Linux SDK by petereddy on Tuesday June 11, 2024 @05:56PM (#40652060)
There are definitely languages with better cross platform support. But far better languages? I think Swift is a pretty good language and I like to know what you think is far better than it.
Re:Swift Static Linux SDK by pzo on Tuesday June 11, 2024 @10:33PM (#40653903)
maybe not far better as a language but on the same league but with far better cross-platform ecosystem that would be kotlin (native) or java (this days). You have great ecosystem for e.g. backend (Spring Boot) and modern java is also looking better every year.
Re:Swift Static Linux SDK by josephg on Tuesday June 11, 2024 @05:34PM (#40651810)
Which languages do you think are both better and have better cross platform support?
Re:Swift Static Linux SDK by boffinAudio on Wednesday June 12, 2024 @06:41AM (#40656567)
Lua, I would say. Far easier to get it everywhere, and a very nice language, also.
Re:Swift Static Linux SDK by josephg on Wednesday June 12, 2024 @10:19AM (#40658474)
Lua is nice, but it’s a bit of a weird comparison for Swift. Swift is compiled and lua is interpreted. Swift is statically typed. Swift uses ref counting to Lua’s runtime GC. And Swift has non nullable types by default, classes, enums, ADTs, match expressions and so on.

Lua is nice. But it’s chalk and cheese comparing the languages. I can’t think of many cases where you’re trying to decide between lua and Swift.

Re:Swift Static Linux SDK by boffinAudio on Thursday June 13, 2024 @03:37AM (#40666987)
In this case, the question is whether to use Swift for a backend server on a Linux machine, or something else. That's the environment. I'd prefer Lua, simply because its a very proven language for that application.

Sure, Swift has sexy features that make it appealing to developers. But the ecosystem for server infrastructure on Lua is formidable.

Re:Swift Static Linux SDK by Tainnor on Thursday June 13, 2024 @05:05AM (#40667468)
Kotlin
Re:Swift Static Linux SDK by sureglymop on Sunday June 16, 2024 @07:02AM (#40696147)
I agree. Honestly a really nice and productive language.
Re:Swift Static Linux SDK by criddell on Tuesday June 11, 2024 @05:33PM (#40651803)
Out of curiosity, which language works best for you and your use case?
Re:Swift Static Linux SDK by righthand on Wednesday June 12, 2024 @10:37AM (#40658684)
CPP
Re:Swift Static Linux SDK by wg0 on Tuesday June 11, 2024 @09:22PM (#40653520)
Haven't written Swift ever but it seems very elegant language. In that spot, only go stands but go although simple but has very ugly corners such as error handling and a weird type system.

So yes for me, I might switch to Swift which seems very elegant and readable compared to some other options.

Re:Swift Static Linux SDK by Tainnor on Thursday June 13, 2024 @04:56AM (#40667400)
I was maintaining a server-side app written in Swift from 2018 to 2020 and we ran into tons of issues at least back then. I haven't looked into all the improvements they did since, but you might want to check.

My coworker wrote down some of the major issues we were facing: https://forums.swift.org/t/issues-learned-4-years-with-serve...

Personally, I've been soured enough that I don't ever want to write any server-side code in Swift again. It just seemed that Swift pretended to be open-source and cross-platform and then Apple would just unilaterally push some changes just because they wanted them for iOS (e.g. function builders for SwiftUI) without waiting for community feedback. It's fine to be a dictator for your PL, but not when you're claiming to have "open governance". All the while support for Linux was routinely being neglected.

I would rather recommend Kotlin. It's similar enough to Swift and it comes with the advantage of having the whole JVM ecosystem which can probably do most things you'd ever want to do on a server.