top | item 7994268

(no title)

hnkain | 11 years ago

I don't think the author's interpretation of #5 to mean use smart objects (which I'll guess means objects in the object-oriented sense) is correct. I interpret Pike's meaning to be to use dumber objects that make the data visible and obvious. That's also consistent with Go's emphasis on simple datatypes.

It's very close (in my opinion) to a restatement of Brook's quote "Show me your flowcharts and conceal your tables, and I shall continue to be mystified. Show me your tables, and I won’t usually need your flowcharts; they’ll be obvious."

discuss

order

derefr|11 years ago

No, it doesn't mean objects in the object-oriented sense. It means something more like "don't build an array and then iterate through it to get the minimum item, if you could just build a minheap." I.e., if you can, use data structures that do the heavy lifting of your algorithms "for free."

wging|11 years ago

Total tangent, but it occurs to me that if all you want is the minimum item, you maybe don't even need a minheap. You can just keep a single item--the smallest--and replace the operation of adding to the array with the operation of compare-and-possibly-replace.

robert_tweed|11 years ago

Exactly. There seems to be a huge amount of confusion here about this. Beyond that quote (which is excellent, btw) there's the point that creating machine-efficient data structures requires understanding the limitations of the architecture and packing the data in a way that it can be accessed efficiently by whatever algorithm you plan to use.

Things like whether you have an array of structs or a struct of arrays can have a massive effect on how the same algorithm will perform, because of factors like data locality, alignment and cache coherence (the latter mainly if it's a concurrent algorithm).

The trouble with studying algorithms without actually working on optimisation in a low-level language like C or Go is that it completely abstracts away what is really happening in the hardware, which is absolutely critical to real-world performance. In a LISP-like language you generally have no idea what the compiler is actually doing.

warmfuzzykitten|11 years ago

No, that's almost diametrically opposed to the intent of #5. I'm not even sure object programmers know what a data structure is. Likewise, using a minheap because you sometimes need to find the minimum value of an array is the opposite of #4.