Live data from Hacker News

Rob Pike’s Rules of Programming (1989)

users.ece.utexas.edu

101–110 of 332 posts

Re: Rob Pike’s Rules of Programming (1989)

#101

Earlier quoted context omitted.

Yep. And if what you have is an Abelian Group, then you also get distributed computation as well (thanks to commutativity).

While true, that's too strict. An Abelian group (like any group) needs inverses. You get distributed computation if you've got an Abelian semigroup.

To be fair, Abel did not know (or care) about semigroups.

Re: Rob Pike’s Rules of Programming (1989)

#102
post #29

Earlier quoted context omitted.

Using array based data structures also get you more cache hits. For smaller data sets, this may well be faster than a fancy algorithm.

This is true only if you are iterating over the entire array often. If you only rarely need to access one data member the array will not be in cache and so you have less to load from memory. Depending on how your data is structured the array may or may not save time even in small sizes.

Of course temporal and spatial locality are important.

Re: Rob Pike’s Rules of Programming (1989)

#103
post #95

Earlier quoted context omitted.

> Bad programmers worry about the code And yet, I see a whole swath of the industry hyper-focused on various linters/styling/rules.

And that’s because it’s Bad Programmers who need help!

... and "rules" for programming.

Re: Rob Pike’s Rules of Programming (1989)

#105

In long-lived systems (systems that run for many years) it's almost impossible to choose the "right data structures" for the ages. The sources and uses of your data will not last nearly as long as the data itself. What to do about this? Two things: STORE YOUR TIMESTAMPS IN UTC. NOT US Pacific or any other local timezone. If you start out with the wrong timezone you'll never be able to fix it. And generations of progr…

Sometimes storing in UTC is simply not correct. For example a shop opening time. The shop opens 10am local time, whether DST or not. Their opening time is 10am local time all year but their UTC opening time actually changes depending on the time of year!

Re: Rob Pike’s Rules of Programming (1989)

#107

Earlier quoted context omitted.

You can distribute the computation on just a monoid as well but it needs more bookkeeping. In particular, your reduce function should know * lhs is before rhs * There is no data between lhs and rhs

One way of looking at it is that equipping our data with that bookkeeping gives us something that commutes.

Hmm sure, but it is not a requirement that your underlying algebraic structure should commute, so I think original phrasing was misleading. The bookkeeping allows you to commute a specific list of objects, even though the underlying operation is anti-commutative (i.e. exists a,b a.b != b.a).

At the moment of computation, you can build a new structure that commutes by enumerating the data. I guess it's true that you need a commuting intermediate data structure to be able to distribute.

Re: Rob Pike’s Rules of Programming (1989)

#108
post #80

> Rule 5. Data dominates. If you've chosen the right data structures and organized things well, the algorithms will almost always be self-evident. Data structures, not algorithms, are central to programming. That one hits me in the feels because I think a lot of folks focus on algorithms (including myself), and code patterns, before their data and as a result a lot of things end up being harder than they need to be.…

It's worth noting the same holds true for UI: data dominates. Design your widgets, layout, and workflow around the data.

> It's worth noting the same holds true for UI: data dominates. Design your widgets, layout, and workflow around the data.

I couldn't agree more.

I think the current state of UI programming is like the pathological case to be honest. Too often folks are concerned with representing their database 1-to-1 in their UI instead of representing their view.

If anyone is suffering from brittle UI code, where somehow caching issues and stale data are affecting your application, this is very likely why. You have muddled your persistence and view concerns together and it's not manageable or pretty. What this means for folks using something like React- don't directly use your persistence models in your views, create "view models" which directly represent whatever the hell it is you're trying to display. Bind your data in your view models, and not your views, and then pass the view model in as props.

Re: Rob Pike’s Rules of Programming (1989)

#109
post #95

Earlier quoted context omitted.

> Bad programmers worry about the code And yet, I see a whole swath of the industry hyper-focused on various linters/styling/rules.

And that’s because it’s Bad Programmers who need help!

but... they need help on data structures/relations and up front thinking about those issues, not where curly braces should go, or tabs-v-spaces.

Re: Rob Pike’s Rules of Programming (1989)

#110

> Tony Hoare's famous maxim "Premature optimization is the root of all evil." Actually that was Donald Knuth - it's an urban legend that it's an urban legend that it was originally Knuth. Hoare was quoting Knuth, but Knuth forgot he said it, and re-mis-attributed the quote to Hoare.

And it is usually quoted out of its context.

"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%."

Post reply on HN