Re: [Thought experiment] Bringing swift into an experimental branch?

From: Alan Somers <asomers_at_freebsd.org>
Date: Mon, 16 Jun 2025 22:27:04 UTC
On Mon, Jun 16, 2025 at 4:09 PM Warner Losh <imp@bsdimp.com> wrote:

> On Mon, Jun 16, 2025 at 4:05 PM Jordan Hubbard <jordan.hubbard@gmail.com>
> wrote:
> >
> > I know that the topic of “bringing additional languages” into OSes is
> controversial and, frankly, we made a bad call with macOS when we brought
> the kitchen sink in (everything from Tcl to Python) and regretted it
> afterwards, so this is just a thought experiment, as noted in the subject.
> >
> > All that said, I think a more modern language than C++ being readily
> available has a useful way of shifting development and generating some
> excitement, and a modern language that is also strongly supported by your
> existing clang / LLVM compiler toolchain represents an increment along the
> same evolutionary path.  It’s also a language that needs a number of
> components to be tightly in sync (libdispatch, clang, llvm, various
> compilation tools and libraries, etc) before any 3rd party developer can
> even compile it for FreeBSD, so saying “it’s a ports collection problem”
> may ultimately work, but not without considerable pain, as evidenced by the
> fact that ports/lang/swift does not exist.
> >
> > Why swift, if anything?
> >
> > Python changes too often in incompatible ways and Rust is still going
> through its Rust foundation stewardship changes (that didn’t form until
> 2021) plus if you bring Rust in, you’ll be immediately enmeshed in the
> “should we just rewrite the kernel in rust?!” topics that seem to plague
> Linux.   Swift, on the other hand, is an application and service
> development language and sits nicely on top of what FreeBSD already has -
> nobody’s going to push to rewrite the kernel or base utilities in Swift,
> but you do get access to a very active community and, of course, the
> backing of a major player like Apple and the open source swift ecosystem.
> >
> > I’m told that Swift also just announced support for FreeBSD, so if there
> is ever a time, this might be it?
>
> There's a rust utilities in the base branch for Rust right now, hosted
> outside of the project...  I'm sure something similar could happen
> with swift for interested parties to collaborate.
>

Note that said branch does not import the Rust toolchain itself.  It relies
on an external toolchain.  That made it quite easy to add all of the Rust
support to the Makefiles.  And there's no cost at all, in either runtime,
buildtime, or maintenance burden, to people who aren't using the Rust
stuff.  The same would be true of Swift, I assume.  But I think that it's
highly premature to consider such a thing before Swift even lands in ports.

As for whether Swift is appropriate for writing base system utilities, I
don't know enough about it to confidently say.  After Swift stabilizes in
ports, and after somebody creates a swift-in-base branch, then we can have
a real holy war ;)