Live data from Hacker News

Drop millions of allocations by using a linked list

github.com

141–150 of 158 posts

Re: Drop millions of allocations by using a linked list

#141
post #117

Earlier quoted context omitted.

Sort of... technically only the '+' operator only applies to strings... however it is essentially the same issue as the pull request, from what I can gather (I assume the issue comes from allocating a new array with size length+1 and copying the original each time a record is added). Same thing happens with java.util.ArrayList.add() and its cousins though, and from my experience people rarely use the constructor spec…

Java's JIT compiler optimises string concatenation by substituting a StringBuilder and has been doing so for a while. As to using the wrong data type, that's really the programmer's fault. If you don't allocate enough capacity or use another data type (e.g. LinkedList) if you don't know the required capacity, you are doing a bad job.

To nitpick, Java's JIT compiler compiles Java bytecodes to machine code, but I know that javac does to the type of optimization that you are describing. There are plenty of scenarios though where it can't/won't do that optimization ... and if you are using the binary version of a library compiled without that optimization I'm pretty sure you're out of luck, especially if the method you're calling is not JIT'd.

I'm not really trying to knock any particular language or runtime here, the point I was trying to make is that nearly every language I've used has quirks that encourage convenience over optimization, and that just because you're coding in language foo, it doesn't mean you're off the hook when it comes to being intentional about the choice between them.

Re: Drop millions of allocations by using a linked list

#142
post #115

Earlier quoted context omitted.

You can be proud of your achievements without being smug. Also, hubris being a virtue is crap. It may be decent for your self esteem but it makes you miserable to be around. Case in point: Larry Wall.

Agreed, hubris is not a virtue. Merriam-Webster - hubris - "a great or foolish amount of pride or confidence" It's just a synonym used for arrogance and smugness. Humbleness is a virtue.

From the way you phrased this, I think You may have missed the context link a couple comments above. Everyone is aware of what hubris means and that it's not a virtue per se. The point of the linked page is that it's (somewhat tongue-in-cheek) taking three vices and positioning them as virtues in a narrow context. It's just semantics; the saying could easily have used synonyms that have positive connotations, but using negative words instead is part of the joke.

Re: Drop millions of allocations by using a linked list

#143

Earlier quoted context omitted.

Agreed, hubris is not a virtue. Merriam-Webster - hubris - "a great or foolish amount of pride or confidence" It's just a synonym used for arrogance and smugness. Humbleness is a virtue.

From the way you phrased this, I think You may have missed the context link a couple comments above. Everyone is aware of what hubris means and that it's not a virtue per se. The point of the linked page is that it's (somewhat tongue-in-cheek) taking three vices and positioning them as virtues in a narrow context. It's just semantics; the saying could easily have used synonyms that have positive connotations, but usi…

Yes; apparently I had. Thanks.

Re: Drop millions of allocations by using a linked list

#144
post #59

I'm not a ruby dev, so I guess maybe my perspective is not that great on this particular issue... but hats off to the dev with the fix, indeed this is how free software collaboration is supposed to work in my opinion. Even the dev with the fix wasn't rude about the original problem, he seemed pretty humble about it actually. If you think the Ruby guys are such shitty programmers you should be able to dive into their…

>so either give them a pull request or STFU Most people have neither the time nor inclination to fix problems with the language they use. If I buy a power saw and it turns out to be a POS, I just won't buy that brand again.

You're talking about OSS - you didn't buy it. OSS does not entitle you to anything. Tenderlove and the Rubygems maintainers spend their time so you don't have to. If it doesn't fit your needs - okay. But don't act as if somebody owes you anything.

Re: Drop millions of allocations by using a linked list

#145

Earlier quoted context omitted.

> Even the dev with the fix wasn't rude about the original problem, he seemed pretty humble about it actually. The Ruby community is very good interpersonally from my experience. It's a culture that I think comes from this: http://en.wikipedia.org/wiki/MINASWAN

Unfortunately, the rails community are the visible minority, and they follow DHH's example more than Matz's.

David Heinemeier Hansson[1] for anybody else that was confused about what "DHH" referred to.

[1]: http://en.wikipedia.org/wiki/David_Heinemeier_Hansson

Re: Drop millions of allocations by using a linked list

#146

Earlier quoted context omitted.

>so either give them a pull request or STFU Most people have neither the time nor inclination to fix problems with the language they use. If I buy a power saw and it turns out to be a POS, I just won't buy that brand again.

You're talking about OSS - you didn't buy it. OSS does not entitle you to anything. Tenderlove and the Rubygems maintainers spend their time so you don't have to. If it doesn't fit your needs - okay. But don't act as if somebody owes you anything.

Once you have a product, free or not, which is used and relied upon by a large group of people, you do owe them something. if you don't want that responsibility then don't release your code or get out when things become serious. I get the OSS philosophy, and I like many things about it, but I also understand why some won't touch it with a ten foot pole.

"Oh, I made a boneheaded error and now your code is 100x slower than it should be? Tough sh*t, fix it yourself. I owe you nothing!"

That's not a reasonable mentality to have if you want adoption. Obviously the Ruby devs don't feel this way, but you seem to. That sort of attitude is nonsense and short sighted.

Re: Drop millions of allocations by using a linked list

#147
post #51

I'm really surprised by the amount of smugness in the comments here. A bit of good-natured teasing, followed by a wheelbarrow full of "ruby-devs" this and "web-devs" that. Take off your Hats of Superior Coding. Any one of us, regardless of honorific titles, could have made this mistake, and you know it. Being steeped in CS Fundamentals does not immunize you against bugs. Congratulations to tenderlove for finding the…

I think that Arrays are so ubiquitous and (usually) so fast that most devs reach to them by default unless there's a good reason not to. I can count on one hand the number of times a linked list has really truly been the correct solution to a programming problem I've faced.

Yet "most devs" aren't developing mainstream programming languages (nor should they). I can forgive e.g. a front-end dev for making that sort of mistake, but a language designer/implementer? No, sorry, you should know your data structures. You should be profiling this stuff and this many allocations should set off alarms. Modeling memory allocations and complexity in time and space should be second nature and, if not, should be understood before moving on.

Re: Drop millions of allocations by using a linked list

#148

Earlier quoted context omitted.

You're talking about OSS - you didn't buy it. OSS does not entitle you to anything. Tenderlove and the Rubygems maintainers spend their time so you don't have to. If it doesn't fit your needs - okay. But don't act as if somebody owes you anything.

Once you have a product, free or not, which is used and relied upon by a large group of people, you do owe them something. if you don't want that responsibility then don't release your code or get out when things become serious. I get the OSS philosophy, and I like many things about it, but I also understand why some won't touch it with a ten foot pole. "Oh, I made a boneheaded error and now your code is 100x slower…

Please describe why you believe the product owners owe the userbase something.

Re: Drop millions of allocations by using a linked list

#150

Earlier quoted context omitted.

You're talking about OSS - you didn't buy it. OSS does not entitle you to anything. Tenderlove and the Rubygems maintainers spend their time so you don't have to. If it doesn't fit your needs - okay. But don't act as if somebody owes you anything.

Once you have a product, free or not, which is used and relied upon by a large group of people, you do owe them something. if you don't want that responsibility then don't release your code or get out when things become serious. I get the OSS philosophy, and I like many things about it, but I also understand why some won't touch it with a ten foot pole. "Oh, I made a boneheaded error and now your code is 100x slower…

> Tough sh*t, fix it yourself.

I never said that, but most projects welcome pull requests.

> I owe you nothing!

True, it's the short version of the MIT license.

> That's not a reasonable mentality to have if you want adoption.

Yes, maintainers should always try to take care of their projects and to accommodate the needs of their communities.

> Obviously the Ruby devs don't feel this way, but you seem to.

You are over-interpreting. But I hate seeing more and more OSS contributors getting burnt out and steamrolled by a self-entitled rout.

Post reply on HN