Remix.run Logo
miffy900 5 hours ago

As someone who first began using Swift in 2021, after almost 10 years in C#/.NET land, I was already a bit grumpy at how complex C# was, (C# was 21 years at that point), but then coming to Swift, I couldn't believe how complex Swift was compared to C# - Swift was released in 2014, so would've been 8 years old in 2022. How is a language less than half the age of C# MORE complex than C#?

And this was me trying to use Swift for a data access layer + backend web API. There's barely any guidance or existing knowledge on using Swift for backend APIs, let alone a web browser of all projects.

There's no precedent or existing implementation you can look at for reference; known best practices in Swift are geared almost entirely towards using it with Apple platform APIs, so tons of knowledge about using the language itself simply cannot be applied outside the domain of building client-running apps for Apple hardware.

To use swift outside its usual domain is to become a pioneer, and try something truly untested. It was always a longshot.

VerifiedReports 4 hours ago | parent | next [-]

I started using it around 2018. After being reasonably conversant in Objective-C, I fully adopted Swift for a new iOS app and thought it was a big improvement.

But there's a lot of hokey, amateurish stuff in there... with more added all the time. Let's start with the arbitrary "structs are passed by value, classes by reference." And along with that: "Prefer structs over classes."

But then: "Have one source of truth." Um... you can't do that when every data structure is COPIED on every function call. So now what? I spent so much time dicking around trying to conform to Swift's contradictory "best practices" that developing became a joyless trudge with glacial progress. I finally realized that a lot of the sources I was reading didn't know WTF they were talking about and shitcanned their edicts.

A lot of the crap in Swift and SwiftUI remind me of object orientation, and how experienced programmers arrived at a distilled version of it that kept the useful parts and rejected dumb or utterly impractical ideas that were preached in the early days.

fingerlocks an hour ago | parent | next [-]

Nowhere does it say structs provide “one source of truth”. It says the opposite actually- that classes are to be used when unique instances are required. All classes have a unique ID, which is simply it’s virtual memory address. Structs by contrast get memcpy’d left and right and have no uniqueness.

You can also look at the source code for the language if any it’s confusing. It’s very readable.

mvdtnz 7 minutes ago | parent [-]

You're re-stating his exact problem while trying to refute him.

ChrisMarshallNY an hour ago | parent | prev | next [-]

I think Swift was developed to keep a number of constituencies happy.

You can do classic OOP, FP, Protocol-Oriented Programming, etc., or mix them all (like I do).

A lot of purists get salty that it doesn’t force implementation of their choice, but I’m actually fine with it. I tend to have a “chimeric” approach, so it suits me.

Been using it since 2014 (the day it was announced). I enjoy it.

zffr an hour ago | parent | prev | next [-]

Prefer structs over classes != only use structs.

There are plenty of valid reasons to use classes in Swift. For example if you want to have shared state you will need to use a class so that each client has the same reference instead of a copy.

raw_anon_1111 4 hours ago | parent | prev [-]

> But there's a lot of hokey, amateurish stuff in there... with more added all the time. Let's start with the arbitrary "structs are passed by value, classes by reference." And along with that: "Prefer structs over classes."

This is the same way that C# works and C and C++ why is this a surprise?

AlexandrB 3 hours ago | parent [-]

Neither C++ nor C pass classes by reference by default (what even is a C "class" other than a struct?).

raw_anon_1111 3 hours ago | parent [-]

You are correct - it’s been ages since I’ve done C. The distinction is in C#.

belmont_sup 4 hours ago | parent | prev | next [-]

Not to mention how heated my laptop gets when I try to compile a new vapor template. On an m1.

fud101 2 hours ago | parent | prev [-]

So did you go back to and keep using C#/NET?