completely-unscientific-benchmarks
completely-unscientific-benchmarks copied to clipboard
Swift "naive" impl contradicts the philosophy
The README states
We define the "naive" implementations as those which a developer with enough experience in a given language would implement as a baseline "good enough" solution where correctness is more important than performance.
Yet the Swift Language Guide, which relatively speaking a developer with any experience will spend some time glancing at clearly states:
The additional capabilities that classes support come at the cost of increased complexity. As a general guideline, prefer structures because they’re easier to reason about, and use classes when they’re appropriate or necessary. In practice, this means most of the custom data types you define will be structures and enumerations.
https://docs.swift.org/swift-book/LanguageGuide/ClassesAndStructures.html
Yet the impl uses classes
exclusively contradicting the above two notions
https://github.com/frol/completely-unscientific-benchmarks/blob/86c455f2dfdfc9637dc66760a6d86571dad7cefe/swift/Sources/naive/main.swift#L4
@rex-remind101 good catch! May I ask you to submit a PR?
Nodes need to be moved a lot, so I wouldn't use a struct for it. Also it doesn't build if you try to use a struct:
error: value type 'Node' cannot have a stored property that recursively contains it