News for hackers. Stuff that matters.
Re:The Intuitive Guide to Data Structures and Algorithms by Veedrac on Friday October 13, 2017 @09:29PM (#15470201)
One thing I find generally worth improving with these sorts of introductions is that they always seem to introduce data structures as a pick-and-mix bag of prebuilt parts, rather than a set of techniques which allow you to enforce properties which allow you to build objects that do what you want efficiently. Teaching the former is like teaching a physicist all the different kinds of gear systems, rather than the math that lets you model them.

Knowing how binary heaps and hash maps work is great, because binary heaps and hash maps are very useful data structures, but knowing the fundamental reasons behind them in a way that composes to building new things is much more useful. What happens when you want properties that someone hasn't already built a data structure for, at least as far as you can find? (Pet example: ordered container with efficient append and the ability to query the maximum of any subslice length k in O(log k). Extension: what are the minimal assumptions you need to do better, eg. amortized O(1)?)

I think this contributes to the attitude where programs are built out of monolithic, ill-fitting parts rather than actually looking at the problem and building the solution which does the right thing, the right way. (Pet example: if you designed websites as data structures and the browser to support doing so efficiently, 90% of requests on a site like Reddit would be a single `memcpy`.)

What I would attempt is rather than saying

"Here's one way we could do it: <explaination of pre-baked hash table>."

talk about the underlying tool first

"One tool that can help us is hashing: <explaination of general technique and why its properties are useful>. In this example we want <these properties> but can't immediately get it because our data has <these properties>. But we can apply hashing to get <technique that looks decent but has caveats>. Handling the caveats by doing <hash table things> gives us a data structure called a hash table."

Yes, this is probably a harder way to handle things, but I'd like to think it'd be worth the trouble.

Re:The Intuitive Guide to Data Structures and Algorithms by chrisweekly on Friday October 13, 2017 @11:42PM (#15470591)
That was a clearly-written, knowledgable, info-dense and effective bit of writing you just did, @Veedrac. Ever considered doing more of the same, and delivering the kind of educational material you just described?
Re:The Intuitive Guide to Data Structures and Algorithms by trishume on Saturday October 14, 2017 @03:26PM (#15473748)
You can subscribe to Veedrac's HN comments on RSS like I do. I've found a bunch of people like Veedrac regularly write really interesting things in HN comments, so I wrote an app that lets you subscribe to them: http://hnblogs.thume.ca/
Re:The Intuitive Guide to Data Structures and Algorithms by Veedrac on Saturday October 14, 2017 @09:52AM (#15472166)
I was expecting a far more mixed reaction, so I'm glad to hear this engaged people. Writing educational material to takes more work (and expertise) than I'd be willing to guarantee, but I'll keep the sentiment in mind :).
Re:The Intuitive Guide to Data Structures and Algorithms by catnaroek on Saturday October 14, 2017 @12:48AM (#15470832)
> Teaching the former is like teaching a physicist all the different kinds of gear systems, rather than the math that lets you model them.

Most programming work is less like theoretical physics and more like car repairing.

Re:The Intuitive Guide to Data Structures and Algorithms by yawboakye on Saturday October 14, 2017 @03:53AM (#15471221)
Programming is trial and error. Anybody who tells you otherwise is a salesman.
Re:The Intuitive Guide to Data Structures and Algorithms by catnaroek on Saturday October 14, 2017 @08:51PM (#15475211)
Speak for yourself.
Re:The Intuitive Guide to Data Structures and Algorithms by Dylan16807 on Saturday October 14, 2017 @12:54AM (#15470847)
> (Pet example: if you designed websites as data structures and the browser to support doing so efficiently, 90% of requests on a site like Reddit would be a single `memcpy`.)

You'd still want a compressed form, even if you had a good way to bypass parsing.

Re:The Intuitive Guide to Data Structures and Algorithms by Veedrac on Saturday October 14, 2017 @08:14AM (#15471815)
Ah, yes, I botched that description, since there has to be more to support things like encryption. A more accurate claim is that the bulk of the work currently done would be replaced with a memcpy.
Re:The Intuitive Guide to Data Structures and Algorithms by amelius on Saturday October 14, 2017 @10:37AM (#15472341)
> (Pet example: if you designed websites as data structures and the browser to support doing so efficiently, 90% of requests on a site like Reddit would be a single `memcpy`.)

Formatting a webpage cannot be done by a simple memcpy, especially since you don't know the size of the browser window in advance.

But perhaps I didn't understand the point you were trying to make.

Re:The Intuitive Guide to Data Structures and Algorithms by Veedrac on Saturday October 14, 2017 @11:05AM (#15472464)
I mean on the server-side. Right now the process between "I want thread 35va5k" and "I want to render this html" makes extremely inefficient use of both servers and network.
Re:The Intuitive Guide to Data Structures and Algorithms by scottLobster on Saturday October 14, 2017 @12:51AM (#15470838)
I'm all for stuff like this in theory, but in my experience I never use said knowledge for any productive purpose and eventually it degrades... until I read a post like this, feel a surge of professional inadequacy and go re-learn it. :P
Re:The Intuitive Guide to Data Structures and Algorithms by petra on Saturday October 14, 2017 @07:01AM (#15471646)
Can this be done using software ? can i ask some software/expert-system - i need this and that properties, and it can tell me - "use this structure" ?
Re:The Intuitive Guide to Data Structures and Algorithms by devonkim on Saturday October 14, 2017 @10:16AM (#15472248)
I’ve wondered why we don’t typically use algorithms that will self-adjust when we have so many VMs that can do all sorts of statistical analysis. We know that quicksort is inefficient on smaller and mostly-sorted lists so we oftentimes switch to selection sort below 20 items or so, but we typically have libraries that have statically picked this behavior as directed by their developers instead of over time selecting the more appropriate algorithm. Sure, if you’be never seen the data before there’s not a lot you can assume, but if over a lot of executions your VM can perform native code substitution and replace certain sections of code out based upon runtime profiling in HotSpot why can’t we come up with heuristics that say “just use a list instead of a hash table until runtimes to access start getting slower than n, in which case reallocate the data to a hash table, btree, or a heap depending upon which operations are most sensitive to system design parameters.” A lot of problems seem like we’re repeating ourselves writing the base algorithms and gluing things together when we really should be investing problems around resource constraints and system trade-offs and priorities. Then we could run test suites against these systems to determine how well they’d meet certain guarantees programmed in.
Re:The Intuitive Guide to Data Structures and Algorithms by petra on Saturday October 14, 2017 @11:59AM (#15472708)
Yep, great idea.

>> A lot of problems seem like we’re repeating ourselves writing the base algorithms and gluing things together when we really should be investing problems around resource constraints and system trade-offs and priorities

What's the minimal platform that would enable library developers to monetize such things ? and does it or something close to it exist ? because that seems like the fastest way to make this happen.