5

Swift does some things really well, but then falls flat in others. Why is polymorphic JSON decoding/encoding such a pain?
In Kotlin, it's a breeze to support multiple object types.

Comments
  • 1
    @Lensflare holy fuck, someone is complaining about swift! :P My swift adventure came to an end tho. I'm just satisfied with C#. Can't find the motivation to learn swift. Also, I have the feeling while it works on Linux, it will be always more Apple specific. Yes, I do get the irony with that since i'm using C# :P I dunno, C# just feels good.
  • 1
    I read swift has sum types. Shouldn't they allow that?
  • 2
  • 2
    @null-pointer-ex

    This isn‘t very obvious but there is a relatively simple way to do that.

    See my examples here:

    hthttps://github.com/WilhelmOks/... can even make it completely generic and support an arbitrary number of Decodable types.

    I thought about making a lib for that but then I thought that it wouldn‘t be the right way to solve this.
    IMO, if the api does this, it‘s crap. The api should be fixed.
    Now that you are complaining about this use case as well, maybe I should really make a lib. :)
  • 1
    @retoor Swift isn’t perfect.

    For example, Kotlin has insanely good syntax for constructors and initialization and is much better than what Swift has to offer in that area.

    Another issue in Swift is that it‘s not possible to have default values in function parameters which refer to the current instance of the type. In Kotlin it's not a problem.

    Swift is better in anything else, though, IMO.

    C# is fine, too. But personally it‘s too outdated for me. I can‘t go back after using Swift and Kotlin.
  • 1
    Link seems broken, here it is again:

    https://github.com/WilhelmOks/...
  • 1
    @Lensflare thanks for the snippet.
Add Comment