4
12bitfloat
131d

Man, I always miss Rust whenever I'm using another language ;_;

Exhibit A: Serialization and deserialization

With serde in Rust you just derive the Serialize/Deserialize trait with a simple annotation and now you can magically serialize/deserialize the struct with any serde backend, whether JSON, YAML, some binary format, whatever

Currently doing C# and I just want to cry ;_;

Comments
  • 2
    except if you serde hashmaps into json format then you gotta make your own keying system
  • 3
    @afaIk he is talking about C#, not C++.
    Your comment sounds like AI btw.
  • 3
    @12bitfloat I‘m curious if the 3rd party lib from Newtonsoft is still the de facto standard for json serialization in C# 😅

    But I can relate:
    In Swift you just conform to Encodable/Decodable and the struct is ready to go for whatever serialization format that you like.
  • 3
    @afaIk it‘s not even relevant if it‘s true because it‘s about a different topic.

    Not only did it compare the wrong languages but it also talked about abstractions and safety, which is not directly related to the topic of serialization.

    Useless pseudo intellectual crap.
  • 3
    @Lensflare The current project I'm working on just uses System.Text.Json.Serialization and .. it honestly works pretty well. With the right annotations on my models, it seems to get everything right. It looks like we're still using Newtonsoft though in parts of the project. I think anything that has to write to Mongo needs to use it as that's their drivers JSON library .... and yes we use Mongo and it's as terrible as it sounds. 😩
  • 1
    @jestdotty HashMaps work perfectly fine in serde. Unless you need ordered "VecMaps"... don't ask me how I know lol
  • 1
    @Lensflare Can you derive them in Swift? I.e. let the compiler give you a default impl (optionally with some extra annotations on fields for specializing it a little)
  • 3
    @whimsical Like a lot of things sadly :(

    I like C# but a lot of it feels kinda old and clunky
  • 2
    @whimsical I've heard of Nim, but never really looked into it. Just looking at the website, I see that it seems to have Python-like (whitespace) syntax?! I love Python and I really hate semicolons ... but Python really isn't good as a system programming language. I might need to look into this.

    I wrote this in Mono back in the day:

    https://github.com/sumdog/...

    I really liked C#/Mono, but Gtk# stopped being maintained and it just became a hassle to keep it running, so I rewrote it in Python for mpv:

    https://gitlab.com/djsumdog/...
  • 2
    @whimsical

    > Seriously, did someone ever used Mono professionally?

    Yup, when I was using Xamarin.
  • 1
    @12bitfloat yes you just derive the struct from Codable and the compiler synthesizes everything for you.
    Customization can be done either via annotations on particular properties or via the serializer for overall rules like casing.
  • 2
    @whimsical I don’t have anything bad to say about Mono. Which is a compliment already.
    Xamarin however, what a shit fest!
  • 1
    @whimsical

    > sure, everything comming from you is considered a compliment.

    It’s most certainly not! 😅

    > I've noticed that you didn't upvote my nice comment to doggii man. Is that personal? Asking for a friend.

    Doggii man? Do you mean kiki with the hotdog comment? I think I did ++ that.
    Not that I need to explain myself when I don’t ++ ^^
Add Comment