4 ms·
This is similar to other types languages no ?
by isanjay 3y ago
This is similar to other types languages no ?
- rcme 3y agoKotlin is the only statically typed language that has the same ergonomics as Go (that I know of), and even then you need an external dependency.
- beatbrot 3y agoJava can do the same with a library like Gson or Jackson
- didip 3y agoJackson is no where near as convenient as Go's marshaling system.
- isanjay 3y ago.NET has System.Text.Json. I wonder how does it compare to go's implementation
- rcme 3y ago.NET is ok, but the classes you make serializable generally aren't how you'd write a normal class, which is what I mean by "ergonomic." As far as I know, you need your fields to be public for both reads and writes, and you need to write a separate constructor if you want to create the types programmatically. Go lets you serialize objects more-or-less how you'd write them without serialization, as does Kotlin.
- hakanderyal 3y agoRecord types introduced in C# 9 solves this. It's now as simple as record SomeData(string Name, int Id); Which gives you an immutable object, auto generated constructor, and some additional helpers to make life easier.