2 ms·
> AlamoFire Ah yeah, so AlamoFire is a monstrosity of a library which was originally implemented in Objective C back when iOS's native networking tools were pr
by skohan 8y ago
> AlamoFire
Ah yeah, so AlamoFire is a monstrosity of a library which was originally implemented in Objective C back when iOS's native networking tools were pretty bare bones. I thought it was bloated and overcomplicated then, and it's worse now.
> JSON parsing in swift
This is a solved problem since Swift 4. Now you can declare conformance to Encodable/Decodable protocols on any one of your types, and in many cases the compiler can generate a default implementation of the protocol methods, so that's all it takes to make a type parsable from/serializable to JSON.
What's better, these "Codable" objects work with "Encoader/Decoder" protocols, so you can provide your own JSON parser implementation, or for instance, you could implement a TOML parser which conforms to Decoder, and all your existing Codables would already work with it.
Swift definitely has some warts remaining, but it's gotten a lot better over time, and the upcoming features and priorities seem promising as well.
- hardwaresofton 8y ago> Ah yeah, so AlamoFire is a monstrosity of a library which was originally implemented in Objective C back when iOS's native networking tools were pretty bare bones. I thought it was bloated and overcomplicated then, and it's worse now. OK, glad I wasn't imagining it > This is a solved problem since Swift 4. Now you can declare conformance to Encodable/Decodable protocols on any one of your types, and in many cases the compiler can generate a default implementation of the protocol methods, so that's all it takes to make a type parsable from/serializable to JSON. This is exactly what I was expecting it to be like which is why I think I was disappointed -- the ToJSON typeclass (haskell) and the Deserialize (rust) trait are the analogs I was expecting to find but didn't. Honestly I think Swift is a good language, my opinion on it really isn't too relevant except for why I normally don't reach for it outside of iOS development. Also does swift compile to a static binary fairly easily? That's another feature I really like from the recent crop of languages (Haskell excluded, it can be a bit tricky) -- Rust and Golang compile statically super easily, and you can get even more portability if you build in alpine (since it uses musl libc).