Hacker News Viewer

Swift is a more convenient Rust (2023)

by behnamoh on 1/31/2026, 10:05:03 PM

https://nmn.sh/blog/2023-10-02-swift-is-the-more-convenient-rust

Comments

by: JackYoustra

Broadly agree but, as is most things, the devil is in the details!<p>- Xcode. A really rough ide that has a hard time at scale, choking on package refreshes, many targets, and more. It has a special entitlement so you can&#x27;t even binary patch it if you want to fix it!<p>- Build systems. Cargo is _much_ easier to work with than SPM.<p>- Macros support, codegen is still largely done outside of the macro system, which should indicate its use.<p>- Linter &#x2F; format support. Yeah, it exists, last I checked it&#x27;s just a good bit worse.<p>- Performance. There are MANY performance cliffs in Swift; most can be fixed by a sufficiently determined compiler developer, but at this point we&#x27;ve kinda departed talking about the language as-is.<p>- Type inference time. Swift&#x27;s bidirectional type inference causes a ton of choking on complex expressions, which is a real problem with its number one use case, SwiftUI.<p>- An exacerbating factor on the above, imports are all implicitly module-scoped, meaning that changing a single file means recomputing the types for all files in the module. And because SPM and Xcode have such a rough time with multiple targets, that usually means that a single change can lead to recompiling all Swift files.<p>- Weirdness around classes and structs? I understand that they had to do it for objc compatibility, but I would&#x27;ve found it much cleaner if they&#x27;d just from the start had something replacing class, like a fully-sugared `final class Box&lt;T&gt;` that replaces all uses of class.<p>I agree that for the most part it _could_ be an easier rust, but between including bidirectional type inference without a cut operator and poor tooling I struggle to find where it&#x27;s actually easier in cases that you can&#x27;t just use typescript and dodge all the non-typecheck compilation headaches entirely.

1/31/2026, 10:56:47 PM


by: SkiFire13

&gt; Consider an enum that represents a tree. Since, it is a recursive type, Rust will force you to use something like Box&lt;&gt; for referencing a type within itself. &gt; &gt; enum TreeNode&lt;T&gt; { &gt; Leaf(T), &gt; Branch(Vec&lt;Box&lt;TreeNode&lt;T&gt;&gt;&gt;), &gt; } &gt; &gt; (You could also us Box&lt;Vec&lt;TreeNode&lt;T&gt;&gt;&gt; instead)<p>This is wrong, you don&#x27;t need a `Box` here. The Rust compiler forces you to have a layer of indirection, but `Vec` already does that.

1/31/2026, 10:50:05 PM


by: rednafi

Swift is a neat language, but it’s a hard sell for server-side software. The ecosystem is tiny, and there’s nothing you gain from using it instead of Go or Rust for infra &#x2F; distsys.<p>Also, it works okay at best with VS Code, and you couldn’t pay me to use Xcode.<p>Kotlin tried doing similar things to gain adoption on the server side. But server-side programming is a crowded space, and people just don’t like writing distsys code in another JVM language. Swift’s story is a little better on that front.<p>If you want a quick-and-dirty language, Python and TypeScript do the job. For perf-sensitive, highly concurrent environments, Go is hard to compete against. A lot of ops tooling and infra code is written in Go. For systems programming and embedded code, Rust is a better choice.<p>So while it’s fun to think about what language X gives you in terms of syntax, in practice it’s rarely enough to pick a language like Swift for your next non-toy backend distsys work.<p>Also, Apple. Given their stance against free and open source software, I wouldn&#x27;t be too thrilled to pick a language that works better in their walled garden.

1/31/2026, 11:54:56 PM


by: porcoda

I’ve done both Swift and rust for Linux applications (symbolic analysis tools and compilers, not web stuff or other server apps). I have to say, I’m torn after building a couple moderate (10-30k SLOC) scale tools in both. I prefer swift since I feel like I’m working at the abstraction level I prefer and letting the ARC stuff take care of memory for me. Rust isn’t so bad, but it does make me think more about things that I don’t when I’m in Ocaml or Swift. Rust has better tooling: the LSP support makes life nice in emacs. Compiler feedback and clippy : super useful. Not a fan of the high usage of crates (I’m in the paranoid about supply chain camp). Swift felt like it shipped with more batteries included. I think the main factor is the people side: however much I like swift, I’m more likely to find rust people in my world. I’m rooting for swift though: the world has room for more than one memory safe C++ successor.

2/1/2026, 4:18:54 AM


by: Validark

&gt; Swift doesn’t have a match statement or expression. It has a switch statement that developers are already familiar with. Except this switch statement is actually not a switch statement at all. It’s an expression. It doesn’t “fallthrough”. It does pattern matching. It’s just a match expression with a different name and syntax.<p>Are there people who see a &quot;match&quot; statement, smash both hands on the table, and shout, &quot;WHAT THE ___ is a ------- MATCH STATEMENT?!!! THIS IS SO $%^&amp;@*#%&amp; CONFUSING!! I DON&#x27;T KNOW THAT WORD!! I ONLY KNOW SWITCH!!&quot;

2/1/2026, 1:38:08 AM


by: mogoh

&gt; There is a perception that Swift is only a good language for Apple platforms. While this was once true, this is no longer the case and Swift is becoming increasingly a good cross-platform language.<p>How good is the developer experience on a non-Apple platform really? Linux is my primary platform and my perception is, that allmost all of the swift eco system is for Apple. Libraries, tools, documentation, IDEs, tutorials, etc. all assume, that you use an Apple.<p>Can someone tell me who does not use an Apple-device and uses swift?

1/31/2026, 11:12:08 PM


by: gary17the

If you want more convenience from Rust and do not want to mess with Rust borrow checker, you do not really have to switch to Swift: you can rely on Rust reference counting. Use 1.) Rust reference-counted smart pointers[1] for shareable immutable references, and 2.) Rust internal mutability[2] for non-shareable mutable references checked at runtime instead of compile time. Effectively, you will be writing kind of verbose Golang, but keep Rust expressiveness.<p>[1] <a href="https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;ch15-04-rc.html" rel="nofollow">https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;ch15-04-rc.html</a><p>[2] <a href="https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;ch15-05-interior-mutability.html" rel="nofollow">https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;ch15-05-interior-mutability.h...</a>

1/31/2026, 11:10:05 PM


by: jdalsgaard

I would tend to disagree; fundamental to Rust is the concept of zero-cost abstraction. Swift does not do that.<p>I my view, and I might be wrong, many features of Rust are chosen specifically to have the language comply to the zero-cost rule. Such as the ownership model.

1/31/2026, 11:46:56 PM


by: killingtime74

Even if it&#x27;s the same (faster horse?) I would rather use Rust for the fact it&#x27;s development is not tied to a big tech company which could abandon it if they liked. Yes it could continue on as a fork but it&#x27;s development velocity would suffer.

1/31/2026, 10:48:20 PM


by: kibwen

<i>&gt; Swift on Windows is being used by The Browser Company to share code and bring the Arc browser to windows.</i><p>Arc is no longer being developed ( <a href="http:&#x2F;&#x2F;www.newswarner.com&#x2F;2025&#x2F;05&#x2F;27&#x2F;the-browser-company-explains-why-it-stopped-developing-arc&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.newswarner.com&#x2F;2025&#x2F;05&#x2F;27&#x2F;the-browser-company-exp...</a> ) and AFAICT their efforts to port Swift to Windows for its sake have been cancelled.

2/1/2026, 12:31:26 AM


by: dagmx

There’s definitely areas where I agree Swift is more ergonomic.<p>Parameter defaults, and null short circuiting are two of them.<p>I find writing Swift is faster for me, and it’s easier to learn for people than Rust. Also Swift interop with other languages is much simpler.<p>Though there are way fewer resources to learn Swift, and cargo is superior to SPM. And of course rust is better cross platform today, but Swift is closing the gap.<p>I think they feel like very similar languages overall, and they both influence each other.

1/31/2026, 10:47:30 PM


by: dang

Related. Others?<p><i>Swift is a more convenient Rust</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=41464371">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=41464371</a> - Sept 2024 (308 comments)

2/1/2026, 4:11:07 AM


by: 999900000999

Hmm.<p>How about Rust is Rust. Swift doesn&#x27;t really appeal to me as a high level programer. C#, JS and Python largely pay my bills.<p>The non apple ecosystem just isn&#x27;t there, and it was never built to be cross platform. If I need to build something I&#x27;d probably lean on the languages I already know.<p>A few times a close friend has wanted an app built and I went with Flutter&#x2F;Dart + Firebase.<p>I&#x27;m using Godot for games.<p>Learning a new language, even a similar one is a time investment. In fact I just want better tooling for the languages I already know. Word to UV for Python.

2/1/2026, 2:18:46 AM


by: beshrkayali

Writing Swift is really fun! Last year I built a game and a macOS app (now working on another app) to get some proper hands on experience and I was very impressed. Wrote about it here[1].<p>I&#x27;d love for the experience outside of Xcode to get better (even on a mac, developing for macOS&#x2F;iOS) but I have to say that I didn&#x27;t find Xcode to be _that_ aweful. I&#x27;ve certainly used worse IDEs, which is partly why I dislike IDEs altogether.<p>1: <a href="https:&#x2F;&#x2F;log.beshr.com&#x2F;notes-on-swift-from-building-an-ios-game&#x2F;" rel="nofollow">https:&#x2F;&#x2F;log.beshr.com&#x2F;notes-on-swift-from-building-an-ios-ga...</a>

1/31/2026, 11:09:38 PM


by: thomassmith65

I lived and breathed Swift for the first five or six years of its existence. When people compliment it, I assume they haven&#x27;t used it long enough to hate it.<p>Swift is a mix of great features, miserable features, and... every other feature that someone on Evolution dreamt up (with the exception of those that would fix the miserable features)<p>Swift is unique among high-level languages in that the mental effort required to do many simple things rivals that of a low-level language.

2/1/2026, 12:30:39 AM


by: politelemon

I can trust the community behind Rust. I cannot trust the company behind swift. They hold a stance that is against open source, and this stance can affect swift at any time, so I wouldn&#x27;t want to invest into something that could be affected at a whim. It is certainly not convenient.

2/1/2026, 1:20:27 AM


by: bla3

Since then, Swift also grew excellent C++ interop, something Rust doesn&#x27;t have at all.

2/1/2026, 3:57:13 AM


by: Larrikin

Kotlin and Swift came in to popularity around the same time. They felt extremely similar at the beginning<p>Kotlin put a lot of work into proving itself as something more than just a language for Android development, starting first with backend.<p>It seems like once KMP became viable Swift is just trying catch back up.

2/1/2026, 12:58:34 AM


by: zozbot234

&quot;Convenience&quot; here basically means giving up semantic precision <a href="https:&#x2F;&#x2F;www.alilleybrinker.com&#x2F;mini&#x2F;rusts-culture-of-semantic-precision&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.alilleybrinker.com&#x2F;mini&#x2F;rusts-culture-of-semanti...</a> It&#x27;s not clear that this is genuinely desirable.

2/1/2026, 12:01:33 AM


by: cosmic_cheese

To me a big ding on Rust is no native imperative UI toolkit. Last I knew all Rust UI toolkits are declarative, which I’ve found to scale poorly past things like terminals, text editors, some mobile apps, and somewhat simplistic utilities. The more complex your UI gets, the more awkward and ill-suited declarative UI becomes. For something like a replacement for Photoshop or Word or even just Firefox you’re better off with something like AppKit.

2/1/2026, 1:44:48 AM


by: fooker

Swift&#x27;s happy path is pretty good, i.e. when you want to use a recent-ish toolchain to develop IOS applications using APIs that are not too new.<p>The more you deviate from this, the more cracks there are.

2/1/2026, 3:02:45 AM


by: usamoi

I really don&#x27;t understand what&#x27;s the point of such comparisons. Swift uses subtyping, while Rust uses typeclasses. Even looking only at their type systems, the two are completely different. You can&#x27;t assume they are similar just because they both use the Latin alphabet.

1/31/2026, 11:34:48 PM


by: dzonga

I once wrote a swift server app - hell even did a show hn over here<p>last time when I used Swift was v3 - and transition from v2 was a little rough.<p>the language kept adding features becoming a baby C++<p>if they had invested in bringing outside parties early on - not just iOS etc - swift would&#x27;ve replaced python

2/1/2026, 1:39:31 AM


by: drnick1

No thanks, too tied to Apple and closed source development models.

1/31/2026, 11:34:31 PM


by: g947o

&quot;The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions&quot; doesn&#x27;t feel convenient to me.

2/1/2026, 1:31:31 AM


by: syspec

I think this title is doing more harm than good.<p>Both are great languages

2/1/2026, 3:08:52 AM


by: nubg

&gt; to do reference counting and “clone-on-right” in your code<p>Was this article vibe dictated?

2/1/2026, 2:42:45 AM


by: csmantle

Swift has little to no toolchain support for less-common platforms like more recent MIPS, LA and alike. I frequently work and develop on such platforms, so sadly this is the major nay for me to use it.

2/1/2026, 12:42:05 AM


by: OrangeDelonge

I generally like Swift, but async is a mess, it feels like they come up with a new async library every release

1/31/2026, 11:02:57 PM


by: xannabelle

I was surprised how similar their approach was to memory management. The creator is doing the same thing for Python as they did for Objective-C, making way for a new wave of Swift and Mojo, although we&#x27;ll have to see if the latter grows to the same success.

1/31/2026, 10:49:58 PM


by: nixpulvis

&gt; Swift takes Rust’s ideas and hides them in C-like syntax.<p>This example doesn&#x27;t show me any meaningful difference, and Rust also let&#x27;s you attach functionality to enums.

2/1/2026, 12:17:49 AM


by: isodev

Until you get to the Swift concurrency stuff, or you try to use Swift on a backend or non-Apple system - then it’s hot garbage.<p>If Rust is too low level for you, you can write Go or Kotlin or even something new and fresh like Gleam.

1/31/2026, 11:18:13 PM


by: Alex_L_Wood

One of the Swift’s worst parts is how Apple keeps putting features in there just for the sake of SwiftUI.

2/1/2026, 12:10:01 AM


by: morshu9001

I used Swift in versions 1-4, so idk if it&#x27;s better now, but the syntax seemed fancy and complicated for no reason. So many different ways to do simple things like loops. Infuriating strings lib. Kinda believe the entire language was designed around emojis. And Xcode was a liability.<p>Rust is more complicated than C but has good reasons for everything it does. It&#x27;s lower level too, which is fine. If I want high level, I look to JS and not Swift.

2/1/2026, 2:45:29 AM


by: ChrisArchitect

(2023)<p>Some previous discussion:<p>2024 <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=41464371">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=41464371</a>

2/1/2026, 3:46:01 AM


by: HippoBaro

&gt; Rust invented the concept of ownership as a solution memory management issues without resorting to something slower like Garbage Collection or Reference Counting.<p>This is plain wrong, and it undermines the credibility of the author and the rest of the piece. Rust did not invent ownership in the abstract; it relies on plain RAII, a model that predates Rust by decades and was popularized by C++. What Rust adds is a compile-time borrow checker that enforces ownership and lifetime rules statically, not a fundamentally new memory-management paradigm.

2/1/2026, 12:03:30 AM


by: mirekrusin

MoonBit lang is better &quot;better Rust&quot; than Swift.

2/1/2026, 12:21:49 AM


by: heavyset_go

Are Core Foundation and Foundation Kit still macOS-only?

2/1/2026, 12:26:57 AM


by: Zak

&gt; <i>Except this switch statement is actually not a switch statement at all. It’s an expression. It doesn’t “fallthrough”. It does pattern matching. It’s just a match expression with a different name and syntax.</i><p>Giving a familiar name to a concept which behaves in familiar ways some of the time and surprising ways other times seems like a dirty trick to me, not a convenience.

2/1/2026, 1:21:52 AM


by: java-man

What is &quot;clone-on-right&quot;?

1/31/2026, 11:39:55 PM


by: rcarmo

Riiiiight. No. I&#x27;m a Mac user for decades, former Obj-C hacker, have tried and tried again and again to use Swift (and I have quite a few CLI apps written in it), but the thing has been a clusterfuck of paper cuts and very minor but significant changes over the years, and I gave up waiting for it to settle.<p>And it&#x27;s not a more convenient Rust. I&#x27;d rather use Zig or Go (neither of which are worthy in the eyes of true Crustaceans, but which just get the job done).

1/31/2026, 11:21:59 PM


by: suddenlybananas

I don&#x27;t really see the advantage of switch statements over match statements.

1/31/2026, 11:04:25 PM


by: bigyabai

Glad to see &quot;Swift is good now&quot; taking the place of &quot;year of the Linux desktop&quot; in a post-Steam Deck world.

1/31/2026, 10:37:37 PM


by: rickstanley

Toady I used GLM 4.7 to port a C++ project of mine to Rust, so I could read and toy with it, to get into the language: <a href="https:&#x2F;&#x2F;codeberg.org&#x2F;RickStanley&#x2F;agatetepe-rs" rel="nofollow">https:&#x2F;&#x2F;codeberg.org&#x2F;RickStanley&#x2F;agatetepe-rs</a>.<p>Really interesting results, not sure how well it is written but works. I was quite found of Rust syntax; it certainly is <i>not</i> as convoluted as C++ (in my opinion).<p>Then I read this article. Since I was already eye-balling Swift for some time, I decided to give it a try and port to it, using Rust implementation as reference, and this time, without much of A. I. assistance, if I could help it.<p>I&#x27;m using an qcow2 Debian trixie arm image in UTM as playground. I found out that there is no packaging for Debian at the time of this writing: <a href="https:&#x2F;&#x2F;github.com&#x2F;swiftlang&#x2F;swift&#x2F;issues&#x2F;60690" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;swiftlang&#x2F;swift&#x2F;issues&#x2F;60690</a>. No problem! They have a script for installing: <a href="https:&#x2F;&#x2F;www.swift.org&#x2F;install&#x2F;linux&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.swift.org&#x2F;install&#x2F;linux&#x2F;</a><p><pre><code> curl -O https:&#x2F;&#x2F;download.swift.org&#x2F;swiftly&#x2F;linux&#x2F;swiftly-$(uname -m).tar.gz &amp;&amp; \ tar zxf swiftly-$(uname -m).tar.gz &amp;&amp; \ .&#x2F;swiftly init --quiet-shell-followup &amp;&amp; \ . &quot;${SWIFTLY_HOME_DIR:-$HOME&#x2F;.local&#x2F;share&#x2F;swiftly}&#x2F;env.sh&quot; &amp;&amp; \ hash -r </code></pre> But, god damn, the size is <i>huge</i>,<p><pre><code> Unsupported Linux platform Debian GNU&#x2F;Linux 13 (trixie) is not an officially supported platform, but the toolchains for another platform may still work on it. Please select the platform to use for toolchain downloads: 0) Cancel 1) Ubuntu 24.04 2) Ubuntu 22.04 3) Ubuntu 20.04 4) Ubuntu 18.04 5) Fedora Linux 39 6) RHEL 9 7) Amazon Linux 2 8) Debian GNU&#x2F;Linux 12 Pick one of the available selections [0-8] : 8 Installing swiftly in &#x2F;home&#x2F;debby&#x2F;.local&#x2F;share&#x2F;swiftly&#x2F;bin&#x2F;swiftly... Creating shell environment file for the user... Updating profile... Fetching the latest stable Swift release... Installing Swift 6.2.3 Downloading Swift 6.2.3 100% [========================================================] Downloaded 947.6 MiB of 947.6 MiB Verifying toolchain signature... Extracting toolchain... The file `&#x2F;home&#x2F;debby&#x2F;ent&#x2F;agateteper&#x2F;.swift-version` has been set to `Swift 6.2.3` The global default toolchain has been set to `Swift 6.2.3` Swift 6.2.3 is installed successfully! There are some dependencies that should be installed before using this toolchain. You can run the following script as the system administrator (e.g. root) to prepare your system: apt-get -y install libicu-dev libcurl4-openssl-dev libedit-dev libsqlite3-dev libncurses-dev libpython3-dev libxml2-dev pkg-config uuid-dev libstdc++-12-dev </code></pre> 947.6 MiB ! I wonder why is that...

1/31/2026, 11:50:15 PM


by: drcongo

This article made me actually interested in learning Swift. Anyone recommend a good place to start?

1/31/2026, 11:20:03 PM


by: worik

I am unconvinced<p>I have used Swift (stopped about two years ago) and use Rust extensively these days.<p>People commenting here have mentioned the dreadful Xcode. But if you want to build systems on Apple, without investing a lot in setup, you are stuck with Xcode.<p>To be clear it&#x27;s failures as an editor or build system are not the main problems with Xcode (albethey very frustrating when the intermittent problems show up) it is the abject failure of the tooling.<p>We never got the profiler to produce anything intelligible after days of trying, spread over several weeks.<p>SwiftUI is not part of the conversation here, and I limit the amount of UI building I do, but it shares all the problems of declarative UI frameworks - mainly &quot;where is the code?&quot;. Debugging logic problems is nigh impossible in code you&#x27;re unfamiliar with<p>The very worst part of Swift were the thread control. Trivial to overwrite shared memory, &quot;DispatchQueus&quot; (?IIRC?) are a thin wrap of fork, and do nothing but add complications<p>Swift is probably better than Objective C, the latter being from the 1980s, and things have moved on, if your target is iOS and friends, and you are sure you never want to port, then obeying Apple is a wise business decision. Other than that stay away from it. Use Go for most things, and Rust when you must

2/1/2026, 12:15:09 AM


by: Mawr

&gt; without resorting to something slower like Garbage Collection or Reference Counting<p>Hah! But RC <i>is</i> GC! [1]<p>&gt; Again, this is just deception for those developers coming from C-like languages. Swift’s error handling works exactly like Rust’s behind the scenes, but it is hidden in a clever, familiar syntax.<p>But the indent heavy syntax is one of the worst parts of exceptions?<p><pre><code> Rust: fn value_in_cents(coin: Coin) -&gt; u8 { Swift: func valueInCents(coin: Coin) -&gt; Int { </code></pre> Well, that settles it — it is known languages that use snake_case are superior.<p>&gt; This is because Rust is fast by default, and lets you be slow, while Swift is easy by default and lets you be fast.<p>Good, good, you&#x27;re onto something here.<p>&gt; There is a perception that Swift is only a good language for Apple platforms. While this was once true, this is no longer the case and Swift is becoming increasingly a good cross-platform language.<p>Sigh. But you <i>just</i> said defaults matter, come on. Let me paraphrase: &quot;This is because Swift is for Apple platforms by default, while Rust is cross-platform by default.&quot;<p>[1]: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=NdREEcfaihg" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=NdREEcfaihg</a>

2/1/2026, 2:24:58 AM


by:

2/1/2026, 3:44:51 AM


by: zenlot

[dead]

2/1/2026, 12:09:41 AM


by: FranklinJabar

[dead]

2/1/2026, 1:55:33 AM


by: prairieroadent

[dead]

2/1/2026, 2:39:28 AM


by: MarginalGainz

[dead]

2/1/2026, 12:10:11 AM


by: IshKebab

Interesting. I&#x27;m not totally sold - still seems like Swift is quite niche and Apple-specific - but I might take another look.<p>Also you might want to rework the `Box` example because you don&#x27;t actually need to use `Box` in that case - the `Vec` already provides indirection.

1/31/2026, 10:48:32 PM


by: ewuhic

&gt;Swift is more convenient Rust<p>Nah.

1/31/2026, 10:41:40 PM


by: amelius

&gt; Swift is better for writing UI and servers and some parts of compilers and operating systems.<p>For UI, why would anyone choose a language that has no automatic GC that can handle cycles?

1/31/2026, 11:01:51 PM