protobuf-swift icon indicating copy to clipboard operation
protobuf-swift copied to clipboard

Classes VS Structs

Open NachoSoto opened this issue 9 years ago • 7 comments

I noticed that the generated Swift code uses classes to represent data. Was there a reason behind using classes instead of structs?

Thank you!

NachoSoto avatar Mar 02 '15 00:03 NachoSoto

In the official languages (C++ / Java / Python) - PB used classes. Therefore, I use classes.

alexeyxo avatar Mar 02 '15 10:03 alexeyxo

I will add new option for generate structs instead of classes. But by default pb-swift will generate classes.

alexeyxo avatar Aug 01 '16 09:08 alexeyxo

:+1:

NachoSoto avatar Aug 01 '16 10:08 NachoSoto

It would be interesting to run some performance tests and see what difference it makes to common operations.

DouglasHeriot avatar Aug 01 '16 13:08 DouglasHeriot

FYI, the official Google Protobuf project is planning to use structs once they get to Swift generation. I think their reasoning is sound, and I'd love to see this happen.

https://github.com/google/protobuf/pull/1442

dpassage avatar Aug 01 '16 18:08 dpassage

Wow, does the protobuf project have anyone actively working on a Swift implementation? Is it possible to resolve the BSD/Apache license difference between protobuf-swift and protobuf, and one day have protobuf-swift become the official Swift implementation? Doesn’t really make sense to duplicate all this work.

DouglasHeriot avatar Aug 02 '16 03:08 DouglasHeriot

@DouglasHeriot Change license - it is no problems.

alexeyxo avatar Aug 02 '16 17:08 alexeyxo