|
NotShadowStar posted:Looks like another Java or PHP programmer doesn't understand Rails. I bet that was in a controller too. nah thats in a model And how does conditionally interpolating "LIMIT ?" into the query open this to SQL injection? Notice the actual value isn't interpolated. (It's building a string to be used with find_by_sql, the values are later added to the end of that array, but I assumed the "?"'s made that obvious) Unfortunately though I'm the developer in question here :\ This query fetches from each user's top score (ordered by judgement) on a chart, the top n scores from each of a given set of charts. This monstrosity happened because I don't want to pull every score into the app just to filter them in Ruby. Can ActiveRecord actually help me here? Xenogenesis fucked around with this message at 04:41 on Dec 8, 2010 |
# ? Dec 8, 2010 04:30 |
|
|
# ? Apr 27, 2024 09:26 |
|
ActiveRecord 2 or 3?
|
# ? Dec 8, 2010 04:42 |
|
NotShadowStar posted:ActiveRecord 2 or 3?
|
# ? Dec 8, 2010 04:54 |
|
|
# ? Dec 8, 2010 05:13 |
|
Someone made this at work in response to the insane requests people made of him: (redacted to protect the guilty) Click here for the full 1284x1000 image.
|
# ? Dec 8, 2010 06:58 |
|
From a client's project: in the test suite there are lovely blocks like:code:
|
# ? Dec 8, 2010 07:02 |
|
Bozart posted:Someone made this at work in response to the insane requests people made of him: I've also seen "Bug: Square Peg does not fit into Round Hole", which exists solely so that tickets can be closed as a duplicate of it....
|
# ? Dec 8, 2010 14:14 |
|
We just have the status "Resolved (Muppet)"
|
# ? Dec 8, 2010 15:07 |
|
npe posted:I've also seen "Bug: Square Peg does not fit into Round Hole", which exists solely so that tickets can be closed as a duplicate of it....
|
# ? Dec 8, 2010 15:21 |
|
ColdPie posted:Hahahahahahahahahahahaha
|
# ? Dec 8, 2010 17:24 |
|
Orzo posted:Missing why this is funny except for a childish jab at IE, isn't IE9 supposed to be wicked fast, like way faster than Chrome/Firefox/Safari? Well, it's "supposed" to be, but actual benchmarks have shown it to be somewhere around Firefox 3.5. Still better than IE6, but nowhere near FF4 or whatever Chrome's at. Interestingly, it might in reality be even slower; IE was caught cheating on Sunspider, by special-casing a few particular functions. Inserting things like "if (false) {}" into the code, or changing the order of variable assignment, can cause it to revert to previous (slow) performance.
|
# ? Dec 8, 2010 17:51 |
|
Xenogenesis posted:2 Ergh. It's certainly possible to get rid of that monstrosity, but it requires named scopes on associated models. You really should look into that, maintaining that thing is going to be your albatross. quote:Interestingly, it might in reality be even slower; IE was caught cheating on Sunspider, by special-casing a few particular functions. Inserting things like "if (false) {}" into the code, or changing the order of variable assignment, can cause it to revert to previous (slow) performance. That's not entirely true. MS was optimizing Javascript like it was a static language. Some of the dynamic sunspider loops were instantly optimized away as dead unreachable code incorrectly. This would affect real world code as well.
|
# ? Dec 8, 2010 17:58 |
|
Janin posted:Interestingly, it might in reality be even slower; IE was caught cheating on Sunspider, by special-casing a few particular functions. Inserting things like "if (false) {}" into the code, or changing the order of variable assignment, can cause it to revert to previous (slow) performance.
|
# ? Dec 8, 2010 18:05 |
|
Orzo posted:I'm not an IE apologist by any means, but this issue is not as simple as 'they were caught cheating' and it's irresponsible to state that as if it were true. Their dead-code analysis is in theory general-purpose, but is in practice A) incredibly fragile, and B) oddly works very well on SunSpider.
|
# ? Dec 8, 2010 18:09 |
|
Aleksei Vasiliev posted:How about "specifically optimizing for SunSpider"? Where fragile means adding nops in the dead code caused it to break.
|
# ? Dec 8, 2010 18:10 |
|
So it is dead-code analysis that gets broken by dead code?
|
# ? Dec 8, 2010 18:13 |
|
ErIog posted:Do we know yet if that behavior is different in IE9? Microsoft seems like they understand that the old versions of IE were abominations with the decisions they've been making with IE9. The problem is going to be what IE9 supports: Vista and 7. They aren't going to do a version for XP because it would involve backporting a lot of system libraries and technologies. This means that the latest version of IE available for XP is going to remain IE8. As long as XP exists in the wild, we are going to need to support IE8. And 7, and 6. Microsoft will be patching XP through the spring of 2014. An unfortunate number of corporate users are going to be using XP even past that point, and who knows how long home users will stick with it. We're probably going to be dealing with the fallout for the next five years, if not longer. That is the coding horror.
|
# ? Dec 8, 2010 18:15 |
|
Vanadium posted:So it is dead-code analysis that gets broken by dead code? Or maybe you were just making a humorous statement that wasn't meant to be taken seriously, either way I'm just trying to point out how absurd the argument against Microsoft here is.
|
# ? Dec 8, 2010 18:30 |
|
Orzo posted:Or maybe you were just making a humorous statement that wasn't meant to be taken seriously, either way I'm just trying to point out how absurd the argument against Microsoft here is. I think you haven't actually read the analysis into this. http://digitizor.com/2010/11/17/internet-explorer-9-caught-cheating-in-sunspider-benchmark/ http://news.ycombinator.com/item?id=1913315 The dead code analysis seems to be very very specific in this case.
|
# ? Dec 8, 2010 18:45 |
|
Zombywuf posted:I think you haven't actually read the analysis into this. I think you haven't actually read the analysis into this all the way. http://arstechnica.com/microsoft/news/2010/11/lies-damned-lies-and-benchmarks-is-ie9-cheating-at-sunspider.ars Some changes to the CORDIC code were noticed by the optimization while others weren't. It's not simply a case of Microsoft programming a cheat to one of many pieces of one of many synthetic browser benchmarks. The reason it's not uniform is because dead code analysis is really difficult to do, and so it is usually done extremely conservatively. ErIog fucked around with this message at 19:00 on Dec 8, 2010 |
# ? Dec 8, 2010 18:57 |
|
Aleksei Vasiliev posted:How about "specifically optimizing for SunSpider"? Because SunSpider is just dead code* and was probably a popular test case because of that. Even after breaking the dead code removal, it takes about twice as long as Chrome in the benchmarks I saw. Chrome being pretty loving fast, that's not really bad at all. *If you look at the source, you'll notice it doesn't return anything at all or change anything in the global scope.
|
# ? Dec 8, 2010 19:07 |
|
Orzo posted:You make it sound like writing something to eliminate 'dead code' is trivial. It isn't. You have to be extremely careful when writing an optimization like that since it's so dramatic (removing entire blocks of code). Who knows what the internal implementation is? All we know is that adding some things makes it not work anymore, and even if they look like completely trivial additions, it's entirely plausible that the algorithm pessimistically gives up (as it should) rather than making the statement that Microsoft is cheating (poorly) on one of many, many browser tests. The examples I saw were adding lines like "if (false) {}" and "true;" in the middle or "return;" at the end. I understand the whole thing is not trivial but I am not sure I can figure out why you would be able to carefully deduce that this entire function is dead code, but some more pretty-obviously-dead code throws it off. What I took away from the hackernews discussion I had read earlier is that the consensus was that IE is pretty obviously just targetting this specific test with its optimisation, and it pretty much not applying to any other code, even code that is fundamentally similar. I guess if that makes me misinformed, by all means take it as an attempt at a humorous observation of the post preceding mine.
|
# ? Dec 8, 2010 19:08 |
|
ErIog posted:Some changes to the CORDIC code were noticed by the optimization while others weren't. It's not simply a case of Microsoft programming a cheat to one of many pieces of one of many synthetic browser benchmarks. The reason it's not uniform is because dead code analysis is really difficult to do, and so it is usually done extremely conservatively. It has almost certainly been fixed to the point where it works on exactly sunspider and left at that. As opposed to, you know, working generally. This isn't "cheating" exactly, which I never claimed, just pretty lovely. It's the same mechanism why windows starts to run slowly after you've used it for long enough to close a sales contract.
|
# ? Dec 8, 2010 19:14 |
|
Orzo posted:You make it sound like writing something to eliminate 'dead code' is trivial. It isn't. You have to be extremely careful when writing an optimization like that since it's so dramatic (removing entire blocks of code). Who knows what the internal implementation is? All we know is that adding some things makes it not work anymore, and even if they look like completely trivial additions, it's entirely plausible that the algorithm pessimistically gives up (as it should) rather than making the statement that Microsoft is cheating (poorly) on one of many, many browser tests. As someone who works on a JIT, this is a crock of poo poo. The "optimization" fails in such hilarious ways it's exceptionally clear (IMO) that they either a) wrote the optimization without any consideration for the semantics of javascript, or b) wrote it specifically for this test.
|
# ? Dec 8, 2010 19:19 |
|
ErIog posted:I think you haven't actually read the analysis into this all the way.
|
# ? Dec 8, 2010 19:19 |
|
The argument in defense of Microsoft isn't that they're competent, merely that they're not necessarily being dishonest. Also, the whole thing is still in beta isn't it?
|
# ? Dec 8, 2010 19:32 |
|
Despite the sheer amount of pain and suffering IE has caused in my professional life I have to feel bad for the team itself. It can't be easy trying to turn the IE ship around and bring it up to par with modern browsers while still maintaining support for all the integrated shell stuff Trident is called on to do. The problem is Firefox, Opera, Chrome, Safari, etc. are *just* browsers. IE is built on a rendering engine that does a lot more than just web browsing, and a lot of those decisions about what else it needs to do were made 10 years ago.
|
# ? Dec 8, 2010 19:43 |
|
Zombywuf posted:It has almost certainly been fixed to the point where it works on exactly sunspider and left at that. This. I would bet that they evaluate the performance impact of development based on its impact on sunspider scores (I know Firefox does). Get it working to the point where it gets a big boost on a SunSpider test, awesome, good job everybody. Keep working on it past that, wasting development hours for a 0% performance impact? Not happening.
|
# ? Dec 8, 2010 19:54 |
|
Janin posted:So your position is that Microsoft wrote an extremely fragile DCE algo, one that it so difficult to trigger that changing from "foo = 5; bar = 2;" to "bar = 2; foo = 5;" can break it, and by sheer coincidence the only thing it works on is a widely used benchmark suite? It's not the entire suite, though. It's a single test, CORDIC, that accounts for something like 0.5% of the overall score for most browsers. CORDIC is also written in such a way that it is conceivable for an optimization that is doing its job correctly to classify the entire test as dead code because it is, in fact, dead code. Arstechnica Article posted:That really isn't the case here; of course the optimization helps the overall score, but the scores of the top browsers are so similar (all in the 200-300 millisecond range) that they're just trading places without any meaningful difference between them. Even without the optimization, Internet Explorer 9 achieves a score within that range; it doesn't need, and isn't getting, a 179.art-style boost to its scores. I'm just not ready to get the pitchforks out to go after MS over what appears to be a mistake. It's also not like the IE9 preview build feels slow. It feels about as fast as the benchmarks would dictate. If you ran almost any beta build of any software through enough test suites, it seems like the chance is fairly high that one of the tests in one of those test suites would expose some sort of bug like this. There's a reason it's still in beta, and a bug like this is one of those reasons. This whole thing was a headline in search of a story. Alert the press! Bug found in beta software! ErIog fucked around with this message at 20:04 on Dec 8, 2010 |
# ? Dec 8, 2010 20:00 |
|
Has somebody written some test benchmarks (not just altering the Sunspider one) to see exactly what the optimizer can and can't do?
|
# ? Dec 8, 2010 20:04 |
|
Orzo posted:Has somebody written some test benchmarks (not just altering the Sunspider one) to see exactly what the optimizer can and can't do? In the Ars article there's a link to a test someone wrote which IE9 optimizes away as dead code and it actually changes the result. The optimizer makes some incorrect assumptions about JS as a language, like immutability of system types - you can make the system array type have side effects when you get a value from it, for example. So it's really fragile about what code it will apply optimizations to, but not fragile enough because it's still wrong in some corner cases.
|
# ? Dec 8, 2010 21:12 |
|
Ryouga Inverse posted:you can make the system array type have side effects when you get a value from it, for example. Doing that would be the horror.
|
# ? Dec 8, 2010 23:55 |
|
If you are not cool with that kind of horror maybe you should not be using a dynamic language in the first place.
|
# ? Dec 8, 2010 23:58 |
|
Vanadium posted:If you are not cool with that kind of horror maybe you should not be using a dynamic language in the first place. It's more than dynamic languages, though. Javascript's prototype-based approach means everything can be modified. Python or even PHP are dynamic, but you can't as easily subvert system types to do what you want with them. I'm not a python expert, but it's my understanding that you can only create new classes that imitate basic ones' behaviour and can adopt their syntax (as PHP does). On the other hand, I believe smalltalk and Ruby support that kind of monkey-patching that exists in Javascript.
|
# ? Dec 9, 2010 00:08 |
|
MononcQc posted:It's more than dynamic languages, though. Javascript's prototype-based approach means everything can be modified. It doesn't have dick all to do with prototype - prototype is simply the message dispatch system JS uses to do OOP-y things. Different languages simply choose to lock down different things. Python actually locks down builtin types pretty hard, Ruby and JS don't. Neither Python nor JS are inherently more or less flexible. You could make a python with easily reopenable classes and mutable everything or a JS with locked down builtins and and the ability to freeze objects without too much trouble at all.
|
# ? Dec 9, 2010 02:10 |
|
Mr. Wynand posted:It doesn't have dick all to do with prototype - prototype is simply the message dispatch system JS uses to do OOP-y things. you're right. A single counter example I can think of could be ActionScript 2.0, which wouldn't let you override every kind of prototype out there.
|
# ? Dec 9, 2010 03:47 |
|
This is from a dude in a freshman programming class I'm helping out, but it still cracks me up:code:
|
# ? Dec 9, 2010 08:28 |
|
Gordon Cole posted:This is from a dude in a freshman programming class I'm helping out, but it still cracks me up: We had something like code:
code:
But yeah, freshmen.
|
# ? Dec 9, 2010 12:05 |
|
Somewhere on the Internet, someone is trying to convince me that function inlining is bad, because it'd blow up the function and general executable size. And that's bad, because going from function to function is going to eat more CPU when they're all bigger and further apart. And oh, calling any function is just a simple jmp, nothing else. It'd make sense if the functions with all the inlines would (almost) exceed the size of the instruction cache, OK, but then the whole applications design's would be broken beyond belief to begin with. I'm currently writing a polyphonic analog synth on the sidelines in C# for WinPho7. Right now I'm trying to find a way to keep some sort of modularity to keep things maintainable and readable, while maximizing performance. Call overhead is killing the app in that case. And since we don't have macros or forceful inlining, that sucks. I was initially asking for C++/CLI project reference support in the WP7 SDK (macros!), when this guy showed up.
|
# ? Dec 9, 2010 15:19 |
|
|
# ? Apr 27, 2024 09:26 |
|
I gave half a talk on php last night to a local techie startup group - the first half was a php apologist - my talk wasn't so flattering: 'php: a great way to write cgi scripts' and 'we don't write cgi-scripts any more' anyway Otto came up with this slide and I figured I'd post it here
|
# ? Dec 9, 2010 16:15 |