←back to thread

42 points todsacerdoti | 1 comments | | HN request time: 0s | source
Show context
PaulHoule ◴[] No.42190446[source]
I think is forgotten here that one of the benefits of nominal typing is that the compiler can know that data layout at run time so performance benefits.

There has been so much ink spilled on the question of what kind of type systems help programmers be productive but there is not such controversy on the performance side.

replies(3): >>42190752 #>>42191794 #>>42199051 #
lmm ◴[] No.42191794[source]
Premature optimisation is the root of all evil. If you get the semantics right then good performance will generally follow, if you make the wrong thing then it doesn't matter how fast it is.
replies(4): >>42191922 #>>42192250 #>>42192332 #>>42194078 #
biorach ◴[] No.42192250[source]
> Premature optimisation is the root of all evil

If you're going to quote Knuth you better be damn sure you've fully understood him.

The quote in question is about micro-optimisations which were pointless on account of design issues. The situation you are commenting on is kind of the opposite.

replies(1): >>42193643 #
1. PaulHoule ◴[] No.42193643{3}[source]
I would say this debate

https://en.wikipedia.org/wiki/AoS_and_SoA

(which I think is weakened in the Wikipedia version) goes to the heart of where profiling can hide huge opportunities for optimization.

It is a good prop bet that rewriting something (that doesn't allocate lots of dynamic memory) that is SoA style in AoS style will speed it up significantly. The victim is emotionally attached to their code and the profiler would never show you the many small costs, often distributed through the memory system, that add up. In a case like that they might accuse you of cheating by applying a bunch of small optimizations which are often easier to express in SoA if not downright obvious. When they apply the same optimizations to their code they will speed it up but not as much.

Oddly it's a discussion that's been going on even since people were writing games in assembly language in the 1980s and probably since that; it would be interesting to see more tools which are AoS on the inside but look SoA on the outside.