3 ms·
Am I the only one as a JS dev, who find it hard with types & casting in Swift?
by itsbits 10y ago
Am I the only one as a JS dev, who find it hard with types & casting in Swift?
- matthewmacleod 10y agoProbably not. Types and casting seem complex to people coming from more dynamic languages – that's okay though! It formalises something that you generally don't have to think about in Javascript – the tradeoff being that you have more consistent, less buggy software at the expense of more effort while writing it.
- itsbits 10y agoAgreed. I am yet to formally make my app available but had tough times mainly while doing Ajax calls, typecasting the JSON i got. Infact took time to understand some concepts like ARC, Optional Chaining when you are from JS background.
- jallmann 10y ago> typecasting the JSON i got This is where a typed serialization comes in handy. (Protobufs, Thrift, Cap'n Proto, etc.) It is also possible to use an IDL to generate a type-safe API to deal with JSON -- although I don't know of any tools that emit Swift. Interfacing with third-party JSON APIs can be a pain though.
- tyingq 10y agoMaybe typescript would be a good thing to experiment with first? You could then get used to types in a familiar language first.