A modern programming language for FreeBSD: Swift

From: Jordan Gordeev <jgopensource_at_proton.me>
Date: Sat, 14 Jun 2025 13:06:40 UTC
The FreeBSD project can leap into the future by choosing a modern programming language to replace C, or continue living in the past, hoping that the rest of the world will do the same.

I want to present to you Swift — a modern programming language with many great features.

Some of its characteristics are:
 * it's mature — it's been around for more than 10 years
 * designed to prevent entire classes of programming mistakes
 * suitable for application and system programming; has a subset for embedded programming too
 * excellent performance of the generated machine code; for code generation the Swift compiler relies on components from clang and LLVM
 * expressive type system with type inference; support for parameterized types (generics, templates) and protocols (interfaces, traits)
 * safety features like checking array indexes, checking for arithmetic overflow
 * concurrency safety with value types, actors model and compile-time checks for possible data races
 * memory management without a garbage collector; either automatic reference counting or ownership-based manual mode
 * excellent interoperability with C; the Swift compiler can read C header files in order to automatically bridge between the two languages
 * interoperability with C++
 * stable ABI for Swift code
 * support for dynamic linking (incl. to libc for isolating generated code from changes to the userland–kernel interface)
 * easy to learn which can help lower the barrier to first contribution
 * offers interactive mode
 * open source under the Apache 2.0 license
 * came from the same group at Apple that did major work on clang and LLVM; those folks do understand compilers and programming languages

Some resources for learning more about Swift:

the About Swift section of the big Swift book:
https://docs.swift.org/swift-book/documentation/the-swift-programming-language/aboutswift/

A Swift Tour, a section of the big Swift book:
https://docs.swift.org/swift-book/documentation/the-swift-programming-language/guidedtour/

the big Swift book itself:
https://docs.swift.org/swift-book/documentation/the-swift-programming-language/

a presentation about Swift in mixed code bases, given at FOSDEM earlier this year:
https://video.fosdem.org/2025/k1105/fosdem-2025-6176-incremental-memory-safety-in-an-established-software-stack-lessons-learned-from-swift.mp4

If you want to try Swift today, there is a port of Swift 5.10.1 submitted for inclusion in the FreeBSD Ports Collection. You can find it at <https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=286454>. Apply the attached patch to your ports tree, build and enjoy.

When it comes to selecting a modern programming language for FreeBSD, I believe that Swift is one of the top three contenders and based on its merits deserves consideration.

Best regards,
Jordan Gordeev