4 ms·
> C# (structs or maybe properties) Those are not directly analogous to records. As a matter of fact, C# is getting records as well: https://blog.cdemi.io/whats
by apta 7y ago
> C# (structs or maybe properties)
Those are not directly analogous to records. As a matter of fact, C# is getting records as well: https://blog.cdemi.io/whats-coming-in-c-8-0-records/ https://blog.cdemi.io/whats-coming-in-c-8-0-records/
- statictype 7y agoThis looks like syntactic sugar for comcepts that already exist? I think in Java’s case, its only mow getting struct-like semantics edit I may be wrong. It could be a purely syntax level feature in Java as well.
- paulddraper 7y agoJava records are syntax sugar. Value semantics are proposed in JEP 169 [1] and are part of Project Valhalla. [2] [1] https://openjdk.java.net/jeps/169 https://openjdk.java.net/jeps/169 [2] https://wiki.openjdk.java.net/display/valhalla/Main https://wiki.openjdk.java.net/display/valhalla/Main
- to11mtm 7y agoC# has had records slated for years without delivery, alas. Thankfully we do finally have a version in testing. In any case to answer GP, structs should not be considered a valid substitute for records, they are 'value types' so passing them around means you copy all the data every time you pass (i.e. lots of allocations if the record is larger than 1 or 2 fields) Properties get you 'closer'. You can do some code Which is a good bit less than Java by default (i.e. not Lombok or similar) F# does have Records, and technically there's nothing stopping you from declaring your records in F# and importing them into C#... but that may not be ideal. I don't think you get the full benefits (like copying a record with specific properties changed)