Live data from Hacker News

Drop millions of allocations by using a linked list

github.com

11–20 of 158 posts

Re: Drop millions of allocations by using a linked list

#11
Great pull request. Ruby makes it easy to duplicate data by calling `.dup` or `+`, and this does help with state isolation. But duplication is an expensive operation.

Ruby's standard libraries don't have much support for immutability, or deep cloning, or copy on write, or linking concatenation. There's no standard library way to ask for a snapshot of an object.

So in the early days for Ruby, an idiom was: if you're writing a method that takes a list, and you need to be sure your list doesn't change out from under you, then duplicate it, get it working, and if it becomes a bottleneck then optimize it.

Re: Drop millions of allocations by using a linked list

#13
post #5
post #4

Just comes to show how careless Ruby guys were while building this.

1. Make it work 2. Optimize

"The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet." — Michael A. Jackson

Re: Drop millions of allocations by using a linked list

#14
post #5

Earlier quoted context omitted.

1. Make it work 2. Optimize

"The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet." — Michael A. Jackson

I prefer full quote from Knuth:

    "Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. 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%."
I have the problems with many happy-coders that they only remember the part about about not optimizing early and often forget that part when you should measure performance, find bottlenecks and get rid of them.

Re: Drop millions of allocations by using a linked list

#16

I'm not very familiar with Ruby; where exactly did the duplication occur in the original code?

I believe it's in the Gem::Specification.traverse method here:

http://ruby-doc.org/stdlib-1.9.3/libdoc/rubygems/rdoc/Gem/Sp...

The 'trail' parameter, an array, was implicitly duplicated by applying the '+' operator on each recursion through a dependency.

Re: Drop millions of allocations by using a linked list

#17
post #6
post #3

Ruby people discovering algorithms ducks

Really. Every time I whine publicly how web programming people aren't familiar with even basic CS, I get a slap. But really, I should move to web programming. I'll be an expert computer scientist there, probably.

Annnndddd.... what reaction do you expect? "Oh, please come and do web development so we can bask in the glow of your self-righteousness and infinite knowledge of computers."

/snark (apologies for being offensive, but good lord, what a silly statement - unless I missed the joke)

I stand before you as a counterpoint to your foolish generalisation, and guess what, I know plenty of other people that don't fit your stereotype either.

I'm not saying there's not an element of truth to your statement. See, here's the thing. People throughout the software (or any) industry have different collections of knowledge. There are an endless number of things to learn and each one of us is different and brings a different set of skills to the table.

To be great at web development you spend years learning the subtleties of developing for a vast domain of different platforms. There are bugs in the platforms decades old that I know the intimate details of and have workarounds for especially constructed to fit in with the other bugs in the other platforms we deal with. And that's a tiny facet of what you need to know.

You know what would really happen when you came over to web development? You'd find that a lot of the skills as a computer scientist aren't altogether useful.

You wouldn't be an expert computer scientist. You'd be a junior developer, probably.

Re: Drop millions of allocations by using a linked list

#19
post #17
post #6

Earlier quoted context omitted.

Really. Every time I whine publicly how web programming people aren't familiar with even basic CS, I get a slap. But really, I should move to web programming. I'll be an expert computer scientist there, probably.

Annnndddd.... what reaction do you expect? "Oh, please come and do web development so we can bask in the glow of your self-righteousness and infinite knowledge of computers." /snark (apologies for being offensive, but good lord, what a silly statement - unless I missed the joke) I stand before you as a counterpoint to your foolish generalisation, and guess what, I know plenty of other people that don't fit your stere…

I keep repeating myself on Hacker News, but once more, we've found the difference between Software Engineer and Computer Scientist. One makes things work, the other is a mathematician.

Why do we keep conflating the two?

Re: Drop millions of allocations by using a linked list

#20
post #17
post #6

Earlier quoted context omitted.

Really. Every time I whine publicly how web programming people aren't familiar with even basic CS, I get a slap. But really, I should move to web programming. I'll be an expert computer scientist there, probably.

Annnndddd.... what reaction do you expect? "Oh, please come and do web development so we can bask in the glow of your self-righteousness and infinite knowledge of computers." /snark (apologies for being offensive, but good lord, what a silly statement - unless I missed the joke) I stand before you as a counterpoint to your foolish generalisation, and guess what, I know plenty of other people that don't fit your stere…

I completely agree that software development is such a vast field that it is completely impossible to be proficient in everything. I am kind of a lamer in web development, for example.

But fundamental CS is a different thing.

"Annnndddd.... what reaction do you expect?"

Admitting your shortcomings and try to fix them is not an option at all?

When some central web frameworks do lamest mistakes like making an O(n^2) queue, it is frightening. And instead of deflecting any critique, one may try to fix this situation somehow.

Post reply on HN