top | item 45837871

Swift on FreeBSD Preview

235 points| glhaynes | 3 months ago |forums.swift.org

156 comments

order

oaiey|3 months ago

A lot of good news recently for swift. I am a bit jealous as my go to language C# / .NET is recently not announcing fancy things.

I really like swift going beyond Apple. Particularly the port to android is IMHO crucial, however, now they are in the UI cross platform hell. Let us see if Apple is playing this better than Microsoft. Unfortunately, I have little hope. The only native contenders in the field right now are IMHO are react native and flutter which are both UI toolkits first and language second. Which I find gruesome.

cosmic_cheese|3 months ago

It'd be nice if Apple made SwiftUI cross platform and I'd be singing in the streets if UIKit got ported, but that seems unlikely at best.

I believe that there's strong community interest in some kind of Swift UI framework for Android, though, and so there's a substantial chance that a third party solution will appear.

troupo|3 months ago

> I am a bit jealous as my go to language C# / .NET is recently not announcing fancy things.

Depends on what you think fancy things are. Both C# and .net are busy releasing a lot of features.

You're forgetting that C# is a 25-year-old language at this time. The exciting features they release are things like "access native memory allocation in a GC language", "native Arm64 support", "support for post-quantum cryptography", "tensor support" etc. while already running on all the platforms that Swift is only now announcing as achievements.

runjake|3 months ago

I guess it's a matter of perspective. Dotnet 10 just came out[1] with a bunch of solid new shiny that I'm enjoying.

And, as it stands, Dotnet is much further along in the multi-platform game than Swift. As far as I know, none of the Swift-based UI stuff is being ported to, let alone going to be usable on non-Apple platforms.

1. https://www.c-sharpcorner.com/article/whats-new-in-net-10/

idatum|3 months ago

Speaking of .NET, I've been successfully running .NET 9 on AMD64 FreeBSD. It's nice to have that choice.

isodev|3 months ago

Swift is a “may you live in interesting times” kind of deal. Not the kind of stress you want in your day job.

CodeCompost|3 months ago

I donnow. C# and .NET are amazing. People tend to ignore it because Microsoft, but they are being short-sighted. What shiny things are you missing?

memsom|3 months ago

> The only native contenders in the field right now are IMHO are [...] and flutter

I wouldn't really call Flutter "native".

I don't have a strong enough grasp of where React Native is at now. It was severely lacking when I looked at it circa 2018. But then we needed to call in to our own native code libraries, so we were probably quite niche.

Xamarin.Forms worked well enough, but the transition to MAUI has been full of woe and even more bugs and weird edge case functionality than Xamarin had.

pjmlp|3 months ago

Aspire, extensions everywhere, field variables, spans as part of the type system, and naturally plenty of AI, isn't fancy enough?

keyle|3 months ago

This is a blessing and a curse. I, for one, preferred Swift from before, when it wasn't hell bent on replacing C++.

It was a simpler Swift, I could understand all of it. Just look at the explosion of keywords in Swift.

hirvi74|3 months ago

I absolutely love Swift. I understand some may disagree, and perhaps many of their arguments are quite valid. However, no language is perfect, and I just feel like Swift has some features that shows that a lot of thought was put into some features -- not to disrespect any other languages.

Considering the static typing, guard statements, protocols, lack of ++/-- operators (Lattner's argument was convincing), let/var, being able to make function parameters immutable, being able to lock symbols down to the file level, easy integration with c languages, etc..

I have not used SwiftUI, so I cannot judge it, but I do not think any issues with it are compelling arguments against Swift as a language (that I have read).

Lattner is my modern-age programming-hero. I'm glad to see FreeBSD will be able to share the love soon enough.

troupo|3 months ago

You can watch Lattner's interview with Theprimeagen. It's a haphazardly designed language where pressure to ship from Apple as a whole overrides any design or development considerations.

That's why you end up with a compiler that barfs at even the simplest SwiftUI code because Swift's type system is overly complicated and undecidable. And makes the compiler dog slow.

That's why you end up with 200+ keywords [1] with more added each release.

That's how you end up with idiocy like `guard let self = self else { return }` (I think they "fixed" this with some syntax sugar) because making if statements understand nulls is beyond the capabilities of heroes apparently.

And this is just surface level that immediately came to mind.

[1] It's not a typo: https://x.com/jacobtechtavern/status/1841251621004538183

ezfe|3 months ago

And SwiftUI is not part of Swift open source, it's just for Apple platforms. The underlying Swift language features could be used by other UI systems if someone wanted to make a crossplatform system, though.

myko|3 months ago

Swift is such an excellent language. I hope it continues to grow outside of the Apple ecosystem.

rootnod3|3 months ago

Are they also gonna take the reigns and officially be the maintainer of the FreeBSD package in ports or are they gonna wait for some volunteer to package it for them and choke on the bug reports whenever someone finds an issue?

latexr|3 months ago

> The Swift compiler and runtimes have a few dependencies. Please install the following dependencies:

> (…) python3 (…)

Wait, which part requires Python, and why? And is that only for FreeBSD, or in general? And is that something which will change? Feels very weird that a compiled systems language is dependent on a high-level scripting language.

airspeedswift|3 months ago

The Swift toolchain includes LLDB, which relies on python for some debugging features. The compiler and runtime itself do not use python.

jshier|3 months ago

LLDB also needs python if you want to use its scripting integration.

fridder|3 months ago

Loving all the new developments with FreeBSD.

jiehong|3 months ago

Porting on more platforms is always great, and a good way to find hidden assumptions.

ethin|3 months ago

Swift just needs to gain cmake bidirectional support, like, SPM should be able to compile CMake projects and vice-versa, or be able to use vcpkg. Once that's done, I could very much see myself switching to it for a lot of things.

wahnfrieden|3 months ago

SPM support for CMake is in progress

turnsout|3 months ago

Wow, this is great news. I still don't understand why it has taken so long, when Swift on Linux has been around for 10 years. But as a FreeBSD user, this is very welcome!

vtail|3 months ago

Do people use Swift outside of Apple iOS/macOS development in real life? Especially on platforms like Windows/Linux/*BSD?

lukeh|3 months ago

I’m using it on Linux for an embedded product. No reason other than it’s a nice language that I am familiar with and productive in. The async/await features are quite nice too when you need to implement a lot of protocols / state machines.

wkat4242|3 months ago

Personally I stay away from Corp owned languages. Even cross platform ones like .net, Java and also swift. With the single commercial party owning it you never know if theyll close it, change things for the worse or get acquired by a hostile party which obviously happened to java :(

andrewl-hn|3 months ago

Arc browser famously had native parts of the UI done in Swift, which admittedly is not a lot: browser tabs, some popups and buttons here and there, a lot of their settings UI is rendered in HTML and is stock Chromium. Which is probably why they actually made a port of it to run on Windows rather than rewriting it into something like Qt or WPF or whatever.

Ladybird browser team planned to start using Swift in their codebase, but it hasn't happen yet.

afavour|3 months ago

Chicken/egg, I think. There was a burst of activity of Swift on the server a few years ago and frameworks like Vapor seem like they’re still pretty active:

https://vapor.codes/

But I think “why” remains a valid question when you could make a safe pick like Node, Python etc. I really like Swift as a language but I’d still struggle to justify using it outside of iOS.

GeekyBear|3 months ago

Like Rust, Swift is a compiled language that offers memory safety and data race safety by default.

rootnod3|3 months ago

I guess so. In a way it makes sense if you can share your code base between the iOS/MacOS app and your backend. It makes development easier. But I guess that the majority of apps is not running MacOS servers for the backend. So far it's probably some node backends and all going JSON inbetween. But for some dedicated apps without a web portal inbetween it might be easier if app and backend are both in Swift.

tiltowait|3 months ago

It’s not super popular, but support is necessary to make it so. There are some well-regarded frameworks, like Vapor, that are written in Swift.

mk89|3 months ago

It'd be nice to use it for server side too, but the ecosystem is really not mature and the build system is not on the same level of Gradle or similar.

Plus, most of the open source libs are one person's weekend projects, from 3 years ago...

It's a great language, but nowadays tooling/ecosystem and build systems are key to success.

pjmlp|3 months ago

Yes, because Apple gave up on the server market, so that demography usually uses Linux based servers and does code sharing between backend and their iDevices apps.

repelsteeltje|3 months ago

Only for iOS apps. Apple does not offer a backend.

tehnub|3 months ago

Could SwiftUI ever be used outside of Apple?

lukeh|3 months ago

I did try to build a medium sized project with this today. Still a lot of dependencies that will need to be updated for the differences between glibc and libc.

hazn|3 months ago

what i am pondering is: is it easier in theory to port swift to freebsd rather than linux? the facts that macOs has shared history with freebsd tells me yes, the fact that llvm favors linux (?) tells me both.

also, congrats, the swift and freebsd are ambitious in terms of new deployment platforms and compatibility! (see embedded swift, oci freebsd containers, freebsd on firecracker)

zapzupnz|3 months ago

> is it easier in theory to port swift to freebsd rather than linux? the facts that macOs has shared history with freebsd tells me yes

That shared history goes back a LONG way. The base components from FreeBSD that are in macOS are absolutely ancient. I think the most modern shared components are just the userland tools.

So I don't think it would make much difference at all.

rootnod3|3 months ago

Why would llvm favor linux? FreeBSD also officially moved from GCC to LLVM for the base system, so I don't see why LLVM wouldn't support it.

kchoudhu|3 months ago

I'm not complaining, but also why?

zapzupnz|3 months ago

Why not? Why wouldn't an open source project want their increasingly platform-agnostic language to be supported on as many platforms as possible?

MBCook|3 months ago

It’s a fantastic language? I’ve come to really like it. Strong type system, is it to work with, lots of resources available, compiles to a binary, interfacing with any other language that you can link to with C, the syntax doesn’t look ugly to me (quite subjective), excellent concurrency support…

What can I say I’m a fan.

DeathArrow|3 months ago

What can you build with Swift on FreeBSD which isn't easier with other languages?

bhokbah|3 months ago

Everything will be easier to build with Swift on FreeBSD for a Swift developer compared to any other language

jhatemyjob|3 months ago

Software that is meant to run on Apple platforms.